Files
morrySnow 5e83a92277 [improvement](parser) Optimize string literal lexing (#66902)
### What problem does this PR solve?



`DorisLexer.STRING_LITERAL` evaluated SQL-mode semantic predicates for
every character, so predicate calls and allocation scaled with the
literal payload. This PR selects the SQL-mode-specific loop once after
the opening quote while preserving the accepted language and token
stream.

It also adds:
- an isolated, opt-in JMH module that does not affect the default parser
jar or its runtime dependencies;
- lexer-only, parser end-to-end, allocation, and no-string control
benchmarks;
- deterministic token/error differential tooling;
- string literal boundary, long-input, predicate-complexity, and
8-thread concurrency tests;
- a gated TODO for subsequent parser optimization work.

Representative plain single-quoted measurements:
- 4 KiB lexer: about 1.40–1.74 ms/op to 0.029–0.059 ms/op;
- 64 KiB lexer: about 21.6–24.4 ms/op to 0.55–0.70 ms/op;
- 4–64 KiB allocation reduction: about 99.6%–99.7%.

The benchmark host did not meet the strict 3% A/A stability gate for
microsecond control cases. The PR therefore reports raw ranges and
explicitly leaves fine-grained G2/G5 validation open instead of claiming
small control-path changes.

### Release note

None

### Check List (For Author)

- Test
    - [ ] Regression test
    - [x] Unit Test
    - [x] Manual test
- `./run-fe-ut.sh --run
org.apache.doris.sqlparser.DorisLexerStringLiteralTest,org.apache.doris.sqlparser.DorisSqlParserTest`
        - `DISABLE_BUILD_UI=ON ./build.sh --fe`
- 46,908-case baseline/candidate token and error snapshot differential:
zero differences
- JMH lexer-only, parser end-to-end, allocation, and no-string control
benchmarks
    - [ ] No need to test or manual test.

- Behavior changed:
    - [x] No.
    - [ ] Yes.

- Does this need documentation?
    - [x] No.
    - [ ] Yes.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
2026-08-20 19:18:05 +08:00

95 lines
3.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.doris</groupId>
<version>${revision}</version>
<artifactId>fe</artifactId>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>fe-sql-parser-benchmark</artifactId>
<packaging>jar</packaging>
<name>Doris FE SQL Parser Benchmarks</name>
<properties>
<jmh.version>1.37</jmh.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>fe-sql-parser</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>doris-fe-sql-parser-benchmarks</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>build-benchmark-jar</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>module-info.class</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>