-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
expr: Optimizing for integer values #5614
Conversation
nice, did you do some benchmark ? - just curious on what kind of impact this can have |
Not yet, was looking if there are some open test data sets available for |
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.
Great! I'm also curious to see the performance impact. I have a few small suggestions, and one case where I think you've accidentally changed the behaviour.
Sorry for getting back on this so late, had a busy week! |
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.
Nice work! I think you took my advice with From
a bit too far, but hopefully what I meant is clear now 😄 It is looking better though!
Also those numbers for the performance are super interesting. I wonder why the string operations are slower! Did you try with --release
?
Thanks for taking a look at it again @tertsdiepraam ! Maybe I should try and do this on a little less noisy system :) |
GNU testsuite comparison:
|
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.
Excellent! Just one final suggestion. Great benchmarks! I think it makes sense that it's noisy because it's not the biggest improvement, but it is a great change nonetheless!
src/uu/expr/src/syntax_tree.rs
Outdated
let pos: usize = Option::<usize>::from(pos.eval()?).unwrap_or(0); | ||
let length: usize = Option::<usize>::from(length.eval()?).unwrap_or(0); |
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.
I still think this one is weird. Maybe it could be eval_as_usize
? Or we could just inline it:
let pos: usize = Option::<usize>::from(pos.eval()?).unwrap_or(0); | |
let length: usize = Option::<usize>::from(length.eval()?).unwrap_or(0); | |
let pos = pos.eval()?.eval_as_bigint().map_or(0, |n| n.to_usize()); | |
let length = pos.eval()?.eval_as_bigint().map_or(0, |n| n.to_usize()); |
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.
done
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.
I made a small change (see the last commit), but this looks ready to be merged once the CI is green. Thanks!
This is great! Thanks so much for all your help. |
green, merged :) |
An attempt at resolving issue #5591