GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-136681: make argsbuf static to speedup processing positional arguments with AC by skirpichev · Pull Request #136732 · python/cpython

Conversation

@skirpichev

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Slow functions calls for C-coded functions, accepting positional-or-kwarg argument vs positional-only #136681

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Jul 17, 2025
Slow functions calls for C-coded functions, accepting positional-or-kwarg argument vs positional-only #136681
Open
@skirpichev skirpichev added the skip news label Jul 17, 2025
@skirpichev
skirpichev force-pushed the ac-argsbuf/136681 branch from 579822c to c88f2bf Compare July 17, 2025 03:30
@skirpichev
pythongh-136681: make argsbuf static to speedup processing positional
5463883
arguments with AC
@skirpichev
skirpichev force-pushed the ac-argsbuf/136681 branch from c88f2bf to 5463883 Compare July 17, 2025 04:06
@skirpichev

skirpichev commented Jul 17, 2025

Copy link
Copy Markdown
Member Author

benchmark: #136681 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity

ZeroIntensity commented Jul 17, 2025

Copy link
Copy Markdown
Member

Won't this break when called concurrently?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

This comment was marked as resolved.

Sign in to view
@skirpichev skirpichev closed this Jul 19, 2025
@skirpichev
skirpichev deleted the ac-argsbuf/136681 branch July 19, 2025 08:22
@skirpichev
skirpichev restored the ac-argsbuf/136681 branch July 29, 2025 14:22
skirpichev added 2 commits July 29, 2025 17:30
@skirpichev
Merge branch 'master' into ac-argsbuf/136681
b4d32ca
@skirpichev
XXX try _Thread_local
46b2f98
@skirpichev

skirpichev commented Jul 29, 2025

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity

ZeroIntensity commented Jul 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
+1
c88bcb2
@skirpichev skirpichev reopened this Jul 29, 2025
@skirpichev

skirpichev commented Jul 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
Merge branch 'master' into ac-argsbuf/136681
36868ce
@skirpichev
skirpichev marked this pull request as ready for review September 10, 2025 05:13
@skirpichev
skirpichev requested review from AA-Turner, ericsnowcurrently and erlend-aasland as code owners September 10, 2025 05:13
@bedevere-app bedevere-app Bot added the awaiting review label Sep 10, 2025
skirpichev added 2 commits November 13, 2025 09:31
@skirpichev
Merge branch 'master' into ac-argsbuf/136681
894d62b
@skirpichev
Merge branch 'master' into ac-argsbuf/136681
98d57ee
@skirpichev skirpichev closed this Nov 13, 2025
@skirpichev
skirpichev deleted the ac-argsbuf/136681 branch November 13, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@skirpichev @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.