| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Apparently a switch on an 8-bit quantity where all cases are present generates a more efficient jump (doing only one indexed memory load instead of two). See faster-cpython/ideas#321 (comment)
|
Would it make more sense to redefine opcode to be a uint8_t, rather than casting it? We should probably make use_tracing an 8 bit unsigned integer as well. |
Sorry, something went wrong.
Yeah, I had considered that, it makes sense. I'll confirm that it has the same effect.
I don't see why -- it's not used in a similar switch AFAICT, and it's not cramped for space in its struct. I assume for most other operations the cost of loading an int and loading a byte is effectively the same, since the CPU has to load a whole cache line (32 or 64 bytes) anyway. |
Sorry, something went wrong.
|
I don't believe this needs a news blurb. |
Sorry, something went wrong.
The dispatch sequence includes opcode |= cframe.use_tracing. |
Sorry, something went wrong.
Okay, I'll make that change. |
Sorry, something went wrong.
|
@markshannon, please re-review. I confirmed that the switch still uses a single indirection (goto *(base + offset_table[opcode])). I also found that the opcode |= use_tracing is a single instruction (but maybe it always was one?). |
Sorry, something went wrong.
|
Looks good to me |
Sorry, something went wrong.
|
Oh wow, that's a simple and clever optimization! Great that it helps MSVC to optimize Python on Windows! |
Sorry, something went wrong.
|
Follow-up fo clean the public API: #91906 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Apparently a switch on an 8-bit quantity where all cases are
present generates a more efficient jump (doing only one indexed
memory load instead of two).
See faster-cpython/ideas#321 (comment)