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 #19890

Merged
merged 6 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ PD 中的 Store 指的是集群中的存储节点,也就是 tikv-server 实例

[TiFlash](/tiflash/tiflash-overview.md) 是 TiDB HTAP 形态的关键组件,它是 TiKV 的列存扩展,在提供良好隔离性的同时,也兼顾了强一致性。列存副本通过 Raft Learner 协议异步复制 TiKV 的数据。在读取时,它通过 Raft 校对索引配合 MVCC(多版本并发控制)的方式获得 Snapshot Isolation 的一致性隔离级别。这个架构很好地解决了 HTAP 场景的隔离性以及列存同步的问题,在进行高效分析查询的同时保持实时数据的一致性。

### TiKV MVCC 内存引擎 (In-Memory Engine, IME)

[TiKV MVCC 内存引擎 (IME)](/tikv-in-memory-engine.md) 在内存中缓存最近写入的 MVCC 版本,并实现独立于 TiDB 的 MVCC GC 机制,以加速涉及大量 MVCC 历史版本的查询。

### Timestamp Oracle (TSO)

因为 TiKV 是一个分布式的储存系统,它需要一个全球性的授时服务 TSO (Timestamp Oracle),来分配一个单调递增的时间戳。这样的功能在 TiKV 中是由 PD 提供的,在 Google 的 [Spanner](http://static.googleusercontent.com/media/research.google.com/en//archive/spanner-osdi2012.pdf) 中是由多个原子钟和 GPS 来提供的。详见 [TSO 文档](/tso.md)。
Expand Down
31 changes: 30 additions & 1 deletion grafana-tikv-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ summary: TiKV 监控指标详解:TiUP 部署 TiDB 集群时,一键部署监
- CDC Worker CPU:CDC Worker 线程的 CPU 使用率
- CDC endpoint CPU:CDC endpoint 的 CPU 使用率
- Raftlog fetch worker CPU:Async raft log fetcher worker 的 CPU 使用率
- TSO Worker CPU: TSO Worker 线程的 CPU 使用率
- TSO Worker CPUTSO Worker 线程的 CPU 使用率

### PD

Expand Down Expand Up @@ -409,6 +409,35 @@ summary: TiKV 监控指标详解:TiUP 部署 TiDB 集群时,一键部署监
- Blob GC output file size:Titan GC 输出文件的大小
- Blob GC file count:Titan GC 涉及的 blob 文件数量

### In Memory Engine

以下为 [TiKV MVCC 内存引擎](/tikv-in-memory-engine.md) (In-Memory Engine, IME) 的监控指标。

- Ops:每秒列族操作次数
- Read MBps:RocksDB 和内存引擎的总体读流量(字节)
- Coprocessor Handle duration:处理 coprocessor 请求的耗时
- Region Cache Hit:从 Region 缓存中成功读取数据的次数
- Region Cache Hit Rate:Region 缓存的命中率
- Region Cache Miss Reason:从 Region 缓存中读取数据失败的原因
- Memory Usage:内存引擎的内存使用情况
- Region Count:不同类型的 Region 的数量
- GC Filter:垃圾回收 (GC) 过程中过滤相关的信息
- Region GC Duration:Region 垃圾回收的耗时
- Region Load Duration:加载 Region 的耗时
- Region Load Count:每秒加载的 Region 的数量
- Region Eviction Duration:驱逐 Region 的耗时
- Region Eviction Count:每秒驱逐的 Region 的数量
- Write duration:写操作的耗时
- 99% In-memory engine write duration per server:内存引擎每秒写操作的 99% 耗时
- Prepare for write duration:准备写操作的耗时
- 99% In-memory engine prepare for write duration per server:内存引擎每秒准备写操作的 99% 耗时
- Iterator operations:不同类型的 iterator 操作的数量
- Seek duration:seek 操作的耗时
- Oldest Auto GC SafePoint:内存引擎缓存的 Region 中,最早的自动 GC safepoint
- Newest Auto GC SafePoint:内存引擎缓存的 Region 中,最新的自动 GC safepoint
- Auto GC SafePoint Gap:内存引擎缓存的 Region 中,最新的自动 GC safepoint 和最早的自动 GC safepoint 之间的时间差
- Auto GC SafePoint Gap With TiKV:TiKV 的自动 GC safepoint 和内存引擎缓存的 Region 中最早的自动 GC safepoint 之间的时间差

### Pessimistic Locking

- Lock Manager Thread CPU:lock manager 的线程 CPU 使用率
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 @@ TiKV MVCC 内存引擎在内存中缓存最近写入的 MVCC 版本,并实现

## 使用方式

如果要开启 TiKV MVCC 内存引擎 (IME) 功能,需要调整 TiKV 配置并重启 TiKV。以下是配置说明:
如果要开启 TiKV MVCC 内存引擎 (IME) 功能,需要调整 [TiKV 配置](/tikv-configuration-file.md#in-memory-engine-从-v850-版本开始引入)并重启 TiKV。以下是配置说明:

```toml
[in-memory-engine]
Expand Down Expand Up @@ -132,3 +132,31 @@ LIMIT 5;
+----------------------------+-----+-------------------+--------------+------------+-----------------------------------+--------------------+--------------------+--------------------+
5 rows in set (1.26 sec)
```

### 如何判断 TiKV MVCC 内存引擎是否开启?

你可以使用 [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md) 语句查看 TiKV 配置。如果 `in-memory-engine.enable` 的值为 `true`,表示 TiKV MVCC 内存引擎已经开启。

```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)
```

### 如何监控 TiKV MVCC 内存引擎?

你可以查看 TiKV-Details 面板中的 [**In Memory Engine**](/grafana-tikv-dashboard.md#in-memory-engine) 部分。
Loading