Skip to content

reduce memory consumption of files cache, fixes #5756#8511

Merged
ThomasWaldmann merged 2 commits intoborgbackup:masterfrom
ThomasWaldmann:files-cache-using-borghash
Nov 1, 2024
Merged

reduce memory consumption of files cache, fixes #5756#8511
ThomasWaldmann merged 2 commits intoborgbackup:masterfrom
ThomasWaldmann:files-cache-using-borghash

Conversation

@ThomasWaldmann
Copy link
Copy Markdown
Member

@ThomasWaldmann ThomasWaldmann commented Nov 1, 2024

  • refactor packing/unpacking of fc entries into separate functions
  • instead of a chunks list entry being a tuple of 256bit id [bytes] and 32bit size [int],
    only store a stable 32bit index into kv array of ChunkIndex (where we also have id and
    size [and refcount]).
  • only done in memory, the on-disk format has (id, size) tuples.

memory consumption (N = entry.chunks list element count, X = overhead for rest of entry):

  • previously:
    • packed = packb(dict(..., chunks=[(id1, size1), (id2, size2), ...]))
    • packed size ~= X + N * (1 + (34 + 5)) Bytes
  • now:
    • packed = packb(dict(..., chunks=[ix1, ix2, ...]))
    • packed size ~= X + N * 5 Bytes

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 97.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.75%. Comparing base (1ec66ed) to head (26bb782).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/cache.py 97.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8511      +/-   ##
==========================================
+ Coverage   81.43%   81.75%   +0.32%     
==========================================
  Files          73       73              
  Lines       13108    13139      +31     
  Branches     1924     1926       +2     
==========================================
+ Hits        10674    10742      +68     
+ Misses       1769     1740      -29     
+ Partials      665      657       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- refactor packing/unpacking of fc entries into separate functions
- instead of a chunks list entry being a tuple of 256bit id [bytes] and 32bit size [int],
  only store a stable 32bit index into kv array of ChunkIndex (where we also have id and
  size [and refcount]).
- only done in memory, the on-disk format has (id, size) tuples.

memory consumption (N = entry.chunks list element count, X = overhead for rest of entry):
- previously:
  - packed = packb(dict(..., chunks=[(id1, size1), (id2, size2), ...]))
  - packed size ~= X + N * (1 + (34 + 5)) Bytes
- now:
  - packed = packb(dict(..., chunks=[ix1, ix2, ...]))
  - packed size ~= X + N * 5 Bytes
@ThomasWaldmann ThomasWaldmann force-pushed the files-cache-using-borghash branch from 5c34c21 to 26bb782 Compare November 1, 2024 16:48
@ThomasWaldmann ThomasWaldmann merged commit 3c38b2f into borgbackup:master Nov 1, 2024
@ThomasWaldmann ThomasWaldmann deleted the files-cache-using-borghash branch November 1, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant