Skip to content

Use msgspec for JSON decoding and disable gc before data loading#387

Merged
isundaylee merged 1 commit into
mainfrom
benchmark-chs-text-regen
Jul 11, 2026
Merged

Use msgspec for JSON decoding and disable gc before data loading#387
isundaylee merged 1 commit into
mainfrom
benchmark-chs-text-regen

Conversation

@isundaylee

Copy link
Copy Markdown
Owner

What & why

Speeds up corpus regeneration by optimizing the JSON-decode hot path and gc behavior:

  • Adds istaroth.json_utils.loads, backed by msgspec.json.decode (~2x faster than stdlib json on AGD-sized files), and switches all AGD JSON decode sites (DataRepo, FirstSeenIndex) to it.
  • Adds msgspec to the app dependencies and to the regen dependency group; msgspec ships free-threaded (3.14t) wheels, so the isolated free-threaded regen path keeps working.
  • Moves gc.disable() in generate-all to before any data loading — decoding the text maps and precompute allocate heavily too, so collection passes during that phase were pure overhead.

Notable details

  • The regen group comment is updated: the constraint is now "must ship free-threaded wheels" rather than "pure-Python only".
  • JSON encoding still goes through the stdlib-based json_utils.dumps to preserve byte-identical corpus output.

Testing

  • pre-commit run (black, isort, mypy, etc.) passes on the changed files.

🤖 Generated with Claude Code

- 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>
@isundaylee isundaylee merged commit fd19f67 into main Jul 11, 2026
2 checks passed
@isundaylee isundaylee deleted the benchmark-chs-text-regen branch July 11, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant