read improvement: don't finalize compaction of imm_ right away, but delay it until it is really needed
- Dominant language
- C++
- Stars
- 39.4k
- Forks
- 8.2k
- PR merge metrics
- No merged PRs in 30d
Description
Current read path looks like this:
1) Read key from **mem_** memtable. If we have a value we are done, otherwise go to 2.
2) Read key from **imm_** memtable (if not yet compacted and finalized). If we have a value we are done (and don't need to scan levels on disk), otherwise we go for a level-by-level scan.
I suggest to improve the second step of the read path.
When we do a compaction (_DBImpl::CompactMemTable()_) we first save the contents of the **imm_** memtable to a disk, then we delete obsolete files relevant to it and after that we finalize compaction by unreference of **imm_** and setting it to null.
In order to improve the second step of the read path, we can delay setting **imm_** to null until we really need it (will be done in _DBImpl::MakeRoomForWrite()_). Thus recent data will be still in memory and available for _DBImpl::Get()_ operation.
I didn't want to create a PR for this, because I want to make sure that it makes sense and I'm not missing anything.
Contributor guide
Assessment
This issue has not been assessed yet.