Repository navigation
Conversation
…expression lists The main branch of Condition/SQLCondition is the last alternative of its choice: entering it and letting the productions reject is equivalent to the deep jj_2 phase simulation that ran for every plain condition first, so gate it with a cheap !interrupted check instead. The named-parameter alternatives of ComplexExpressionList only ever match a single-token name directly followed by their assignment token, so a first check on the second token is equivalent to their 2-token lookahead scan. parseSQLStatements: 21.3-21.4 vs 24.6-24.8 ms/op against master in 3 interleaved JMH pairs (-13% to -14%, error intervals not overlapping); behavior verified identical by 26 EXISTS/named-parameter probes, the full 10,344-test suite (same 35 pre-existing environment failures as master) and a byte-identical AST dump of performance.sql. Signed-off-by: 付典 <fudianchn@gmail.com>
Contributor
|
This is a good one and to be honest: most of the Does anyone have a good idea how to clean those up? |
Use exact token predicates for PRIOR, OVERLAPS, time keywords, ALL and boolean literals while retaining interruption checks. Add 52 boundary cases for expression dispatch, named arguments, malformed input and cancellation. Signed-off-by: 付典 <fudianchn@gmail.com>
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
What
Skip redundant lookahead simulations on hot expression parse paths: the deep jj_2 phase simulation guarding the main branch of
Condition()/SQLCondition(), and theOracle/PostgresNamedFunctionParameterprobes inComplexExpressionList().Also replace five complete single-token probes with exact token predicates:
PRIOR,SQLCondition'sOVERLAPS, time-key expressions,ALL, and boolean values.Why
The main branch of
Condition()/SQLCondition()is the last alternative of its choice, so its lookahead can only accept or reject what the productions themselves accept or reject immediately after: entering it directly and letting them fail is equivalent, without re-walking the whole expression tree first. Under JFR profiling ofparseSQLStatementsthis simulation collected about 17% of the execution samples, paid by every plain condition on top of the real parse.The named-parameter probes can never match a dotted name (
f(a.b => 1)fails to parse on master with or without this change), so a check of the second token decides them exactly like the 2-token scan did.How
Condition()/SQLCondition(): gate the main alternative withLOOKAHEAD({ !interrupted })instead of the implicit deep simulation; the EXISTS alternatives ahead of it are unchanged.ComplexExpressionList(): gate the four named-parameter alternatives withisNamedParameterAssignmentAhead(), a two-kind check ongetToken(2). Keep the syntactic probes that validate the name.(+), named-parameter names andANYcomparisons in place.Root cause
Not applicable (performance).
Testing
check jmhJar --no-daemon --max-workers=4, with a per-run repository mirror init script, passed on both the PR commit and masterbdf8ac31.WithItemTest.testInterruptedWithItemLookaheadStopsReadingandCCJSqlParserUtilTest.testParserInterruptedByTimeoutboth passed remotely;ParserExecutionTestpassed all 7 cases. The focused run completed 129 cases with 2 existing disabled cases and zero failures/errors.LookaheadDispatchTest: 52 cases passed, checking AST kinds and operands, EOF consumption, round trips, quoted/non-reserved names, first/later named arguments, invalid names and malformed conditions. The two already-interrupted numeric-fragment cases document the!interruptedgate: master accepts the fragment, the PR rejects it before consumption, and removing the gate makes both tests fail.Remote JMH
JSQLParserBenchmark.parseSQLStatements(version=latest, unmodifiedperformance.sql): 3 forks per window, 3 × 3 s warmup and 10 × 1 s measurement per fork, 30 samples per window; master → branch → master → branch. Errors are JMH 99.9% confidence intervals.The measurements cover the complete PR relative to master.
Malformed conditions can fail inside the productions instead of at choice dispatch; their failure class remains unchanged in the tested cases.
Verification of the original issue
Not applicable (no issue).