Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

neumann_parser Benchmarks

The parser is a hand-written recursive descent parser with Pratt expression parsing for operator precedence.

Tokenization

Query TypeTimeThroughput
simple_select182 ns99 MiB/s
select_where640 ns88 MiB/s
complex_select986 ns95 MiB/s
insert493 ns120 MiB/s
update545 ns91 MiB/s
node625 ns98 MiB/s
edge585 ns94 MiB/s
path486 ns75 MiB/s
embed407 ns138 MiB/s
similar185 ns118 MiB/s

Parsing (tokenize + parse)

Query TypeTimeThroughput
simple_select235 ns77 MiB/s
select_where1.19 us47 MiB/s
complex_select1.89 us50 MiB/s
insert688 ns86 MiB/s
update806 ns61 MiB/s
delete464 ns62 MiB/s
create_table856 ns80 MiB/s
node837 ns81 MiB/s
edge750 ns74 MiB/s
neighbors520 ns55 MiB/s
path380 ns58 MiB/s
embed_store650 ns86 MiB/s
similar290 ns76 MiB/s

Expression Complexity

Expression TypeTime
simple (a = 1)350 ns
binary_and580 ns
binary_or570 ns
nested_and_or950 ns
deep_nesting1.5 us
arithmetic720 ns
comparison_chain1.3 us

Batch Parsing Throughput

Batch SizeTimeQueries/s
105.2 us1.9M/s
10052 us1.9M/s
1,000520 us1.9M/s

Large Query Parsing

Query TypeTime
INSERT 100 rows45 us
EMBED 768-dim vector38 us
WHERE 20 conditions8.5 us

Analysis

  • Zero dependencies: Hand-written lexer and parser with no external crates
  • Consistent throughput: ~75-120 MiB/s across query types
  • Expression complexity: Linear scaling with expression depth
  • Batch performance: Consistent 1.9M queries/second regardless of batch size
  • Large vectors: 768-dim embedding parsing in ~38us (20K dimensions/second)

Complexity

OperationTime ComplexityNotes
TokenizationO(n)Linear scan of input
ParsingO(n)Single pass, no backtracking
Expression parsingO(n * d)n = tokens, d = nesting depth
Error recoveryO(1)Immediate error on invalid syntax

Parser Design

  • Lexer: Character-by-character tokenization with lookahead
  • Parser: Recursive descent with Pratt parsing for expressions
  • AST: Zero-copy where possible, spans track source locations
  • Errors: Rich error messages with span highlighting