Repository navigation
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a18b8a-340f-717d-9ca7-6dcf564a065a Co-authored-by: Kevin Longe <kvlonge@gmail.com>
Expression::Star held Star inline, which made every Expression 232 bytes. Boxing it shrinks Expression to 96 bytes and removes most memcpy traffic when parsing. BREAKING CHANGE: Expression::Star now holds Box<Star>. Construct it with Expression::Star(Box::new(star)) or Expression::star(). Serialized JSON is unchanged. Co-authored-by: Kevin Longe <kvlonge@gmail.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a18b8a-340f-717d-9ca7-6dcf564a065a
This branch has not been deployed
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.
Why
Parsing dominates SQL lint cost in downstream users: tokenize plus parse is about two thirds of lint instructions. Profiling showed per-token hashing for single character tokens, a full token copy when parsing from kept tokens, and heavy memcpy because every
Expressionwas 232 bytes due to the unboxedStarvariant.Changes
Parser::with_config_from_tokens(sql, &[Token], config)builds parser tokens that share kept token text instead of cloning the token vector.Expression::Starnow holdsBox<Star>, shrinkingExpressionfrom 232 to 96 bytes. Construct it withExpression::Star(Box::new(star))orExpression::star(). Pattern matches onExpression::Star(_)are unaffected. Serde output is unchanged becauseBox<T>serializes likeT, so JSON, Python, WASM and FFI ASTs keep the same shape.Verification
cargo fmt --checkandcargo check -p polyglot-sql --testspass. The full polyglot suite could not compile locally (8 GB memory), so this draft relies on CI for core, release-fixtures, bindings and feature-gates.