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-134584: Eliminate redundant refcounting from _BINARY_OP_ADD_UNICODE by corona10 · Pull Request #135817 · python/cpython Conversation
|
|
Maybe I have to wait #135761 first |
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.
Mostly LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| l = left; | ||
| r = right; | ||
| Py_DECREF(temp); | ||
| } | ||
| else { | ||
| res = sym_new_type(ctx, &PyUnicode_Type); | ||
| l = left; | ||
| r = right; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be in the branch. You can write this at the end of the instruction here.
That way, we only need to have one l = left; r = right
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| self.assertIsNotNone(ex) | ||
| uops = get_opnames(ex) | ||
|
|
||
| self.assertIn("_POP_TOP_NOP", uops) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add
self.assertIn("_BINARY_OP_ADD_UNICODE", uops)
to make sure this is the op that's actually generated?
Should we also test for _POP_TOP_UNICODE?
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.
In this code, It will be replaced to _POP_TOP_NOP because _POP_TOP_UNICODE will be optimized to _POP_TOP_NOP .
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.
Yup, do you think it makes sense to test _POP_TOP_UNICODE separately? That is, the case when it is not optimized to _POP_TOP_NOP? (not sure how difficult it'll be to come up with a test case though)
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 have a test for that in my original PR already.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def test_store_fast_pop_top_specialize_unicode(self): | ||
| def random_str(n): | ||
| return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n)) | ||
| def testfunc(n): | ||
| y = random_str(32) | ||
| for _ in range(n): | ||
| x = y + y # _POP_TOP | ||
| x = None # _POP_TOP_NOP | ||
|
|
||
| testfunc(TIER2_THRESHOLD) | ||
|
|
||
| ex = get_first_executor(testfunc) | ||
| self.assertIsNotNone(ex) | ||
| uops = get_opnames(ex) | ||
|
|
||
| self.assertIn("_POP_TOP_NOP", uops) | ||
|
|
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.
Sorry I thought of a better test: you can use this one but change for str, and assert that the _POP_TOP_UNICODE uop is inside
cpython/Lib/test/test_capi/test_opt.py
Line 2310 in 46b423f
| def test_float_op_refcount_elimination(self): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry I just merged my PR in #135761. You'll have to rebase/merge in changes! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Fidget-Spinner Done! |
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.
This adds an extra field to every frame, which is likely to cost more than the improvement this PR would otherwise bring.
If we apply this change to every BINARY_OP, then it might be worth it.
Having said that, TOS caching might solve that problem.
If we can guarantee that each uop that would overflow the stack always leaves the necessary number of outputs in registers and that we never spill those values to memory,
than we can do this without the extra stack space.
Let's wait until TOS is in, and then we can investigate if that approach makes sense.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the 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.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.