antlr / antlr/antlr4

How to improve the deserialization time of ATNSimulator?

Open
#3,554 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

ANTLR4 is a great tool.

But I have faced a performance problem.
As @ericvergnaud said,[“We should focus on deserialization time, and memory size after deserialization.”](https://github.com/antlr/antlr4/pull/3505#issuecomment-1025116471)

I have used ANTLR 4.9.3 to generate my CssParser.java and Csslexer.java from [css3.g4](https://github.com/antlr/grammars-v4/blob/master/css3/css3.g4)

Both the two class spend about 70ms - 100ms to deserialize the _serializedATN which is a long String.

Is there any way to decrease the deserialization time of ATN?

Thank you very much for your support!

Contributor guide

Open the contributing guide

Research direction

Start with the generated CssParser.java and CssLexer.java from css3.g4, focusing on their _serializedATN deserialization path. Measure the reported 70–100 ms cost with ANTLR 4.9.3 and compare both generated classes. Done would require a defined, validated approach that reduces deserialization time without breaking parser behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.