Optimize indexMaxBlobs for lower memory usage#2631
Closed
MichaelEischer wants to merge 1 commit intorestic:masterfrom
Closed
Optimize indexMaxBlobs for lower memory usage#2631MichaelEischer wants to merge 1 commit intorestic:masterfrom
MichaelEischer wants to merge 1 commit intorestic:masterfrom
Conversation
Each index file is currently loaded into a separate hashmap. Go hashmaps use a load factor of 6.5/8 and allocate an array whose size is a power of two. For 2000 entries this requires a array with 4096 slots which wastes a lot of memory. The maximum number of entries for that array size would be 3328. However, leave some headroom as the index_uploader only runs every 30 seconds.
8 tasks
Member
Author
|
Obsoleted by #2749. |
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 is the purpose of this change? What does it change?
Reduce the memory required to load preliminary index files. If an preliminary index is uploaded during backup and it is considered as full because its blob count reached indexMaxBlobs, then the hashmap used to loaded this index wastes a lot of memory:
Go hashmaps use a load factor of 6.5/8 and allocate an array whose size is a power of two. For 2000 entries this requires a array with 4096 slots which wastes a lot of memory. The maximum number of entries for that array size would be 3328. However, leave some headroom as the index_uploader only runs every 30 seconds.
I'm not sure whether a changelog entry is required. The memory usage of restic should be slightly lower when running backups without calling rebuild-index inbetween, but it's hard to tell by how much.
Was the change discussed in an issue or in the forum before?
No. I noticed the problem during the discussions in #2523.
Checklist
[ ] I have added tests for all changes in this PR[ ] I have added documentation for the changes (in the manual)changelog/unreleased/that describes the changes for our users (template here)gofmton the code in all commits