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

Performance improvement #316

Open
yhirose opened this issue Nov 26, 2024 · 1 comment
Open

Performance improvement #316

yhirose opened this issue Nov 26, 2024 · 1 comment

Comments

@yhirose
Copy link
Owner

yhirose commented Nov 26, 2024

This article reports cpp-peglib is 10 times slower than the YACC based parser used in Postgress.

Postgres takes on average 24 ms to parse this file using YACC. Note that this time includes the execution of grammar actions that create Postgres' parse tree. cpp-peglib takes on average 266 ms to parse the test file. However, our experimental parser does not have grammar actions defined yet. When simulating actions by generating default AST actions for every rule, parsing time increases to 339 ms. Note that the AST generation is more expensive than required, because a node is created for each matching rule, even if there is no semantic meaning in the grammar at hand.

This article also mentions about places where we could to improve the performance of cpp-peglib.

Furthermore, there are still ample optimization opportunities in the experimental parsers we created using an off-the-shelf PEG library. For example, the library makes heavy use of recursive function calls, which can be optimized e.g., by using a loop abstraction.

@yhirose
Copy link
Owner Author

yhirose commented Dec 20, 2024

One of the options is to use VM instead of Tree-Walk interpreter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant