-
Notifications
You must be signed in to change notification settings - Fork 4
Move evaluation of binary operations to step_bin_op #23
Conversation
No worries! Good learning opportunity for me 馃檪 |
The Never seen the |
You are right it is rather arcane/uncommon https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html#-bindings but nonetheless a cool feature. |
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.
Some big performance regression so please verify it locally before merge smile I don't trust my old laptops performance
I'll fetch your code and test it on mine (maybe benchmarks could be done by Travis?).
Edit: I now saw that the issue is assigned to @seanchen1991 I hope you don't mind me trying to do it sweat_smile
Yeah :/ next time try to check if the issue is not assigned beforehand. But no problem.
Implement short circuiting for && and ||
I ran the benchmarks and got the same regressions. I believe (take it with a grain of salt) that this has something to do with the match inside the new step function. I'm going to tinker a little bit with this and decide what to do. Edit: After poking the code here and there I discovered something. If you remove the short-circuiting patterns from
I think we can omit the short circuiting part for now and implement it in an earlier stage. Something that happens after the creation of the LIR of the code but before execution. However I'd like to have both your opinions before taking the next step. |
Than we would lose the ability to short circuit besides the simplest cases. This would not be short circuited before execution.
|
Ok that's true. I didn't think about that. I'm going to check which rules are executed when to see if we can win some performance somewhere. |
you made me realize that
doesn't short circuit right now, or does it? |
This short circuits
This does not
Edit: Is there some code that transforms function without conditions to constant? |
We don't really have the concept of constant yet. However functions without arguments are equivalent to its body. So these two snippets
and
are compiled to the same IR |
Ok good to know. I am fine with removing the short circuiting during evaluation and just doing it once before it. But maybe the performance hit is acceptable but our (selection of) benchmark algorithms aren't that good? |
Yep benchmarks aren't great. I'll open an issue to discuss it. I think we might take an intermediate decision and just short-circuit using the left term of a binary operation. i.e I propose that behavior to be consistent when using longer functions and it should make the regression less pronounced. What do you think? |
That would match the behavior of other languages that evaluate expression from left to right. I'm ok with it I just implemented both ways because it was possible 馃槅 |
Applied the changes and added one small fix to |
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.
LGTM, thanks!
Implement short circuiting for && and ||
Solves #4 and is part of #9
I added a helper function[1] to the test that stops the new test after 1 sec. So i someone breaks the short-circuiting the tests do not run endless.
Some big performance regression so please verify it locally before merge 馃槃 I don't trust my old laptops performance
Edit: I now saw that the issue is assigned to @seanchen1991 I hope you don't mind me trying to do it 馃槄