Skip to content

[P0] [Performance] Unable to parallel kv-write #42

@gaoteng-git

Description

@gaoteng-git

问题描述:
使用同一 wallet 的key如果进行并发写入,写入间隔需要 > 1 秒才能大概率成功。
(多个wallet key,支持并发写入)。

测试数据:

写入间隔 成功率 备注
< 0.5秒 <20% 高失败率
0.5-1秒 ~50% 不稳定
> 1秒 >90% 稳定

根本原因(推测):

  • 区块链 nonce 冲突

建议方案:

写缓存队列
┌─────────────────────────────────┐
│ 写入队列 (按 wallet) │
│ ├─ key1: value1 (t=0ms) │
│ ├─ key2: value2 (t=200ms) │
│ └─ key1: value1_new (t=500ms) │ ← 保留最新
└─────────────────────────────────┘
↓ (定时 flush)
Batch Write to 0G
(
0G目前支持Batch Write:
0g-kv-storage write
--stream-keys "key1,key2"
--stream-values "value1,value2"
)

队列策略

  • 去重: 同一 key 只保留最新值
  • Flush 触发: 超时 2s 或达到 100 条
  • 读取: 先查队列(最新数据),miss 则查 storage

待确认问题:

  1. 该并发解决方案,在0G侧,还是EverMemOS应用层实现?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions