| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Hm, it doesn't sound right to override profile-guided optimization, especially since test_decimal (the only current caller of _PyType_GetModuleByDef2) is in the PGO test set. |
Sorry, something went wrong.
|
It is mentioned on the faster-cpython repo that the telco test has slowed down a lot. According to MSVC, the module state access counts were: Function / breakdown entry-cnt alternative access
----------------------- --------- ---------------------------
PyType_GetModuleByDef() 6852643
convert_op 2971848 via context object
PyDecType_New 1651188 via context object (partial)
dec_addstatus 1651188 via context object (partial)
current_context 1486221 via context object (partial)
dec_mpd_qquantize 247731 METH_METHOD
ctx_mpd_qquantize 165000 METH_METHOD
...
_PyType_GetModuleByDef2() 1073193
nm_mpd_qadd 660462
nm_mpd_qmul 412731
Tested with the /Ob3 option, switching the inlining specifier: f740a5d. My Release/PGO builds on Windows get slower using TLS version of PyThreadState_Get(), which is also observed at #103324 (comment). If *nix OSes are in good health with TLS, I guess I also need to run the telco with a good condition (without TLS):
This patch would need to be applied if we wanted as much speed as the global state access on Windows, which has little effect alone (1%) for some reason. |
Sorry, something went wrong.
|
Windows PGO: |
Sorry, something went wrong.
|
Is it acceptable that test_decimal.py has a test case like below, instead of touching the C code? @requires_cdecimal
class CArithmeticOperatorsTest(ArithmeticOperatorsTest, unittest.TestCase):
...
@unittest.skipIf(not test.support.PGO, 'PGO training only')
def test_excecise_binop(self):
Decimal = self.decimal.Decimal
d = Decimal('11.1')
for i in range(500000):
1 + d # at least 300000 times |
Sorry, something went wrong.
|
I'll try PyType_GetBaseByToken() version. |
Sorry, something went wrong.
|
Closing in favor of proposing the PyType_GetBaseByToken() version, which can supersede _PyType_GetModuleByDef2() on PGO and Relase(/Ob3) builds. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
On main and 3.13, there are cases where the get_module_by_def function in typeobject.c is not inlined in its wrapper functions:
Non-builtin modules can have extra function-call overheads, where the wrappers cannot be inlined.
This PR specifies Py_ALWAYS_INLINE to the callee.
cc @encukou