Repository navigation
Conversation
Signed-off-by: 付典 <fudianchn@gmail.com>
The token actions query the wired FeatureConfiguration for every identifier, string literal and quoted identifier; PrimaryExpression pays new predicate checks after every expression. Cache the derived dialect/flag answers on the wired configuration's identity (it is only mutated before parsing starts), lazily allocate the DuckDB chained-sign list, reject non-operator images before the PostgreSQL json-access equals chain, and hoist the unsupported statements flag out of the capture loop. Signed-off-by: 付典 <fudianchn@gmail.com>
Signed-off-by: 付典 <fudianchn@gmail.com>
Track configuration mutations as well as object identity, preserve the public token manager configuration, and avoid caching dynamic subclass values. Cover parser reuse, in-place changes, replacement, and direct lexer APIs with 33 regression checks. Signed-off-by: 付典 <fudianchn@gmail.com>
Contributor
Author
|
@manticore-projects, the remote benchmarks on the 54-statement corpus didn't show a measurable speedup from this PR. I don't think the added cache-invalidation complexity and maintenance cost are justified by these results, so I'm closing it. If there's a specific workload where this approach could help, we can revisit it with evidence. |
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
What
Remove repeated feature-configuration lookups from per-token and per-expression paths, use typed getter fast paths, and reduce allocation and predicate work in primary expressions.
Why
Lexical actions repeatedly read the same options. Cache these derived flags while the configuration remains unchanged, and avoid converting already typed getter values through strings. Configuration changes and parser reuse must preserve the existing parsing behavior.
How
getAsBoolean/getAsLong/getAsInt/getAsIntegerreturn storedBoolean/Long/Integervalues directly and keep string parsing for other stored types, includingnull.FeatureConfiguration.setValueupdates a modification stamp exposed bygetModificationCount(). Both derived-flag caches check configuration identity and this stamp, so in-place changes andReInitreuse refresh the flags. Configuration subclasses are refreshed on each use to preserve overridden values.configuration; hash comments retain their existing stream-wiring requirement.innerSignsis allocated only for chained signs. PostgreSQL JSON access rejects non-operator images before the equals chain, and opaque statement capture checks its enabled flag before the loop.Root cause
The original draft's identity-only caches missed in-place changes between parses. Reading only
input_stream.featureConfigurationalso ignored options set directly on the public token manager. Both regressions are covered by the added tests.Testing
mvn clean verifypassed on basebdf8ac31(10,334 tests) and fixed head0f911fa7(10,367); Gradlecheckpassed with 10,352 and 10,385 tests respectively. Each run has zero failures/errors and the same 25 project-disabled tests. The Mockito suites previously blocked by local agent attachment execute successfully there.643b2adf. Four targeted cache/guard mutants fail as expected.performance.sqlare byte-identical to master: 54 statements, 486,434 bytes.ssh devon the same Linux server and JDK 17.0.20. The harness is the unmodified projectJSQLParserBenchmark.parseSQLStatementsandDynamicParserRunnerfrombdf8ac31; every parser JAR uses the same isolatedURLClassLoader(parent=null), including the snapshots. Configuration is SIMPLE (withAllowComplexParsing(false)). No production code or corpus was changed for this experiment.performance.sqlcorpus has SHA-256e8546f42fa84bbd9e142490cdfcbcd4cc37110cccebda3b059ff77c1c06df8f8. Each state parses all 54 non-null statements and produces the same restored SQL. The three snapshot states have identical semantic field values. The 5.4 model is older: shared semantic fields agree, while snapshot fields additionally record STANDARD escaping and FILTER WHERE presence. Release-to-snapshot timings therefore include model/schema evolution and do not isolate equal AST work.-Xms1g -Xmx1g -Xss4m -Dfile.encoding=UTF-8: 30 samples per window, 60 per version.e847e94bbdf8ac3168c035bc0f911fa7For this PR, latency is +1.08% / +1.42% versus master, with overlapping score confidence intervals. These measurements do not demonstrate a speedup; passing the correctness regression tests does not establish an optimization benefit. No recovery of the observed release-to-snapshot performance gap is demonstrated by this PR on this corpus.
Versus 5.4, this PR has +4.88% / +4.33% latency; master has +3.76% / +2.87%. Their score intervals do not overlap with 5.4 in either window, subject to the model-evolution qualification above. Percentages compare point estimates; no confidence interval for these ratios is claimed.
Verification of the original issue
Not applicable (no issue).