Skip to content

Reduce size of Expr#2271

Open
xitep wants to merge 5 commits intoapache:mainfrom
xitep:function-box
Open

Reduce size of Expr#2271
xitep wants to merge 5 commits intoapache:mainfrom
xitep:function-box

Conversation

@xitep
Copy link
Contributor

@xitep xitep commented Mar 6, 2026

  • This whole change is reducing the size of Expr to 112 bytes.
  • This appears to be improving the performance of the parser; compared to the main branch #b3e176d, i get this from the benchmarks on my machine (roughly a 7% improvement):
benchmark main this-branch
benchmark/sqlparser::select 3.4347 µs 2.8873 µs
benchmark/sqlparser::with_select 17.490 µs 16.946 µs
benchmark/parse_large_statement 5.5956 ms 5.1574 ms
benchmark/format_large_statement 293.73 µs 282.47 µs
word_to_ident/clone_into_ident_100x 2.0907 µs 1.9933 µs
word_to_ident/to_ident_100x 1.6960 µs 1.6310 µs
parse_identifiers/select_100_columns 85.290 µs 78.486 µs
parse_identifiers/select_100_qualified_columns 181.46 µs 165.29 µs
Details
> cargo bench -- --baseline main
...
sqlparser-rs parsing benchmark/sqlparser::select
                        time:   [2.8171 µs 2.8873 µs 2.9611 µs]
                        change: [−20.224% −17.456% −14.693%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking sqlparser-rs parsing benchmark/sqlparser::with_select: Collecting 100 samples in estimated 5.0368 s (308k
sqlparser-rs parsing benchmark/sqlparser::with_select
                        time:   [16.627 µs 16.946 µs 17.299 µs]
                        change: [−8.0130% −5.0889% −2.1257%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking sqlparser-rs parsing benchmark/parse_large_statement: Collecting 100 samples in estimated 5.3783 s (1000 i
sqlparser-rs parsing benchmark/parse_large_statement
                        time:   [5.0584 ms 5.1574 ms 5.2594 ms]
                        change: [−10.235% −7.8314% −5.3302%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking sqlparser-rs parsing benchmark/format_large_statement: Collecting 100 samples in estimated 6.0742 s (20k i
sqlparser-rs parsing benchmark/format_large_statement
                        time:   [276.05 µs 282.47 µs 289.60 µs]
                        change: [−10.490% −8.1724% −5.7397%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 15 outliers among 100 measurements (15.00%)
  14 (14.00%) high mild
  1 (1.00%) high severe

word_to_ident/clone_into_ident_100x
                        time:   [1.9460 µs 1.9933 µs 2.0395 µs]
                        change: [−9.7186% −7.1667% −4.4646%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe
word_to_ident/to_ident_100x
                        time:   [1.5993 µs 1.6310 µs 1.6673 µs]
                        change: [−9.8227% −7.0780% −4.4473%] (p = 0.00 < 0.05)
                        Performance has improved.

parse_identifiers/select_100_columns
                        time:   [76.620 µs 78.486 µs 80.527 µs]
                        change: [−16.581% −13.951% −11.342%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking parse_identifiers/select_100_qualified_columns: Collecting 100 samples in estimated 5.1332 s (30k iteratio
parse_identifiers/select_100_qualified_columns
                        time:   [161.17 µs 165.29 µs 169.87 µs]
                        change: [−14.949% −12.703% −10.289%] (p = 0.00 < 0.05)
                        Performance has improved.
  • I can see a similar improve in a client program

@xitep xitep changed the title Expr:Function as a Box Expr::Function as a Box Mar 6, 2026
@LucaCappelletti94
Copy link
Contributor

If there isn't rush, I can come back with benchmarks in parsing with and without this change against my fuzzing corpus. I am a bit overworked right now, so I don't think I can deliver it earlier than the end of next week.

@xitep
Copy link
Contributor Author

xitep commented Mar 6, 2026

absolutely no rush, @LucaCappelletti94. (this was just an experiment which surprised me and i thought it's worth sharing.) if you'd manage to run it on some workload of yours it would be a great way to expose or exclude some error on my part.

@xitep xitep changed the title Expr::Function as a Box Reduce size_of Expr Mar 15, 2026
@xitep xitep changed the title Reduce size_of Expr Reduce size of Expr Mar 15, 2026
@xitep xitep marked this pull request as ready for review March 15, 2026 10:31
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.

2 participants