Skip to content

⚡ perf(oci): replace Moka membership cache#220

Open
gaborbernat wants to merge 1 commit into
tox-dev:mainfrom
gaborbernat:fix/oci-membership-cache-speed
Open

⚡ perf(oci): replace Moka membership cache#220
gaborbernat wants to merge 1 commit into
tox-dev:mainfrom
gaborbernat:fix/oci-membership-cache-speed

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Jul 12, 2026

Copy link
Copy Markdown
Member

We added repository-scoped blob authorization in PR #211. We measured oci_blob_serve with CodSpeed simulation at 87.6 µs on its parent and 694.7 µs at commit 45f0155. We recorded the regression in #219.

We replace Moka with a parking_lot read lock and a hash set, giving cache hits one lock and one lookup. We store one Arc<str> in both the set and FIFO under an 8 MiB encoded-key cap and recheck misses under the write lock; concurrent readers cannot count a key twice.

We use redb for misses and hold the write lock through persistent invalidation so a client reading during deletion cannot restore a deleted membership. We preserve repository isolation and shared blob storage from #211; operators do not need to change configuration or data.

@gaborbernat gaborbernat added bug Something isn't working priority:P1 Protocol parity or important product gap type:performance Latency, throughput, memory, or cache efficiency area:performance Cache, HTTP, memory, and benchmark work area:storage Blob stores, object storage, and storage backend work labels Jul 12, 2026
@read-the-docs-community

read-the-docs-community Bot commented Jul 12, 2026

Copy link
Copy Markdown

@codspeed-hq

codspeed-hq Bot commented Jul 12, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 13.28%

❌ 1 regressed benchmark
✅ 28 untouched benchmarks
⏩ 62 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime oci_version_check 5.4 µs 6.3 µs -13.28%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:fix/oci-membership-cache-speed (043a328) with main (38729f8)

Open in CodSpeed

Footnotes

  1. 62 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gaborbernat gaborbernat force-pushed the fix/oci-membership-cache-speed branch 2 times, most recently from a9fb29c to 86b82a2 Compare July 12, 2026 21:31
@gaborbernat gaborbernat added the enhancement New feature or request label Jul 13, 2026
@gaborbernat gaborbernat changed the title ⚡ perf(oci): streamline membership cache ⚡ perf(oci): replace Moka membership cache Jul 13, 2026
@gaborbernat gaborbernat force-pushed the fix/oci-membership-cache-speed branch from 86b82a2 to 89f771a Compare July 13, 2026 04:34
We measured a 7.9x slowdown after adding Moka to repository-scoped
blob reads in PR tox-dev#211.

Use a bounded `parking_lot` read lock and hash set for one lookup per
hit; recheck misses under the write lock so concurrent reads cannot
count a key twice. Keep redb authoritative on misses. Hold the write
lock through persistent invalidation so clients cannot read a deleted
link from the cache.
@gaborbernat gaborbernat force-pushed the fix/oci-membership-cache-speed branch from 89f771a to 043a328 Compare July 13, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:performance Cache, HTTP, memory, and benchmark work area:storage Blob stores, object storage, and storage backend work bug Something isn't working enhancement New feature or request priority:P1 Protocol parity or important product gap type:performance Latency, throughput, memory, or cache efficiency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant