FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-136681: make argsbuf static to speedup processing positional arguments with AC by skirpichev · Pull Request #136732 · python/cpython · GitHub

/ cpython Public

gh-136681: make argsbuf static to speedup processing positional arguments with AC - #136732

Closed
skirpichev wants to merge 7 commits into
python:mainfrom
skirpichev:ac-argsbuf/136681
Closed

gh-136681: make argsbuf static to speedup processing positional arguments with AC#136732
skirpichev wants to merge 7 commits into
python:mainfrom
skirpichev:ac-argsbuf/136681

Conversation

skirpichev commented Jul 17, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

benchmark: #136681 (comment)

Copy link
Copy Markdown
Member

Won't this break when called concurrently?

This comment was marked as resolved.

skirpichev closed this Jul 19, 2025
skirpichev deleted the ac-argsbuf/136681 branch July 19, 2025 08:22
skirpichev restored the ac-argsbuf/136681 branch July 29, 2025 14:22

Copy link
Copy Markdown
Member Author

Hmm, @ZeroIntensity, test seems fixed with using combined static and _Thread_local. May this work or this is too naive approach?

ZeroIntensity commented Jul 29, 2025
edited
Loading

Copy link
Copy Markdown
Member

Hm, you could try it and see what the test suite says. To my knowledge, thread local lookups are generally slower, so we might not see a speedup.

skirpichev reopened this Jul 29, 2025

skirpichev commented Jul 29, 2025
edited
Loading

Copy link
Copy Markdown
Member Author

Well, CI tests pass, but that might be just an accident.

thread local lookups are generally slower, so we might not see a speedup.

Here my quick measurements for default configure arguments on Linux box. (Free-threading build might change the picture.) Micro-benchmarks are for math.fmin(): when only positional arguments are allowed (as in the main) vs positional-or-keyword allowed.

In the main:

Benchmark posonly-ref posorkw-ref
fmin(1.0, 2.0) 169 ns 188 ns: 1.11x slower
fmin(1.0, 2.0) x 2 times 969 ns 1.00 us: 1.03x slower
fmin(1.0, 2.0) x 10 times 2.09 us 2.27 us: 1.08x slower
fmin(1.0, 2.0) x 100 times 14.8 us 16.5 us: 1.12x slower
Geometric mean (ref) 1.09x slower

With the patch:

Benchmark posonly-patch posorkw-patch
fmin(1.0, 2.0) 170 ns 173 ns: 1.02x slower
fmin(1.0, 2.0) x 10 times 2.06 us 2.08 us: 1.01x slower
fmin(1.0, 2.0) x 100 times 14.8 us 15.0 us: 1.01x slower
Geometric mean (ref) 1.01x slower

Benchmark hidden because not significant (1): fmin(1.0, 2.0) x 2 times

Details
import pyperf
from math import fmin

def f(n):
    for _ in range(n):
        fmin(1.0, 2.0)

runner = pyperf.Runner()
runner.bench_func('fmin(1.0, 2.0)', fmin, 1.0, 2.0)
for n in [2, 10, 100]:
    s = f'fmin(1.0, 2.0) x {n:3} times'
    runner.bench_func(s, f, n)

skirpichev closed this Nov 13, 2025
skirpichev deleted the ac-argsbuf/136681 branch November 13, 2025 13:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL