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

What is trim_parse_tree? #59

Closed
dalance opened this issue Feb 28, 2023 · 2 comments
Closed

What is trim_parse_tree? #59

dalance opened this issue Feb 28, 2023 · 2 comments

Comments

@dalance
Copy link

dalance commented Feb 28, 2023

I tried to use trim_parse_tree at parol 0.18.1, and got about 20-30% performance gain.

throughput/parse        time:   [26.970 ms 26.976 ms 26.984 ms]
                        thrpt:  [562.98 KiB/s 563.15 KiB/s 563.27 KiB/s]
                 change:
                        time:   [-22.763% -21.446% -20.414%] (p = 0.00 < 0.05)
                        thrpt:  [+25.651% +27.300% +29.472%]
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  6 (6.00%) high mild
  2 (2.00%) high severe

I want to know the actual effect of trim_parse_tree.
The doc says that it is useful when the whole parse tree is not needed.

Doing so the parse tree doesn’t grow much and runtime overhead is diminished. Useful when enabling production mode and the whole parse tree is not needed.

In my understanding, my usage requires the whole parse tree.
So I thought that trim_parse_tree can't be used, but trim_parse_tree didn't break any my testcases actually.
What information is trimmed?

@jsinger67
Copy link
Owner

jsinger67 commented Feb 28, 2023

Hi @dalance,
the parser tree is the structure returned by the parse method (in the Result).
It resembles the concrete structure of the parsed input on which your grammar was applied.
You can regard it as a possibility to evaluate your language description and/or as an alternative way to process the parse result (e.g. by tree visitors).
Especially during the phase of development of your grammar and during rapid prototyping this can be very useful. There are built in ways to visualize this parse tree to support the user in these phases.
Normally though, as in your case, and when using parol's auto-generation mode, this is often not used at all and discarded.
And here one can use the possibility to not building up the complete parse tree.

@dalance
Copy link
Author

dalance commented Feb 28, 2023

Thank you for your description.
I understood that trim_parse_tree can be used in my usage.

@dalance dalance closed this as completed Feb 28, 2023
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

No branches or pull requests

2 participants