-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
kv: replace memdb with a more memory efficient version #11807
Conversation
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 |
/run-all-tests |
kv/memdb/arena.go
Outdated
} | ||
|
||
func newArenaAddr(blockIdx int, blockOffset uint32) arenaAddr { | ||
return arenaAddr(uint64(blockIdx+1)<<32 | uint64(blockOffset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not +1
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blockIdx == 0 && blockOffset == 0
means null
.
Maybe we can place a nil
pointer at blocks[0]
to make blockIdx
starts at 1
?
LGTM |
/run-all-tests |
LGTM |
/run-all-tests |
/run-all-tests |
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
Get
andPut
is slightly improved.Here is the result of benchmarks in
kv
package:opCnt = 100000
master
new
opCnt = 10000000
master
new
Check List
Tests
Side effects