Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: drop the initial stack copy #2670

Merged
merged 3 commits into from Dec 5, 2021
Merged

Conversation

isidentical
Copy link
Collaborator

This isn't much, but at least a good start (we did 3 overall copies, but seem like the initial one is unnecessary since we never touch that stack, so we do 2 of them now).

main:

$ touch t.py; time black -tpy310 --check t.py > /dev/null
would reformat t.py
Oh no! 💥 💔 💥
1 file would be reformatted.
black -tpy310 --check t.py > /dev/null  0,33s user 0,02s system 99% cpu 0,358 total

this branch:

$ touch t.py; time black -tpy310 --check t.py > /dev/null
would reformat t.py
Oh no! 💥 💔 💥
1 file would be reformatted.
black -tpy310 --check t.py > /dev/null  0,27s user 0,01s system 99% cpu 0,275 total

test script: https://gist.github.com/isidentical/2911e41262314e6f189149da45a10054

@ichard26
Copy link
Collaborator

ichard26 commented Dec 5, 2021

parse-black/strings
===================

Mean +- std dev: [uhh-default] 67.0 ms +- 2.0 ms -> [uhh-initial] 227 ms +- 27 ms: 3.39x slower
Mean +- std dev: [uhh-default] 67.0 ms +- 2.0 ms -> [uhh-speedup] 154 ms +- 3 ms: 2.30x slower

parse-match-identifiers
=======================

Mean +- std dev: [uhh-default] 21.8 ms +- 2.7 ms -> [uhh-initial] 196 ms +- 23 ms: 9.01x slower
Mean +- std dev: [uhh-default] 21.8 ms +- 2.7 ms -> [uhh-speedup] 135 ms +- 10 ms: 6.19x slower

Geometric mean
==============

uhh-initial: 5.53x slower
uhh-speedup: 3.77x slower

❯ pyperf compare_to uhh-initial.json uhh-speedup.json -G
Faster (2):
- parse-black/strings: 227 ms +- 27 ms -> 154 ms +- 3 ms: 1.47x faster
- parse-match-identifiers: 196 ms +- 23 ms -> 135 ms +- 10 ms: 1.46x faster

Geometric mean: 1.47x faster

@JelleZijlstra JelleZijlstra merged commit 28ab82a into psf:main Dec 5, 2021
@ichard26 ichard26 added the C: performance Black is too slow. Or too fast. label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: performance Black is too slow. Or too fast.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants