Repository navigation
Keep the lobsters and shipit caches in memory - #564
Merged
Merged
Conversation
Both apps cached through a file store in tmp/cache, so processes running from one checkout shared it, and concurrent lobsters runs could fail with a 500 when one process removed a cache directory another was renaming into. A memory store keeps the same cache reads, writes and deletes per iteration without touching the disk.
thomasklemm
force-pushed
the
thomasklemm/memory-cache-store
branch
from
November 4, 2026 08:28
c4d362b to
a920bf4
Compare
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.
This changes the cache store of lobsters and shipit from a file store in
tmp/cacheto:memory_store, so each benchmark process starts with an empty cache of its own.The shared file store causes two problems. When several lobsters processes run from one checkout, some requests fail with a 500: with three processes started together, two stopped at
/replies/unreadwithErrno::ENOENTfromFile.rename, because one process deleted a cache entry and removed its empty directory while another was renaming a new entry into it. And a process starts with whatever an earlier run left intmp/cache, so its first iteration does different work depending on that. shipit uses the Rails default file store intmp/cachefor its view fragments, so it has the second problem too.With
:memory_store, the same three concurrent lobsters runs all succeed. In the iterations after warmup, both stores record 118 cache reads, 18 writes and 8 deletes per lobsters iteration, and 249 reads per shipit iteration. All 114 lobsters responses have the same byte length and story count as with the file store.Lobsters also gets faster. After warmup, the time spent in cache reads, writes and deletes, summed from Active Support's cache notifications, falls from 21.7 to 1.7 ms per iteration with ZJIT on Ruby a8b095a07e, and from 24.7 to 2.5 ms with the interpreter. That is about 2% of a lobsters iteration (2.3% with ZJIT, 1.8% with the interpreter), so lobsters results from before and after this change are not directly comparable.