Itamar Ostricher <itamar...@gmail.com> added the comment:

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%

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45697>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to