Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional parentheses cause significant increase of parsing time #305

Closed
treiher opened this issue Jun 26, 2020 · 3 comments · Fixed by #306
Closed

Additional parentheses cause significant increase of parsing time #305

treiher opened this issue Jun 26, 2020 · 3 comments · Fixed by #306
Assignees
Labels
bug specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented Jun 26, 2020

Parentheses have an unexpectedly high impact on the parsing time. Just by adding two pairs of parenthesis (without changing the semantics of the expression) the parsing time increased from 1 s to 53 s on my local machine.

from rflx.parser.grammar import mathematical_expression

mathematical_expression().parseString(" (Y / 9 - (3 / S -  (2 + G) )) ")  #  1 s
mathematical_expression().parseString(" (Y / 9 - (3 / S - ((2 + G)))) ")  #  7 s
mathematical_expression().parseString("((Y / 9 - (3 / S - ((2 + G)))))")  # 53 s
@treiher treiher added bug specification Related to specification package (e.g., specification parsing) labels Jun 26, 2020
@treiher treiher added this to To do in RecordFlux 0.4.1 via automation Jun 26, 2020
@treiher
Copy link
Collaborator Author

treiher commented Jun 26, 2020

Enabling packrat parsing improves the performance significantly, so that the whole example shown above runs in less than 1 s.

@treiher treiher self-assigned this Jun 26, 2020
@treiher treiher moved this from To do to In progress in RecordFlux 0.4.1 Jun 26, 2020
treiher added a commit that referenced this issue Jun 26, 2020
@senier
Copy link
Member

senier commented Jun 26, 2020

@treiher We had packrat off? Then I'm impressed that we had no more severe performance issues.

@treiher
Copy link
Collaborator Author

treiher commented Jun 26, 2020

@treiher We had packrat off? Then I'm impressed that we had no more severe performance issues.

It's the default.

enablePackrat() - a class-level static method to enable a memoizing performance enhancement, known as “packrat parsing”. packrat parsing is disabled by default, since it may conflict with some user programs that use parse actions.

RecordFlux 0.4.1 automation moved this from In progress to Done Jun 29, 2020
treiher added a commit that referenced this issue Jun 29, 2020
@treiher treiher mentioned this issue Jul 1, 2020
26 tasks
@treiher treiher mentioned this issue Jul 14, 2020
4 tasks
treiher added a commit that referenced this issue Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug specification Related to specification package (e.g., specification parsing)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants