Repository navigation
sql-parser: Shrink AST nodes - #41117
Merged
Merged
Conversation
Box the window spec in `Function::over` and the SHOW statement in `SetExpr::Show`. Both are large and rarely present, but they set the size of every `Expr` and `Statement`. On x86-64, `Expr` shrinks from 240 to 136 bytes and `Statement` from 1,736 to 920 bytes, so every AST allocation that holds one gets smaller. `parse_statements` reserves a single slot for the first statement, since most inputs contain one and each spare slot is a full statement. Unwrapping `(SHOW ...)` into a top-level `Statement::Show` moves the node instead of cloning it. The parser allocates about 28% fewer bytes, and parsing and dropping ASTs gets faster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
def-
force-pushed
the
perf/layout-parser
branch
from
November 28, 2026 12:46
77b7dd4 to
7de28ea
Compare
def-
marked this pull request as ready for review
November 28, 2026 12:54
ggevay
approved these changes
Nov 28, 2026
ggevay
left a comment
Contributor
There was a problem hiding this comment.
LGTM. One minor thing: could the description also cover the changes besides the boxing? parse_statements now reserves one slot and has its end-of-statement check rewritten, and the (SHOW ...) unwrap moves the SHOW node instead of cloning it. The commit message mentions the reserve and the move, but the squash commit takes its message from the PR description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Box the window spec in
Function::overand theSHOWstatement inSetExpr::Show. Both are large and rarely present, but increased the size ofExprandStatement. On x86-64Expr: 240 -> 136 bytes,Statement: 1,736 -> 920 bytes.parse_statementsreserves exactly one slot before pushing the first statement. Most inputs contain a single statement, and each spare slot costs the size of a full statement. After parsing each statement, it immediately checks for a semicolon or the end of input, eliminating the delimiter flag.When unwrapping
(SHOW ...), the parser moves theSHOWnode into the top-levelStatement::Show, avoiding a clone.This makes the parser allocate ~28% less memory, also happens to be slightly faster.