Skip to content

Conversation

@TristonianJones
Copy link
Collaborator

It is possible and safe to re-use ANTLR Parser instances; however, they are not thread safe. Introduce a sync.Pool for the CEL ANTLR Parser in order to reduce the construction overhead. This change improves the overall parse / check performance per #346.

Note, ANTLR generated lexers cannot be used within a sync.Pool until antlr/antlr4#2816 is merged.

@TristonianJones TristonianJones requested a review from JimLarson May 1, 2020 15:49
Note, the change brings in github.com/antlr/antlr4/pulls/2816 which updates the
ANTLR Go runtime. Other applications using vendored code, or alternate sources
of truth besides the main ANTLR GitHub repository will also need to be udpated
for this change to work.
@TristonianJones TristonianJones changed the title Introduce a sync.Pool for ANTLR Parser instances Introduce a sync.Pool for ANTLR Lexer / Parser instances May 4, 2020
@TristonianJones TristonianJones merged commit f3a4721 into google:master May 6, 2020
TristonianJones added a commit to rachelmyers/cel-go that referenced this pull request Jun 15, 2020
* Introduce a sync.Pool for ANTLR Parser instances
* Introduce sync.Pool instances for the Lexer as well.

Note, the change brings in github.com/antlr/antlr4/pulls/2816 which updates the
ANTLR Go runtime. Other applications using vendored code, or alternate sources
of truth besides the main ANTLR GitHub repository will also need to be udpated
for this change to work.
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