Skip to content

bluejay-parser: performance optimizations#95

Open
swalkinshaw wants to merge 1 commit intomainfrom
parser-perf-optimizations
Open

bluejay-parser: performance optimizations#95
swalkinshaw wants to merge 1 commit intomainfrom
parser-perf-optimizations

Conversation

@swalkinshaw
Copy link
Contributor

~16% faster schema parsing, ~12% faster executable parsing

Key optimizations:

  • Rewrite block string parser: direct string processing instead of sub-lexer + Vec<Vec> (~10%)
  • Compact Span: u32 start+len (8 bytes) instead of Range (16 bytes), add Copy (~3%)
  • Field: consume-then-check for alias instead of peek(1) (~2%)
  • Optimize next_if_* methods: peek+consume in single buffer operation (~1%)
  • Lazy depth_limiter.bump(): only bump when optional elements exist
  • Add Copy to DepthLimiter + preallocate Vec capacity in DefinitionDocument

Also adds benchmarks for ExecutableDocument parsing with a large fixture, and updates downstream crates to use Copy semantics on Span (clone → deref).

Note: this is a manually curated (with the help of Claude) and cleaned up version of an /autoresearch run

…rsing

Key optimizations:
- Rewrite block string parser: direct string processing instead of sub-lexer + Vec<Vec<Token>> (~10%)
- Compact Span: u32 start+len (8 bytes) instead of Range<usize> (16 bytes), add Copy (~3%)
- Field: consume-then-check for alias instead of peek(1) (~2%)
- Optimize next_if_* methods: peek+consume in single buffer operation (~1%)
- Lazy depth_limiter.bump(): only bump when optional elements exist
- Add Copy to DepthLimiter + preallocate Vec capacity in DefinitionDocument

Also adds benchmarks for ExecutableDocument parsing with a large fixture,
and updates downstream crates to use Copy semantics on Span (clone → deref).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@swalkinshaw swalkinshaw requested a review from adampetro March 17, 2026 16:47
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