Repository navigation
Conversation
Eviction and retention clear an artifact's storage_path and keep the row. In idx_artifacts_last_used those rows sort first, so every eviction batch walked past every artifact ever cleared before it found one still in storage. The index is now partial, on storage_path IS NOT NULL, which the eviction query already filters on.
Renumber the index migration to 025; git-pkgs#702 took 024.
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.
Eviction gets slower with every artifact it has ever cleared.
Eviction and retention clear an artifact's
storage_pathand keep the row. Inidx_artifacts_last_usedthose rows sort first: they were the least recently used, and a cleared row that was never served has no date left at all.GetLeastRecentlyUsedCacheEntriesreads that index in order and looks up each row to find 50 that are still in storage, so every batch walks past every cleared row. Eviction asks for a batch again and again until the cache fits.The index is now partial, on
storage_path IS NOT NULL. The eviction query already filters on that, so the query is unchanged. Migration025drops and recreates the index in one transaction.Measured with 200,000 artifacts, 150,000 of them cleared, one batch of 50:
Both return the same 50 entries. The migration took 34 ms on SQLite and 12 ms on Postgres for that table. On Postgres,
CREATE INDEXblocks writes toartifactswhile it builds.Tests cover the index definition in a fresh schema, the migration from the old index (run twice, and from no index), and that eviction still lists stored artifacts in order with cleared ones left out. They run on SQLite and Postgres.
#709 also adds migrations; whichever lands later needs renumbering.
Summary by CodeRabbit