[issue46528] Simplify the VM's stack manipulations

2022-02-09 Thread Brandt Bucher
Change by Brandt Bucher : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-02-09 Thread Brandt Bucher
Brandt Bucher added the comment: New changeset 78ae4cc6dc949e8bc39fab25fea5efe983dc0ad1 by Brandt Bucher in branch 'main': bpo-46528: Attempt SWAPs at compile-time (GH-30970) https://github.com/python/cpython/commit/78ae4cc6dc949e8bc39fab25fea5efe983dc0ad1 --

[issue46528] Simplify the VM's stack manipulations

2022-02-09 Thread Brandt Bucher
Brandt Bucher added the comment: New changeset 46328d8ae6529db916ccaabb9247fb0327ce0c1e by Brandt Bucher in branch 'main': bpo-46528: Check PyMem_Malloc for NULL (GH-30998) https://github.com/python/cpython/commit/46328d8ae6529db916ccaabb9247fb0327ce0c1e --

[issue46528] Simplify the VM's stack manipulations

2022-02-01 Thread Brandt Bucher
Brandt Bucher added the comment: New changeset a0e55a571cf01885fd5826266c37abaee307c309 by Brandt Bucher in branch 'main': bpo-46528: Simplify BUILD_TUPLE/UNPACK_SEQUENCE folding (GH-31039) https://github.com/python/cpython/commit/a0e55a571cf01885fd5826266c37abaee307c309 --

[issue46528] Simplify the VM's stack manipulations

2022-01-31 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +29222 pull_request: https://github.com/python/cpython/pull/31039 ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-01-28 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +29180 pull_request: https://github.com/python/cpython/pull/30998 ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-01-28 Thread Brandt Bucher
Brandt Bucher added the comment: Hm, yeah. Bummer that this needs error handling now. I'll have a fix up soon. -- ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-01-28 Thread Dennis Sweeney
Dennis Sweeney added the comment: Minor nit: I think swaptimize() should check the for PyMem_Malloc returning NULL here. // Create an array with elements {0, 1, 2, ..., depth - 1}: int *stack = PyMem_Malloc(depth * sizeof(int)); for (int i = 0; i < depth; i++) { stack[i]

[issue46528] Simplify the VM's stack manipulations

2022-01-28 Thread Ken Jin
Ken Jin added the comment: > IIRC, Carl got a lot of benefit out of reordering the opcodes in the main > loop to put the most common ones at the top. I don't know if that is still > relevant or whether computed gotos, when enabled, change that calculus. AFAIK, on nix systems with PGO, the

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: IIRC, Carl got a lot of benefit out of reordering the opcodes in the main loop to put the most common ones at the top. I don't know if that is still relevant or whether computed gotos, when enabled, change that calculus. --

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Brandt Bucher
Brandt Bucher added the comment: > I did an experiment to double the number of instructions. Were the extra instructions just NOPs, or were they actually doing any work? If they were NOPs, then presumably those numbers tell us more about the overhead of dispatch and cache pressure than

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Mark Shannon
Mark Shannon added the comment: Timings for individual instructions are a bit meaningless, as out-of-order execution and speculation on modern CPUs makes it hard to pin down the timing of anything. I did an experiment to double the number of instructions. It slowed things down by ~10%, so

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Brandt Bucher
Brandt Bucher added the comment: In a typical run of the pyperformance benchmark suite, rotations account for a bit over 1% of all instructions executed. I don't have timings for individual instructions, unfortunately. -- ___ Python tracker

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Very interesting. Do we have any current (or even cutting edge, i.e. 3.11) timings for individual instructions? Or a breakdown of how frequently different instructions are invoked? I remember Carl Shapiro presenting his findings here several years ago

[issue46528] Simplify the VM's stack manipulations

2022-01-27 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +29148 pull_request: https://github.com/python/cpython/pull/30970 ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-01-26 Thread Brandt Bucher
Brandt Bucher added the comment: New changeset 85483668647e7840c7b9a1877caaf2ef14a4443f by Brandt Bucher in branch 'main': bpo-46528: Simplify the VM's stack manipulations (GH-30902) https://github.com/python/cpython/commit/85483668647e7840c7b9a1877caaf2ef14a4443f --

[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher
Brandt Bucher added the comment: In practice, pretty much the only thing that will do more work now is augmented subscription: >>> a[b] += c main: 1 2 LOAD_NAME0 (a) 4 LOAD_NAME1 (b) 6 DUP_TOP_TWO 8

[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher
Change by Brandt Bucher : -- keywords: +patch pull_requests: +29081 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30902 ___ Python tracker ___

[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: What are the (unoptimized) performance implications of replacing one instruction with multiple instructions? -- nosy: +barry ___ Python tracker

[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher
New submission from Brandt Bucher : ...as discussed in https://github.com/faster-cpython/ideas/discussions/228. We can dramatically simplify our stack manipulations by getting rid of the `DUP_TOP*` and `ROT_*` families of instructions: - Replace `DUP_TOP` with `COPY(1)`. - Replace