Skip to content

perf(core): replace BTreeMap with DashMap in MemTable for concurrent access#382

Merged
ElioNeto merged 1 commit into
mainfrom
fix/memtable-concurrent
May 26, 2026
Merged

perf(core): replace BTreeMap with DashMap in MemTable for concurrent access#382
ElioNeto merged 1 commit into
mainfrom
fix/memtable-concurrent

Conversation

@ElioNeto
Copy link
Copy Markdown
Owner

Closes #367

…access

MEM-MEMTABLE-002: MemTable previously used BTreeMap for sorted key storage,
which serialized all access. Replaced with dashmap::DashMap, a shard-based
concurrent hashmap that allows lock-free reads and writes to different keys.

- DashMap provides O(1) average access vs BTreeMap's O(log n)
- Iteration now requires sorting snapshot (for SSTable flush and scan)
- Engine: flush_memtable_impl sorts entries before SSTable build
- MemTableIterator: now uses owned sorted snapshot (no lifetime issues like crossbeam-skiplist)
- TableIterator: KeyType changed to Vec<u8> for compatibility

Closes #367
@ElioNeto ElioNeto merged commit 0a5ab0c into main May 26, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MEM-MEMTABLE-002: MemTable usa BTreeMap O(log n) em vez de skip list lock-free — concorrência limitada

1 participant