Repository navigation
Make CommandStorage namespaces a ConcurrentHashMap - #514
Closed
lewisgibson wants to merge 2 commits into
Closed
lewisgibson wants to merge 2 commits into
lewisgibson wants to merge 2 commits into
Conversation
CommandStorage lazily fills a plain HashMap of namespace containers from whichever region reads it first. See the patch for details.
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.
CommandStoragelazily loads a namespace's container into a plainHashMapthe first time it is read. Loot tables with a storage nbt or number provider and text components with a storage source read it from whichever region is running them, so two regions reading a namespace for the first time at once race on the put. This makes the map aConcurrentHashMap, like the saved data storage cache it loads from, and folds the change into the Region Threading Base patch.Tested on ver/26.2.x with a small test plugin that starts 8 threads at once, each calling
CommandStorage#setfor 5000 distinct namespaces (40000 in total), then countskeys(). It usessetbecause that is the quickest way to put many namespaces into the map from many threads, and it is the same map and the same unsynchronised put. On the unpatched build 202 of the 40000 entries were lost to the race, with this change none were.This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.