Repository navigation
Read the caches without a lock on JRuby - #95
Merged
Merged
Conversation
Since #90 every cache read took a Mutex off CRuby, so on JRuby throughput stayed at one thread's pace whatever the number of threads (#93). JRuby's tables are now a ConcurrentHashMap whose keys stay Ruby Strings, and Bot's keyword patterns a frozen table replaced whole under its lock. Closes #93 Assisted-by: Claude [Claude Code]
Assisted-by: Claude [Claude Code]
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.
Since #90, every cache read takes a Mutex off CRuby, so on JRuby a process answering user agents it has already seen stays at one thread's throughput whatever the number of threads (#93).
JRuby's cache tables are now a
java.util.concurrent.ConcurrentHashMap, whose reads take no lock. Bot's keyword patterns, the last table read under a lock, become a frozen table that a write replaces whole underKEYWORDS_LOCK, on every Ruby. CRuby's tables are unchanged, and TruffleRuby keeps the locked tables.RubyString, compared like Hash keys, and a new test checks these cases on every engine.Measurements (JRuby 10.0.2, 4 cores, shared machine)
The script from #93: 20 user agents asked over and over, so every lookup is a cache hit, 10 s of JIT warmup, median of 3 measures of 2 s, two runs each, alternated. Throughput relative to one thread:
The machine's load varies between runs, but main never scales and this branch does on every run.
Generated by Claude Code