Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tikv-in-memory-engine: Add link to config and extend docs #20293

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@

[TiFlash](/tiflash/tiflash-overview.md) is a key component of TiDB's HTAP architecture. It is a columnar extension of TiKV that provides both strong consistency and good isolation. TiFlash maintains columnar replicas by asynchronously replicating data from TiKV using the **Raft Learner protocol**. For reads, it leverages the **Raft consensus index** and **MVCC (Multi-Version Concurrency Control)** to achieve **Snapshot Isolation** consistency. This architecture effectively addresses isolation and synchronization challenges in HTAP workloads, enabling efficient analytical queries while maintaining real-time data consistency.

### TiKV MVCC In-Memory Engine (IME)

[TiKV MVCC In-Memory Engine](/tikv-in-memory-engine.md) (IME) caches the latest written MVCC versions in memory and implements an MVCC GC mechanism independent of TiDB to accelerate queries involving a large number of MVCC historical versions.

Check warning on line 383 in glossary.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.Ambiguous] Consider using a clearer word than 'a large number of' because it may cause confusion. Raw Output: {"message": "[PingCAP.Ambiguous] Consider using a clearer word than 'a large number of' because it may cause confusion.", "location": {"path": "glossary.md", "range": {"start": {"line": 383, "column": 201}}}, "severity": "INFO"}

### Timestamp Oracle (TSO)

Because TiKV is a distributed storage system, it requires a global timing service, Timestamp Oracle (TSO), to assign a monotonically increasing timestamp. In TiKV, such a feature is provided by PD, and in Google [Spanner](http://static.googleusercontent.com/media/research.google.com/en//archive/spanner-osdi2012.pdf), this feature is provided by multiple atomic clocks and GPS. For more information, see [TSO](/tso.md).
Expand Down
29 changes: 29 additions & 0 deletions grafana-tikv-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,35 @@
- Blob GC output file size: The size of Titan GC output file
- Blob GC file count: The count of blob files involved in Titan GC

### In Memory Engine

The following metrics are related to [TiKV MVCC In-Memory Engine](/tikv-in-memory-engine.md) (IME).

- Ops: The number of operations per second for column families
- Read MBps: The total bytes of read traffic in RocksDB and the in-memory engine
- Coprocessor Handle duration: The time consumed for handling coprocessor requests
- Region Cache Hit: The number of times data is successfully retrieved from the Region cache
- Region Cache Hit Rate: The hit rate of Region cache
- Region Cache Miss Reason: The reasons why data is not retrieved from the Region cache
- Memory Usage: The memory usage of the in-memory engine
- Region Count: The count of different types of Regions
- GC Filter: The information about the filtering process during garbage collection (GC)
- Region GC Duration: The time consumed for Region GC
- Region Load Duration: The time consumed for loading Regions
- Region Load Count: The number of Regions loaded per second
- Region Eviction Duration: The time consumed for evicting Regions
- Region Eviction Count: The number of Regions evicted per second
- Write duration: The time consumed for write operations in the Region cache engine
- 99% In-memory engine write duration per server: The 99th percentile of write duration per TiKV server for the in-memory engine

Check failure on line 433 in grafana-tikv-dashboard.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.Ordinal] Spell out all ordinal numbers ('99th') in text. Raw Output: {"message": "[PingCAP.Ordinal] Spell out all ordinal numbers ('99th') in text.", "location": {"path": "grafana-tikv-dashboard.md", "range": {"start": {"line": 433, "column": 55}}}, "severity": "ERROR"}
- Prepare for write duration: The time consumed for preparing write operations in the in-memory engine
- 99% In-memory engine prepare for write duration per server: The 99th percentile of time consumed for preparing write operations per TiKV server in the in-memory engine

Check failure on line 435 in grafana-tikv-dashboard.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.Ordinal] Spell out all ordinal numbers ('99th') in text. Raw Output: {"message": "[PingCAP.Ordinal] Spell out all ordinal numbers ('99th') in text.", "location": {"path": "grafana-tikv-dashboard.md", "range": {"start": {"line": 435, "column": 67}}}, "severity": "ERROR"}
- Iterator operations: The number of different types of iterator operations
- Seek duration: The time consumed for seek operations
- Oldest Auto GC SafePoint: The oldest automatic GC safepoint for Regions cached in the in-memory engine
- Newest Auto GC SafePoint: The newest automatic GC safepoint for Regions cached in the in-memory engine
- Auto GC SafePoint Gap: The time gap between the newest automatic GC safepoint and the oldest automatic GC safepoint for Regions cached in the in-memory engine
- Auto GC SafePoint Gap With TiKV: The gap between the TiKV automatic GC safepoint and the oldest automatic GC safepoint for Regions cached in the in-memory engine

### Pessimistic Locking

- Lock Manager Thread CPU: The CPU utilization of the lock manager thread
Expand Down
30 changes: 29 additions & 1 deletion tikv-in-memory-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The preceding diagram shows two rows of records, each with 9 MVCC versions. The

## Usage

To enable the TiKV MVCC in-memory engine (IME), you need to adjust the TiKV configuration and restart TiKV. The configuration details are as follows:
To enable the TiKV MVCC in-memory engine (IME), you need to adjust the [TiKV configuration](/tikv-configuration-file.md#in-memory-engine-new-in-v850) and restart TiKV. The configuration details are as follows:

```toml
[in-memory-engine]
Expand Down Expand Up @@ -133,3 +133,31 @@ The following result shows that queries with severe MVCC amplification exist on
+----------------------------+-----+-------------------+--------------+------------+-----------------------------------+--------------------+--------------------+--------------------+
5 rows in set (1.26 sec)
```

### How can I check whether the TiKV MVCC in-memory engine is enabled?

You can check the TiKV configuration using the [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md) statement. If the value of `in-memory-engine.enable` is `true`, it means that TiKV MVCC in-memory engine is enabled.

```sql
SHOW CONFIG WHERE Type='tikv' AND Name LIKE 'in-memory-engine\.%';
```

```
+------+-----------------+-----------------------------------------------+---------+
| Type | Instance | Name | Value |
+------+-----------------+-----------------------------------------------+---------+
| tikv | 127.0.0.1:20160 | in-memory-engine.capacity | 5GiB |
| tikv | 127.0.0.1:20160 | in-memory-engine.cross-check-interval | 0s |
| tikv | 127.0.0.1:20160 | in-memory-engine.enable | true |
| tikv | 127.0.0.1:20160 | in-memory-engine.evict-threshold | 4920MiB |
| tikv | 127.0.0.1:20160 | in-memory-engine.gc-run-interval | 3m |
| tikv | 127.0.0.1:20160 | in-memory-engine.load-evict-interval | 5m |
| tikv | 127.0.0.1:20160 | in-memory-engine.mvcc-amplification-threshold | 10 |
| tikv | 127.0.0.1:20160 | in-memory-engine.stop-load-threshold | 4208MiB |
+------+-----------------+-----------------------------------------------+---------+
8 rows in set (0.00 sec)
```

### How can I monitor the TiKV MVCC in-memory engine?

You can check the [**In Memory Engine**](/grafana-tikv-dashboard.md#in-memory-engine) section on the TiKV-Details dashboard in Grafana.