Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-117581: Specialize binary operators by refcount as well as type.#117627

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@markshannon
Copy link
Member

@markshannonmarkshannon commentedApr 8, 2024
edited
Loading

This PR changes the specialization of binary operators for the current, fairly ad-hoc approach to a bit more principled approach of specializing by refcount and using table lookup to specialize by type.

Tier 1 performance is in the noise, maybe showing a slight slowdown.

I expect the advantages of this approach to show up when applied toBINARY_SUBSCR,COMPARE_OP and with the JIT.

It also opens the possibility of specializing binary operators for numpy arrays and the Decimal class.

unused/1+
_GUARD_NOS_REFCNT1+
_GUARD_TOS_IMMORTAL+
_BINARY_OP_TABLE_NN;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you please document in thebytecodes.c file what these suffixes mean? Some of them are easy to see, but I don't know what'sNN vsND immediately.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

@markshannon
Copy link
MemberAuthor

Performance on both tier 1 and tier 2 is about 1% slower.
With deferred reference counting, there will be no need for specializing on refcount, so I'm deferring this until deferred reference counting is done.

@markshannon
Copy link
MemberAuthor

Earlier results had an issue with thetelco benchmark, probably due to the decimal module falling back to the pure Python version.

Benchmarking on tier 1 shows theslowdown to be in the noise.
The significant results are a speedup of 7% for spectral_norm and a slowdown of 12% for nbody.
This is presumably due to more complete specialization for spectral_norm and additional overhead for the already well specialized nbody code.
We expect the advantage of better specialization to be important in tier 2, but the additional tier 1 overhead to be largely irrelevant there.

@brandtbucherbrandtbucher self-requested a reviewJune 6, 2024 16:48
@brettcannonbrettcannon removed their request for reviewJune 11, 2024 20:34
@markshannon
Copy link
MemberAuthor

Abandoning this as#128722 is handling the same problem and we have a better ideas for reducing refcounting overheadfaster-cpython/ideas#700

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner left review comments

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ncoghlanncoghlanAwaiting requested review from ncoghlanncoghlan is a code owner

@warsawwarsawAwaiting requested review from warsawwarsaw is a code owner

@methanemethaneAwaiting requested review from methanemethane is a code owner

@brandtbucherbrandtbucherAwaiting requested review from brandtbucher

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@markshannon@Fidget-Spinner

[8]ページ先頭

©2009-2025 Movatter.jp