GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — gh-126835: Move constant tuple folding to CFG by WolframAlph · Pull Request #130769 · python/cpython Conversation
|
|
After moving folding to codegen (70ce2c8) I can see couple refleaks after running test suite in refleak hunter mode. After some debugging I narrowed down the problem. Long tuple defined directly does not report refleaks: x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30) but if it is run via compile("x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30)", "", "single") no idea yet why this is happening. I will be debugging further, but maybe someone has some insight what could be the problem? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Does it leak with compile with other modes (exec, eval)? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Yes. I wonder if it could be some form of false positive. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No idea. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Problem found. Turns out |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Why does it not happen at the prompt? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No idea. Maybe refleak checking flaw, but not sure. Maybe someone who knows more about it could tell us? Back to this PR - if we fold long tuples at codegen stage, we won't be able to fold long tuples that have constant expressions inside, for instance: (1, 2, 1 + 2, 4, ... 100) # long constant tuple will not be folded, unless we fold it in peepholer as written initially. Drawback of having optimizations that have to work together split between different stages. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I tend to agree. So I guess you're saying we should choose the second option from #130769 (comment). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Second options assumes that if we have constant tuple, we can skip |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
We could check recursively for constant expressions and emit long tuple bytecode if we know all subexpressions are constant, but I believe it would complicate code more than optimizing it in the peepholer. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I understand. Ok, let's revert back to the peephole situation then. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Another idea (not in this PR) would be to move all the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I will make a note and investigate later. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've reverted to the peepholer optimization and addressed previous review, please take a look. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it's a bit simpler if we grab two instructions in each iteration.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
577fb71 to
72a3e65
Compare
|
@iritkatriel can you review again when you have time? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
!buildbot refleak |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 4b11cf8 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F130769%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.