Skip to content

perf: reuse one end-of-input IOException per SimpleCharStream - #2962

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
g4lb:perf-eof-ioexception
Nov 28, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
g4lb:perf-eof-ioexception

Conversation

@g4lb

@g4lb g4lb commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

At the end of the input, SimpleCharStream.FillBuff() makes a new IOException. The token manager discards it. Each new exception fills in a long stack trace, and a parse makes many of them. Now each stream makes the exception one time and throws it again. The class and the message do not change.

JMH, JDK 21, Apple M-series, 20 rounds, median time per parse:

Input master this branch Change
SELECT a FROM t 41.2 µs 26.4 µs −35.8%
SELECT a FROM t, CCJSqlParserUtil.parse(String) 64.7 µs 49.9 µs −22.8%
8 nested CASE WHEN 72.4 µs 59.9 µs −17.2%

No other input that I measured became slower. mvn verify gives the same result as on master. The output is the same as on master for 1.1M random SQL inputs.

@g4lb
g4lb force-pushed the perf-eof-ioexception branch from 3f837da to 21f9f2f Compare November 26, 2026 01:57
@manticore-projects
manticore-projects merged commit 1e682d1 into JSQLParser:master Nov 28, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you very much, I love such performance improvements!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants