Message258918
A number of fine-grained methods in Objects/listobject.c use PyList_Check(). They include PyList_Size, PyList_GetItem, PyList_SetItem, PyList_Insert, and PyList_Append.
The PyList_Check() works by making two sequentially dependent memory fetches:
movq 8(%rdi), %rax
testb $2, 171(%rax)
je L1645
This patch proposes a fast path for the common case of an exact match, using PyList_CheckExact() as an early-out before the PyList_Check() test:
leaq _PyList_Type(%rip), %rdx # parallelizable
movq 8(%rdi), %rax # only 1 memory access
cmpq %rdx, %rax # macro-fusion
je L1604 # early-out
testb $2, 171(%rax) # fallback to 2nd memory access
je L1604
This technique won't help outside of Objects/listobject.c because the initial LEA instruction becomes a MOV for the global offset table, nullifying the advantage. |
|
Date |
User |
Action |
Args |
2016-01-25 19:25:40 | rhettinger | set | recipients:
+ rhettinger, serhiy.storchaka |
2016-01-25 19:25:40 | rhettinger | set | messageid: <1453749940.01.0.185085396815.issue26201@psf.upfronthosting.co.za> |
2016-01-25 19:25:39 | rhettinger | link | issue26201 messages |
2016-01-25 19:25:39 | rhettinger | create | |
|