[improvement](parser) Localize identifier post-processing - #67457
Merged
morrySnow merged 2 commits intoSep 3, 2026
Conversation
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Add fixed control, ordinary identifier, non-reserved keyword, quoted identifier, and wide projection workloads for measuring global parser listener removal through both the standalone facade and a pre-tokenized parser.
### Release note
None
### Check List (For Author)
- Test: Manual test
- Benchmark module package with Checkstyle
- JMH smoke run for all workloads and both benchmark methods
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: The global ANTLR parse listener receives every rule-exit event even though it only normalizes non-reserved and quoted identifiers and reports malformed identifiers. Move those actions into their grammar rules and remove listener dispatch from both parser facades. Preserve token text, type, positions, malformed-identifier errors, and parsing without a CST. JMH parser-only workloads improve by 2.8%-14.3% (typical 9.4%, wide 7.7%) while allocation falls by 0.07%-2.09%; end-to-end typical and wide workloads improve by 3.2% and 14.0%.
### Release note
None
### Check List (For Author)
- Test: Unit Test and manual differential/performance tests
- `mvn -Pbenchmark -pl fe-sql-parser,fe-sql-parser-benchmark -am -Dmaven.build.cache.enabled=false package`
- `./run-fe-ut.sh --run org.apache.doris.nereids.parser.NereidsParserTest`
- `./build.sh --fe`
- 4,610 tracked SQL files in default and ANSI modes match the baseline
- Identifier CST, token, and error snapshots match the baseline
- JMH 1.37, 3 forks, 4 warmup and 7 measurement iterations
- Behavior changed: No
- Does this need documentation: No
morrySnow
requested review from
924060929,
englefly and
starocean999
as code owners
September 2, 2026 17:48
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 16802 ms |
Contributor
TPC-DS: Total hot run time: 82312 ms |
Contributor
ClickBench: Total hot run time: 14.66 s |
924060929
approved these changes
Sep 3, 2026
11 tasks
morrySnow
added a commit
that referenced
this pull request
Sep 3, 2026
### What problem does this PR solve? Related PR: #67455, #67457 Problem Summary: `LimitClausePrefixTest` registered `PostProcessor` directly. After #67457 moved identifier post-processing into grammar actions and deleted `PostProcessor`, combining it with the LIMIT-prefix test from #67455 caused `fe-sql-parser` test compilation to fail. Remove the obsolete import and listener registration. Identifier post-processing is now performed by the grammar, and the LIMIT test does not require a global parse listener.
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.
What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
PostProcessorwas installed as a global ANTLR parse listener, so every rule exit paid listener-dispatch cost even though only three local actions were needed: normalizing non-reserved identifiers, normalizing quoted identifiers, and reporting malformed unquoted identifiers.This PR moves those actions into the corresponding grammar rules and removes the listener from both
DorisSqlParserandNereidsParser. It preserves identifier token text/type/positions, double-backtick unescaping, malformed-identifier errors, and parsing withbuildParseTree=false.Benchmark
Environment:
760b14ee62c(benchmark-only commit onf054492cbb9)5b45223bc61-Xms1g -Xmx1g, 4 x 300 ms warmup, 7 x 400 ms measurement,-prof gctypicalparser-only was 88.8 us/op instead of the stable 7-9 us/op range); the final artifact was rebuilt and measured in a clean run.Build and run:
LC_ALL=en_US.UTF-8 mvn -Pbenchmark -pl fe-sql-parser,fe-sql-parser-benchmark -am \ -Dmaven.build.cache.enabled=false package java -jar fe/fe-sql-parser-benchmark/target/fe-sql-parser-benchmark-*-benchmark.jar \ 'IdentifierPostProcessorBenchmark.*' -prof gc -rf json -rff result.jsonTime is
us/op; positive change means faster. The workloads cover a control query, a typical aggregate query, a 64-column query, a non-reserved-keyword-heavy query, and a quoted-identifier-heavy query.The direct parser path improves by 2.8%-14.3% and allocates less in every workload. End-to-end means also improve in every workload; the larger quoted/control figures have more host-level variance and are not used as the primary conclusion. The gain comes from removing global rule-exit listener dispatch; the remaining allocation reduction comes from avoiding listener bookkeeping.
Artifact/result hashes:
b9941cb95ea3cc8797d0ad896259049613e822c0f72319403a062bfc9bcb51a42d33163832f90e0d1c1929e522e012becbab56e3bc463dcc19b42f0e9d27526a3629629849730548e3e8ff5ab54bb9d02b14e3dde3aff3b8aa51c31cc74c8c5eca94f64515f2b904244f78139c7c43f636bff1f72f5daa00a748f7b9800167e698227ae4ce630bf306084573a2a315a5f3d3d0081c787a08c6eca9cea6c73000/private/tmp/doris-p7-benchmark.YSnF7t/.Semantic verification
.sqlfiles in default and ANSI modes. Acceptance/error class/error position/statement count matched the frozen baseline in all 9,220 cases.c1fdf48a22d311f7164516b512e850bef373126be1d3079148c109e5f80f80c1.test-table/test-tblerrors. Every rule node and token field matched the baseline.buildParseTree=false.Release note
None
Check List (For Author)
Test
mvn -Pbenchmark -pl fe-sql-parser,fe-sql-parser-benchmark -am -Dmaven.build.cache.enabled=false package(193 parser tests passed)./run-fe-ut.sh --run org.apache.doris.nereids.parser.NereidsParserTest./build.sh --feBehavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)