Message405654
thanks for the feedback Serhiy!
repeating my response from the PR here as well (not sure what's the proper etiquette.. :-) )
note that this code path is not for creating new types (which is slow as you say), but for creating new instances (which is quite fast).
I ran some synthetic benchmarks with this change and without it (on an opt build with PGO and LTO), and the gain is measurable:
build from main (commit acc89db9233abf4d903af9a7595a2ed7478fe7d3 which is the base commit for this PR):
```
>for _ in {1..10}; do ./main-opt/python -m timeit -n 10000 -s 'class Spam: pass' -- 'ten_k_spams = [Spam() for _ in range(10000)]'; done
10000 loops, best of 5: 896 usec per loop
10000 loops, best of 5: 887 usec per loop
10000 loops, best of 5: 857 usec per loop
10000 loops, best of 5: 838 usec per loop
10000 loops, best of 5: 847 usec per loop
10000 loops, best of 5: 863 usec per loop
10000 loops, best of 5: 845 usec per loop
10000 loops, best of 5: 902 usec per loop
10000 loops, best of 5: 890 usec per loop
10000 loops, best of 5: 875 usec per loop
```
build with this change applied (commit 2362bf67e8acee49c6f97ea754d59dfd8982e07c):
```
>for _ in {1..10}; do ./test-opt/python -m timeit -n 10000 -s 'class Spam: pass' -- 'ten_k_spams = [Spam() for _ in range(10000)]'; done
10000 loops, best of 5: 833 usec per loop
10000 loops, best of 5: 885 usec per loop
10000 loops, best of 5: 845 usec per loop
10000 loops, best of 5: 838 usec per loop
10000 loops, best of 5: 833 usec per loop
10000 loops, best of 5: 827 usec per loop
10000 loops, best of 5: 858 usec per loop
10000 loops, best of 5: 811 usec per loop
10000 loops, best of 5: 843 usec per loop
10000 loops, best of 5: 845 usec per loop
```
also worth noting that the previous approach (GH-29380) was implemented on the Instagram Server production workload in Meta/Facebook/Instagram (choose your favorite) and resulted measurable perf gain of around 0.2% |
|
Date |
User |
Action |
Args |
2021-11-03 22:42:17 | itamaro | set | recipients:
+ itamaro, serhiy.storchaka, Dennis Sweeney, kj, arhadthedev |
2021-11-03 22:42:17 | itamaro | set | messageid: <1635979337.61.0.332160959049.issue45697@roundup.psfhosted.org> |
2021-11-03 22:42:17 | itamaro | link | issue45697 messages |
2021-11-03 22:42:17 | itamaro | create | |
|