Use msgspec for JSON decoding and disable gc before data loading#387
Merged
Conversation
- Add istaroth.json_utils.loads backed by msgspec (~2x faster than stdlib on AGD-sized files) and switch AGD JSON decode sites to it - Add msgspec to app deps and the free-threaded regen dependency group - Move gc.disable() in generate-all before data loading, since text-map decoding and precompute allocate heavily too Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
Speeds up corpus regeneration by optimizing the JSON-decode hot path and gc behavior:
istaroth.json_utils.loads, backed bymsgspec.json.decode(~2x faster than stdlibjsonon AGD-sized files), and switches all AGD JSON decode sites (DataRepo,FirstSeenIndex) to it.msgspecto the app dependencies and to theregendependency group; msgspec ships free-threaded (3.14t) wheels, so the isolated free-threaded regen path keeps working.gc.disable()ingenerate-allto before any data loading — decoding the text maps and precompute allocate heavily too, so collection passes during that phase were pure overhead.Notable details
regengroup comment is updated: the constraint is now "must ship free-threaded wheels" rather than "pure-Python only".json_utils.dumpsto preserve byte-identical corpus output.Testing
pre-commit run(black, isort, mypy, etc.) passes on the changed files.🤖 Generated with Claude Code