Repository navigation
Keeper memory optimization by not holding snapshot in memory - #34584
Merged
Merged
Conversation
alesapin
reviewed
Feb 15, 2022
| return -1; | ||
| } | ||
| data_out = nuraft::buffer::clone(*latest_snapshot_buf); | ||
| int fd = ::open(latest_snapshot_path.c_str(), O_RDONLY); |
Member
There was a problem hiding this comment.
Let's move this code into separate function.
alesapin
reviewed
Feb 15, 2022
| LOG_WARNING(log, "Error opening {}.", latest_snapshot_path); | ||
| return -1; | ||
| } | ||
| auto file_size = ::lseek(fd, 0, SEEK_END); |
Member
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
This is used only on Linux, not suitable for mac os x.
Co-authored-by: alesapin <[email protected]>
alesapin
reviewed
Feb 15, 2022
| return -1; | ||
| } | ||
| data_out = nuraft::buffer::clone(*latest_snapshot_buf); | ||
| if (bufferFromFile(log, latest_snapshot_path, data_out)) |
Contributor
Author
There was a problem hiding this comment.
Errno has been printed in the inner function.
Member
|
|
Contributor
Author
|
alesapin
approved these changes
Feb 17, 2022
Co-authored-by: alesapin <[email protected]>
Contributor
Author
|
@alesapin Thanks for your review, can merge now? |
Member
4 tasks done
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.

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Don't hold the latest snapshot in memory, instead, reading the snapshot if needed, sequence reading is fast to 200+MBps even on HDD using mmap system call.
Writing snapshot data directly to disk using compression method without holding original data and compressed data in memory.
Effect: about 20% saving memory

client command:
./utils/keeper-bench/keeper-bench --host=127.0.0.1:12183 -c 128 --generator=create_small_datanew version:
master version(34092fa):
