The Parrot parser is based on Antlr 4 and has been the Groovy parser since Groovy 3.0.0. The following system properties tune parsing performance.

Option Description Default Version Example

groovy.parallel.parse

Parse Groovy source files in parallel.

true since Groovy 4.0.0 (false before that)

3.0.5+

-Dgroovy.parallel.parse=false

groovy.antlr4.cache.threshold

How many source files are parsed before the parser DFA cache is replaced. The value is a count of files, not of tokens. 0 (the default) turns this counter off. A positive value replaces the cache after that many files. A negative value never replaces the cache and also disables groovy.antlr4.cache.size. Groovy 4 defaulted to 64, which cleared the cache on that cadence. Groovy 5.0 used 0 to clear the cache when memory was tight; that cleaner no longer runs, so 0 does not mean automatic clearing.

0

3.0.5+

-Dgroovy.antlr4.cache.threshold=200

groovy.antlr4.cache.size

Maximum number of DFA states retained in the parser cache. Crossing the ceiling replaces the cache. The default scales with the maximum heap: about 32 states per megabyte, and never less than 20,000 or more than 500,000. 0 or a negative value disables the ceiling. A negative groovy.antlr4.cache.threshold disables it as well.

heap-scaled

6.0.0+

-Dgroovy.antlr4.cache.size=100000

groovy.antlr4.sll.threshold

The parser tries SLL prediction and falls back to LL if SLL fails. SLL is faster and less powerful, and it fails more often as the token count grows. When the token count is greater than this threshold, SLL is skipped and LL is used directly. 0 skips SLL for any non-empty source. A negative value (the default) always tries SLL first.

-1

3.0.9+

-Dgroovy.antlr4.sll.threshold=1000

groovy.antlr4.clear.lexer.dfa.cache

When true, the lexer DFA cache uses the same replacement policy as the parser cache. The lexer cache stays small and warm, so leave this false unless a lexer cache is actually exhausting the heap.

false

3.0.9+

-Dgroovy.antlr4.clear.lexer.dfa.cache=true