-
Notifications
You must be signed in to change notification settings - Fork 135
all/any builtins implemented using Truffle #239
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
Conversation
Hello Octave Larose, thanks for contributing a PR to our project! We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address octave -(dot)- larose -(at)- hotmail -(dot)- fr. You can sign it at that link. If you think you've already signed it, please comment below and we'll check. |
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.
Thank you for the contribution. The code is mostly correct, but has few performance problems, see the comments inline. I'll answer your questions in a spearate comment, the review UI is not good for writing long replies
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
if (e.type != StopIteration)
throw e; So any other exception than
Agreed, the generic specialization will handle strings. We don't need to cover all builtin types, just the common ones where we expect some performance benefit from taking advantage of their internals.
It's not guaranteed, I added a counterexample in the review.
I think it's ok as it is. Specializing on
You can match on
I'd personally keep them in
I mentioned it in the review too. You don't have to specialize on every subclass, just the ones that will be common and then have a generic fallback that handles the rest. I'd personally do that in a separate inner helper node to avoid combinatorial explosion of specializations. |
Thanks for your feedback! I'll try to send an updated version next week or so. To answer a specific few comments:
I did know it yielded the keys (which makes me realize calling
I was just thinking of calls to various nodes, like
I did consider it, actually! I thought it might be better to keep them separate for code clarity reasons and maybe performance (it's hard for me to assess what can impact performance negatively and what can't, for now). But yes, if so I'll gladly make them share some logic. Not a fan of boolean arguments and might use an Many questions I had but didn't necessarily ask got answered in your comments, so thank you for that! Thanks for taking the time to write these remarks, in general. |
Here's the updated version of the code, taking your feedback into account. The implementation should now be correct now that the behavior of all/any on A few notes:
That's pretty much it, let me know if I didn't implement code related to your previous feedback correctly. Also looking for advice on improving code readability/quality! |
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.
Just some brief comments.
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
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 added some comments, but I'm out of time now, I'll probably comment more next week.
I recommend you read some of the main papers about GraalVM/Truffle, if you haven't done that already. If you're writing a thesis, they will serve well for citations. In particular:
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
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.
Looks good to me overall, thank you for fixing the problems. There are two comments left unaddressed and I added one more. I'll submit it for review internally, so I might add some comments from others or results from the CI.
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
Octave Larose has signed the Oracle Contributor Agreement (based on email address octave -(dot)- larose -(at)- hotmail -(dot)- fr) so can contribute to this repository. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@OctaveLarose could you please rebase the PR on top of current master and make it build? It doesn't build anymore due to some unused import of a class we removed in the meantime |
Sure thing, should be fixed now. I'd been basing it off an older version of As for the rest, I wasn't 100% done (hence the odd I was also trying to compare my changes with the current implementation via |
If master cannot build, there are 2 common reasons why that could happen:
Ah, sorry, it seemed quite complete, so I thought it was. No hurry, take your time.
You need to build and run with the graal compiler enabled. By default, most
Feel free to ping me there directly. |
That should be it, I thought I had more left to do - my bad for not getting it done last Friday. I wanted to try to improve the I also wanted to move In other news, Graal was indeed not up to date and |
Regarding benchmarks, there are two major metrics we measure:
We care a lot about peak performance because that's how we differentiate from CPython, but interpreter performance is also important so that programs don't take minutes to start up. Ideally, you would benchmark both. The default configuration measures peak performance. For benchmarking interpreter performance, you can run a benchmark like this: |
I ran the CI gates and there were some gate failures:
|
Fixed the tests, there was a big oversight in For the formatting, though, I'm not sure.
Thanks! This should save me some searching. |
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
…r lists and no error messages/correct behavior for invalid inputs Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
…ts/sets/tuples as well Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
…ation via shouldStopIteration() Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
…changed parent node class Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
… class to PNodeWithContext Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
…formatting Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
I rebased it on this repo's main branch again to make absolutely sure it wasn't the formatting issue didn't only happen when completely up to date, but this doesn't seem to have been the case. |
Ah, sorry, I realized what the problem is with the formatter - it uses eclipse formatter and it needs to have eclipse installed, otherwise it only checks licenses. Please download eclipse (we use version 4.14 for the formatter, so it's probably a good idea to get the same), extract it somewhere and set environment variable Additionally, you can get the formatting in your IDE. If you're using Eclipse it should work already. If you're using Intellij IDEA you can install Eclipse Formatter Plugin and rerun |
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Ah, because of the name of the command, I was assuming it was purely 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.
I forwarded some comments that I got from the internal review. There were some suggestions regarding loop profiling, which I marked as optional, because we're missing loop profiling in a lot of other places. Loop profiling is done to help the compiler have more accurate statistics about which code parts are "hotter" to guide other optimizations. I don't know relevant it is to your thesis, so I'm leaving it up to you if you want to deal with that.
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
…very all/any specialization method Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
...n/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
You have a bug somewhere:
|
Signed-off-by: Octave Larose <octave.larose@hotmail.fr>
Thanks for the heads up, corrected in fa07d30 - was an oversight on my part. |
PullRequest: graalpython/2011
Hi all,
First of all, thank you for your work on this project! Second of all, while I've read the contributing guidelines and signed the OCA, I'm still waiting for it to be approved ; I thought I'd open this pull request to get some potential feedback in the meantime.
I've only been looking at this project for a couple of days and I'm not too familiar with it, just like I'm fairly new to Graal as well. Which is why I'm assuming this work should be revised.
While functional, it can be definitely improved in many ways I'm most likely not familiar with. As a series of notes:
while(true)
loop in the generic implementations for both. While I'm assuming aStopIteration
exception will always be called and caught no matter what, I can't say it with full confidence out of lack of knowledge regarding GraalPython. Also unsure whether this implementation can preventKeyboardInterrupt
.all
orany
call on astr
will always returnTrue
as far as I know anyway (unlessany
is fed an empty string). I could write a specialization method for strings that simply returnstrue
, however. (and does a simple check for empty strings withany
).dict
specialization but don't know how warranted it is for the reasons mentioned above. I made theall
one returnTrue
by default because of them ; let me know if you can think of counterarguments to this implementation. (or this potentialPString
one)bytes
/bytearray
specializations. I originally specialized usingPSequence
, which obviously caught them as they extend it, but I assumed specificity yielded better performance. Adding specifications for these types would be trivial.PSet
and notPBaseSet
, hence not accounting forPFrozenSet
. Unsure how relevant that is and how it should be done.BuiltinFunctions.java
, but I'd rather have the bulk of it be in one/two separate class(es), as seems to be the case for many builtin functions. However, I wasn't sure what to name them, where to put them in the file tree, etc. Which plays into my next question:SequenceStorage
instead of simply relying on this parent class (as I do here). If relevant, how should one go about this? This sounds like a lot of added logic if done right.Thanks for your time and hard work!