kv: replace memdb with a more memory efficient version#11807
Merged
sre-bot merged 12 commits intopingcap:masterfrom Aug 29, 2019
Merged
kv: replace memdb with a more memory efficient version#11807sre-bot merged 12 commits intopingcap:masterfrom
sre-bot merged 12 commits intopingcap:masterfrom
Conversation
ngaut
reviewed
Aug 21, 2019
ngaut
reviewed
Aug 21, 2019
ngaut
reviewed
Aug 21, 2019
Codecov Report
@@ Coverage Diff @@
## master #11807 +/- ##
===========================================
Coverage 81.2942% 81.2942%
===========================================
Files 441 441
Lines 94805 94805
===========================================
Hits 77071 77071
Misses 12257 12257
Partials 5477 5477 |
Contributor
|
/run-all-tests |
coocood
reviewed
Aug 21, 2019
kv/memdb/arena.go
Outdated
| } | ||
|
|
||
| func newArenaAddr(blockIdx int, blockOffset uint32) arenaAddr { | ||
| return arenaAddr(uint64(blockIdx+1)<<32 | uint64(blockOffset)) |
Contributor
Author
There was a problem hiding this comment.
blockIdx == 0 && blockOffset == 0 means null.
Maybe we can place a nil pointer at blocks[0] to make blockIdx starts at 1?
coocood
reviewed
Aug 22, 2019
Member
|
LGTM |
coocood
reviewed
Aug 22, 2019
coocood
reviewed
Aug 22, 2019
tiancaiamao
reviewed
Aug 23, 2019
tiancaiamao
reviewed
Aug 23, 2019
Member
|
/run-all-tests |
Contributor
|
LGTM |
Member
|
/run-all-tests |
ngaut
approved these changes
Aug 28, 2019
Contributor
|
/run-all-tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
The existing memdb from goleveldb use a contiguous memory to store data. It will put pressure on system memory when enlarging the underlying slice. After supporting large transaction, this problem will be more obvious.
What is changed and how it works?
Implementing a new skiplist with a block-based memory allocator, when enlarging the memdb simply allocate a new block instead of allocating a large amount of memory and copy all of the existing data into the new memory location.
The block size starts at an initial block size then doubled when each new block allocated until it reaches 128M.
Because there are some internal data structure optimization, the performance of
GetandPutis slightly improved.Here is the result of benchmarks in
kvpackage:opCnt = 100000
master
new
opCnt = 10000000
master
new
Check List
Tests
Side effects