Skip to content

Conversation

@meskill
Copy link

@meskill meskill commented Feb 9, 2026

That's an experimental attempt to replace current recursive algorithm with the iterative approach.

Currently only the parsing part is implemented and the functionality is exported as parse_raw_iter function. I've copied tests from raw_parse and fixed them with some help of LLMs.

I've added the parse_raw_iter to the test with benchmark inside tests/raw_parse_test.rs and the results are following:

with --release flag on my machine:

============================================================
            parse_raw vs parse Benchmark                    
============================================================
Query: 2725 chars (CTEs + JOINs + subqueries + window functions)

┌─────────────────────────────────────────────────────────┐
│                    RESULTS                              │
├─────────────────────────────────────────────────────────┤
│  parse_raw (direct C struct reading):                   │
│    Iterations:         86900                            │
│    Total time:         5.00s                            │
│    Per iteration:      57.54 μs                         │
│    Throughput:         17379 queries/sec                │
├─────────────────────────────────────────────────────────┤
│  parse_raw_iter (direct C struct reading):              │
│    Iterations:         79000                            │
│    Total time:         5.00s                            │
│    Per iteration:      63.32 μs                         │
│    Throughput:         15792 queries/sec                │
├─────────────────────────────────────────────────────────┤
│  parse (protobuf serialization):                        │
│    Iterations:         19000                            │
│    Total time:         5.01s                            │
│    Per iteration:     263.48 μs                         │
│    Throughput:          3795 queries/sec                │
├─────────────────────────────────────────────────────────┤
│  COMPARISON                                             │
│    Speedup:             4.58x faster                    │
│    Speedup iter:        0.91x faster                    │
│    Time saved:        205.94 μs per parse               │
│    Extra queries:      13584 more queries/sec           │
└─────────────────────────────────────────────────────────┘

So, it's slightly slower than current recursive approach. I've tried different ideas to optimize my code but have managed to make it fully on-par yet.

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