-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Add more optimizations #473
Conversation
…eded to match a separated list
… to find the most expensive expression between 'rule' and 'rest'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for taking time to write this! The change looks good, but I'd like to ask you to write some tests for this before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Again, thanks a lot for this. 👍
bors r+
473: Add more optimizations r=dragostis a=SkiFire13 Adds a couple more optimizations: 1. Converts `(rule ~ rest) | rule` to `rule ~ rest?`, avoiding trying to match `rule` twice. Same as the already existing `factor` but in the case the second expression is not `Expr::Seq`. 2. Converts `rule | (rule ~ rest)` to `rule` since `(rule ~ rest)` will never match if `rule` didn't. Not sure if this should go in `factorizer.rs` but the pattern looked really similar. 3. Converts `(rule ~ rest)* ~ rule` to `rule ~ (rest ~ rule)*`, avoiding matching the last `rule` twice, should have a big impact on issues like #453 and #463. Goes to a new file names `lister.rs`, not sure if the name is descriptive enough. Actually there's a 4th optimization I thought of, converting `(rule ~ rest)* ~ rule?` to `rule ~ (rest ~ rule)* ~ rest?`, assuming `rule` is more expensive than `rest` but I don't think this can be determined if one of them contain an `Expr::Ident`. This would have the same effect of 3. on the relevant cases. Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
Timed out. |
480: Fix build after PR #454 r=CAD97 a=SkiFire13 PR #454 broke the build by adding a doctest that doesn't compile, in particular it gave the following error: ``` failures: ---- src/error.rs - error::ErrorVariant<R>::message (line 445) stdout ---- error[E0282]: type annotations needed for `pest::error::ErrorVariant<R>` --> src/error.rs:447:15 | 5 | let variant = ErrorVariant::CustomError { | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `R` declared on the enum `ErrorVariant` | | | consider giving `variant` the explicit type `pest::error::ErrorVariant<R>`, where the type parameter `R` is specified error: aborting due to previous error For more information about this error, try `rustc --explain E0282`. Couldn't compile the test. failures: src/error.rs - error::ErrorVariant<R>::message (line 445) test result: FAILED. 59 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out ``` This error made PRs #470's and #473's bors build fail. After this PR is merged bors should be re-run for them. Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
I'll re-r this once CI is fixed (#483), but I unfortunately really don't have time to sort through the new style warnings and apply/ignore them right now. I already spent too much time on this, grad school is really eating all of my time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the merge issue and I'll merge this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r=dragostis
Will manually merge when CI passes
473: Add more optimizations r=dragostis a=SkiFire13 Adds a couple more optimizations: 1. Converts `(rule ~ rest) | rule` to `rule ~ rest?`, avoiding trying to match `rule` twice. Same as the already existing `factor` but in the case the second expression is not `Expr::Seq`. 2. Converts `rule | (rule ~ rest)` to `rule` since `(rule ~ rest)` will never match if `rule` didn't. Not sure if this should go in `factorizer.rs` but the pattern looked really similar. 3. Converts `(rule ~ rest)* ~ rule` to `rule ~ (rest ~ rule)*`, avoiding matching the last `rule` twice, should have a big impact on issues like #453 and #463. Goes to a new file names `lister.rs`, not sure if the name is descriptive enough. Actually there's a 4th optimization I thought of, converting `(rule ~ rest)* ~ rule?` to `rule ~ (rest ~ rule)* ~ rest?`, assuming `rule` is more expensive than `rest` but I don't think this can be determined if one of them contain an `Expr::Ident`. This would have the same effect of 3. on the relevant cases. Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
Timed out. |
bors merge |
Build succeeded: |
Adds a couple more optimizations:
Converts
(rule ~ rest) | rule
torule ~ rest?
, avoiding trying to matchrule
twice. Same as the already existingfactor
but in the case the second expression is notExpr::Seq
.Converts
rule | (rule ~ rest)
torule
since(rule ~ rest)
will never match ifrule
didn't. Not sure if this should go infactorizer.rs
but the pattern looked really similar.Converts
(rule ~ rest)* ~ rule
torule ~ (rest ~ rule)*
, avoiding matching the lastrule
twice, should have a big impact on issues like Improving slow Rockstar parser #453 and Very slow recursive pattern #463. Goes to a new file nameslister.rs
, not sure if the name is descriptive enough.Actually there's a 4th optimization I thought of, converting
(rule ~ rest)* ~ rule?
torule ~ (rest ~ rule)* ~ rest?
, assumingrule
is more expensive thanrest
but I don't think this can be determined if one of them contain anExpr::Ident
. This would have the same effect of 3. on the relevant cases.