Skip to content

Simplify file cache metadata and CI benchmarks#33

Merged
joecorall merged 9 commits intomainfrom
cache-eviction-storedat
May 2, 2026
Merged

Simplify file cache metadata and CI benchmarks#33
joecorall merged 9 commits intomainfrom
cache-eviction-storedat

Conversation

@joecorall
Copy link
Copy Markdown
Member

@joecorall joecorall commented May 2, 2026

Summary

This PR simplifies the file-backed cache paths and trims the benchmark harness to measure Triplet only.

Main changes:

  • move cache size/age accounting to payload file stat/mtime
  • keep source-cache content type sidecars, but remove derivative-cache content-type sidecars
  • stop mutating derivative cache entries on read hits
  • harden cache eviction against concurrent writes and temp-file races
  • make benchmark-iiif Triplet-only instead of spinning up Cantaloupe

Why

Cached benchmark latency was still much higher than expected. The first cleanup was reducing cache-hit filesystem overhead:

  • no read-side mtime refresh
  • no derivative .meta reads on hit
  • derivative cache serves content type from request format

The benchmark harness also made local/CI analysis noisier by always benchmarking Cantaloupe in the same run. This PR removes that and makes the benchmark output Triplet-focused.

Changes

Cache behavior

  • FileStore now derives:
    • Entry.Size from payload stat
    • Entry.StoredAt from payload mtime
  • max_age and max_bytes eviction now use payload file mtime
  • derivative cache uses a payload-only file store
  • source cache still stores content type sidecars

Derivative cache hits

  • no sidecar read on normal derivative cache hit
  • no cache writes on normal derivative cache hit
  • handler falls back to IIIF request format for Content-Type

Concurrency hardening

  • temp files are skipped during eviction
  • cache mode is constructor-only, not mutable after creation
  • added tests for:
    • payload-only derivative entries
    • mod-time eviction behavior
    • fake-time expiry behavior with synctest
    • in-flight temp-file preservation
    • concurrent Put() calls under constant eviction pressure

Benchmarks

  • make benchmark-iiif now runs Triplet only
  • benchmark report metadata no longer assumes Cantaloupe is present

Notes

  • If an environment still has old derivative .meta files from before the payload-only derivative store change, clearing the derivative cache is the cleanest reset.

speedup

Ran the benchmarks locally on the old codebase and this PR

make benchmark-iiif

before

Mode Concurrency Triplet OK Duration s Req/s p95 ms p99 ms CPU ms/req Max MiB
uncached 2 270/270 (100%) 18.16 14.9 156.9 287.0 53.77 138.1
uncached 4 270/270 (100%) 10.20 26.5 193.7 400.6 43.08 229.0
uncached 8 270/270 (100%) 7.77 34.7 309.0 474.8 62.82 298.9
cached 8 270/270 (100%) 4.06 66.5 11.1 22.8 1.41 129.5
cached 32 270/270 (100%) 3.98 67.9 194.5 256.0 3.72 124.9
cached 128 270/270 (100%) 3.76 71.7 323.5 444.4 2.99 142.7

after

Mode Concurrency Triplet OK Duration s Req/s p95 ms p99 ms CPU ms/req Max MiB
uncached 2 270/270 (100%) 18.17 14.9 153.4 278.8 57.89 170.4
uncached 4 270/270 (100%) 10.01 27.0 184.6 396.8 41.14 228.2
uncached 8 270/270 (100%) 7.36 36.7 295.2 477.6 57.57 320.0
cached 8 270/270 (100%) 3.75 72.0 10.3 23.3 1.29 140.4
cached 32 270/270 (100%) 3.59 75.2 188.8 240.4 3.96 153.3
cached 128 270/270 (100%) 3.63 74.5 320.7 372.2 2.84 150.2

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Benchmark Matrix: pr-33-25251913018

Summary

Triplet image: ghcr.io/libops/triplet:cache-eviction-storedat

Mode Concurrency Triplet OK Duration s Req/s p95 ms p99 ms CPU ms/req Max MiB
uncached 2 270/270 (100%) 13.32 20.3 170.6 297.9 80.09 372.0
uncached 4 270/270 (100%) 10.16 26.6 271.4 472.3 72.99 172.3
uncached 8 270/270 (100%) 10.10 26.7 404.7 621.4 73.26 270.3
cached 8 270/270 (100%) 10.18 26.5 408.5 674.8 74.90 247.7
cached 32 270/270 (100%) 10.55 25.6 558.4 715.8 74.28 341.8
cached 128 270/270 (100%) 10.71 25.2 886.0 1049.1 78.31 410.7

Status reflects Triplet request success. Performance metrics are informational.

remove cantaloupe from benchmark runs
@joecorall joecorall force-pushed the cache-eviction-storedat branch from da65c80 to 0707aba Compare May 2, 2026 11:51
@joecorall joecorall changed the title Use storedAt for cache eviction Simplify file cache metadata and make IIIF benchmarks Triplet-only May 2, 2026
@joecorall joecorall force-pushed the cache-eviction-storedat branch from daa76f7 to 8d06654 Compare May 2, 2026 12:20
@joecorall joecorall force-pushed the cache-eviction-storedat branch from 8d06654 to bb19b82 Compare May 2, 2026 12:28
@joecorall joecorall changed the title Simplify file cache metadata and make IIIF benchmarks Triplet-only Simplify file cache metadata and benchmarks May 2, 2026
@joecorall joecorall changed the title Simplify file cache metadata and benchmarks Simplify file cache metadata and CI benchmarks May 2, 2026
@joecorall joecorall merged commit c6cbd05 into main May 2, 2026
6 checks passed
@joecorall joecorall deleted the cache-eviction-storedat branch May 2, 2026 12:35
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