Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Conversation

@fingon
Copy link
Contributor

@fingon fingon commented Nov 29, 2023

The endgame we really want is adding per-node manifests and some sort of summary manifest to be handled here, not keeping the 'too old' manifests in memory helps a lot in case of nodes which have already taken too many backups.

With this, we will load only up to the <amount kept+1> manifests to memory at most, so having e.g. 70 manifests in object storage and 5 kept means we at most have 6 in memory at a time.

(As seen in production.)



def _prune_manifests(manifests: List[ipc.BackupManifest], retention: Retention) -> List[ipc.BackupManifest]:
manifests = sorted(manifests, key=lambda m: (m.start, m.end, m.filename), reverse=True)
Copy link
Contributor Author

@fingon fingon Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: Not sure if some later step makes assumptions about order -> sort even if we don't change the list here. Also, while this sorts list every time manifest is inserted, we have only tens of backup manifests at most so I didn't go for e.g. biject module's sorted insert.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked all 3 instances of context.get_result(ComputeKeptBackupsStep) and all operations are essentially on sets, so no ordering issue expected there.

@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4cdca34) 87.31% compared to head (3429f28) 87.32%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #161   +/-   ##
=======================================
  Coverage   87.31%   87.32%           
=======================================
  Files         141      141           
  Lines       10035    10040    +5     
=======================================
+ Hits         8762     8767    +5     
  Misses       1273     1273           

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

@fingon fingon marked this pull request as ready for review November 29, 2023 08:03
The endgame we really want is adding per-node manifests and some sort
of summary manifest to be handled here, not keeping the 'too old'
manifests in memory helps a lot in case of nodes which have already
taken too many backups.

With this, we will load only up to the <amount kept+1> manifests to
memory at most, so having e.g. 70 manifests in object storage and 5
kept means we at most have 6 in memory at a time.

(As seen in production.)
@kmichel-aiven kmichel-aiven merged commit 0cba114 into main Nov 29, 2023
@kmichel-aiven kmichel-aiven deleted the mst-memory-efficient-cleanup branch November 29, 2023 09:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants