Conversation
Author
|
The initial version moved timestamp writes off the request path and deduplicated repeated The worker now updates the entire batch with one statement: UPDATE object
SET last_accessed_at = NOW()
WHERE id IN (...);A dedicated PostgreSQL benchmark compared the previous per-object writes with the bulk
This keeps the single-object case effectively unchanged while substantially reducing database The benchmark also verifies that every expected object receives an updated timestamp. |
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.
Move NAR access timestamp updates out of the download response path and coalesce repeated
accesses.
Previously, every successful NAR request synchronously updated object.last_accessed_at before
returning the response. With remote PostgreSQL, this adds a database round trip to every
download and generates unnecessary writes when an object is requested repeatedly.
This change adds a bounded background access tracker:
The worker currently performs one database update per unique object ID. This change reduces
duplicate writes and removes access tracking from response latency; it does not introduce a
bulk SQL update. (EDIT: No longer true, see comment)
Also fixes the PostgreSQL integration-test connection URL to explicitly use the atticd
database user.
last_accessed_at supports retention and observability. It does not need to block a NAR
download or record every individual access precisely.
In the benchmark workload, 8,000 requests to one object previously caused 8,000 synchronous
PostgreSQL updates. Coalescing reduced this to approximately 8 updates while preserving access
tracking.
Benchmark results
NixOS VM benchmark using Attic, PostgreSQL, and Garage S3:
Failure behavior
Access tracking is intentionally best-effort:
Testing