Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging around Zarr manifest cache interactions #170

Merged
merged 14 commits into from
Aug 19, 2024
Merged

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Jul 16, 2024

This PR makes the following changes:

  • Format all log lines as JSON
  • Add logging of Zarr manifest cache events
  • Limit Zarr manifest cache by total size of entries
    • Add a -Z/--zarrman-cache-bytes option for setting the cache size (default: 100 MiB)
  • Expire idle Zarr manifest cache entries after 5 minutes
  • Log Zarr manifest cache entries every hour
  • Add a Python script under tools/ for taking one or more Heroku log files and producing statistics about the Zarr manifest cache

Part of #118.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 1.75439% with 112 lines in your changes missing coverage. Please review.

Project coverage is 46.33%. Comparing base (6d87388) to head (36a059c).
Report is 15 commits behind head on main.

Files Patch % Lines
src/zarrman/fetcher.rs 0.00% 79 Missing ⚠️
src/zarrman/mod.rs 0.00% 9 Missing ⚠️
src/main.rs 0.00% 7 Missing ⚠️
src/zarrman/util.rs 0.00% 7 Missing ⚠️
src/paths/component.rs 0.00% 5 Missing ⚠️
src/zarrman/resources.rs 0.00% 4 Missing ⚠️
src/zarrman/manifest.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
- Coverage   46.97%   46.33%   -0.64%     
==========================================
  Files          27       29       +2     
  Lines        3930     3984      +54     
==========================================
  Hits         1846     1846              
- Misses       2084     2138      +54     

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

@jwodder jwodder self-assigned this Jul 17, 2024
@jwodder jwodder added this to the Current priorities milestone Jul 17, 2024
@jwodder jwodder added the OOM Dealing with out-of-memory errors label Jul 17, 2024
@jwodder jwodder force-pushed the cache-log branch 2 times, most recently from ec2eadd to 57b47dd Compare July 22, 2024 12:26
@jwodder jwodder removed this from the Current priorities milestone Jul 22, 2024
@jwodder jwodder force-pushed the cache-log branch 4 times, most recently from 60afdd3 to 35f169c Compare July 26, 2024 18:09
@jwodder jwodder force-pushed the cache-log branch 2 times, most recently from a168770 to ade0877 Compare August 5, 2024 21:15
@jwodder jwodder added the hier:zarrs Relating to serving the /zarrs/ hierarchy label Aug 6, 2024
@jwodder jwodder marked this pull request as ready for review August 6, 2024 13:00
@jwodder jwodder requested a review from yarikoptic August 6, 2024 13:01
@jwodder jwodder force-pushed the cache-log branch 2 times, most recently from 58eeb5e to 30936a2 Compare August 12, 2024 12:22
@jwodder
Copy link
Member Author

jwodder commented Aug 12, 2024

@yarikoptic Ready for review.

@jwodder
Copy link
Member Author

jwodder commented Aug 14, 2024

@yarikoptic Ping.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

Just left some comments/questions more for my own education I guess. Would be great to see it in action

README.md Outdated
Comment on lines 123 to 125
- `-Z <INT>`, `--zarrman-cache-bytes <INT>` — Specify the maximum number of
bytes of parsed Zarr manifest files to store in the Zarr manifest cache at
once [default: 100 MiB]
Copy link
Member

Choose a reason for hiding this comment

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

may be just worth making it

Suggested change
- `-Z <INT>`, `--zarrman-cache-bytes <INT>` — Specify the maximum number of
bytes of parsed Zarr manifest files to store in the Zarr manifest cache at
once [default: 100 MiB]
- `-Z <INT>`, `--zarrman-cache-megabytes <INT>` — Specify the maximum number of
megabytes of parsed Zarr manifest files to store in the Zarr manifest cache at
once [default: 100]

since unlikely we would ever look into less than 1 MiB? That might make it easier to use this option

Copy link
Member Author

Choose a reason for hiding this comment

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

Done: fe32cf6

})
.time_to_idle(MANIFEST_CACHE_IDLE_EXPIRY)
.eviction_listener(|path, manifest, cause| {
tracing::debug!(
Copy link
Member

Choose a reason for hiding this comment

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

test coverage annotation is funny here but suggests that most here is not tested Does it mean that logging on eviction doesn't happen ie. evictions do not happen during testing? (I am not yet a good reader of Rust, sorry)

Copy link
Member Author

Choose a reason for hiding this comment

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

None of the caching is currently tested.

tools/zarr-cache-stats.py Show resolved Hide resolved
start: MissMoment
end: MissMoment
#: Number of other misses in progress as of the end of this miss
parallel: int
Copy link
Member

Choose a reason for hiding this comment

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

interesting why of interest "as of the end" and not "as of the beginning"?

Copy link
Member Author

Choose a reason for hiding this comment

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

It all comes out the same either way, but I had to pick one.

for k, v in misses_in_progress.items()
)
misses_in_progress = {}
last_accesses = {}
Copy link
Member

Choose a reason for hiding this comment

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

is this the end and there should be no other hits or a new dandidav starts and we should get new separate stats or you are just collating them across all runs?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the start of a new dandidav process, so any information specific to the previous process needs to be cleared.

1 for ts in last_accesses.values() if ts > last_access
)
else:
recency_index = len(last_accesses)
Copy link
Member

Choose a reason for hiding this comment

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

when/how do we hit this on "hit"?... not exactly following

Copy link
Member Author

Choose a reason for hiding this comment

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

This happens if the provided logs start in the middle of a server process and a hit is encountered for an entry that was previously accessed before the start of the logs.

@jwodder
Copy link
Member Author

jwodder commented Aug 19, 2024

@yarikoptic Please re-review; can this be merged now?

@yarikoptic
Copy link
Member

Yes, thank you! Let's try it out in action!

@yarikoptic yarikoptic merged commit 38b59ef into main Aug 19, 2024
9 of 11 checks passed
@yarikoptic yarikoptic deleted the cache-log branch August 19, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
caching hier:zarrs Relating to serving the /zarrs/ hierarchy logging OOM Dealing with out-of-memory errors tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants