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-115999: Add free-threaded specialization for ``TO_BOOL`` by corona10 · Pull Request #126616 · python/cpython

Conversation

@corona10

@corona10 corona10 commented Nov 9, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • None / bool / int / str are immutable types, so they is thread-safe.
  • list is mutable, but by using PyList_GET_SIZE we can make it as thread-safe.
  • Issue: Make the specializing interpreter thread-safe in --disable-gil builds #115999

Sorry, something went wrong.

Uh oh!

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

All reactions
@corona10
pythongh-115999: Add free-threaded specialization for TO_BOOL
62b0307
* None / bool / int / str are immutable types, so they is thread-safe.
* list is mutable, but by using ``PyList_GET_SIZE`` we can make it
  as thread-safe.
@corona10
corona10 requested a review from markshannon as a code owner November 9, 2024 09:10
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 9, 2024
@corona10
corona10 requested a review from mpage November 9, 2024 09:10
@bedevere-app bedevere-app Bot mentioned this pull request Nov 9, 2024
Make the specializing interpreter thread-safe in --disable-gil builds #115999
Closed
@corona10 corona10 added the skip news label Nov 9, 2024
@corona10
nit
e32f2f0
@corona10
corona10 marked this pull request as draft November 9, 2024 09:44
@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 9, 2024
corona10
corona10 commented Nov 9, 2024
View reviewed changes
Comment thread Python/specialize.c Resolved

Uh oh!

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

@corona10
Make set cache as atomic operation
6798366
@corona10
corona10 marked this pull request as ready for review November 9, 2024 10:33
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 9, 2024
@corona10
fix
e45778b
@corona10
corona10 requested a review from Fidget-Spinner November 9, 2024 10:53
@corona10 corona10 changed the title gh-115999: Add free-threaded specialization for TO_BOOL [WIP] gh-115999: Add free-threaded specialization for TO_BOOL Nov 9, 2024
corona10
corona10 commented Nov 9, 2024
View reviewed changes
Comment thread Python/specialize.c Resolved

Uh oh!

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

@corona10
fix
bafabd7
@corona10 corona10 changed the title [WIP] gh-115999: Add free-threaded specialization for TO_BOOL gh-115999: Add free-threaded specialization for TO_BOOL Nov 9, 2024
@corona10 corona10 added the topic-free-threading label Nov 9, 2024
eendebakpt
eendebakpt reviewed Nov 9, 2024
View reviewed changes
Comment thread Python/specialize.c
if (PyAnySet_CheckExact(value)) {
return SPEC_FAIL_TO_BOOL_SET;
}
if (PyTuple_CheckExact(value)) {

@eendebakpt eendebakpt Nov 9, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe not for this PR to address, but why is the tuple type handled here? I see no specialization for tuple (or did I miss something?). Tuple is immutable, so it should be relatively easy to add

Sorry, something went wrong.

Uh oh!

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

All reactions

@corona10 corona10 Nov 9, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

IIRC, we added specializaiton based on metric that is measured at https://github.com/faster-cpython/benchmarking-public.
I am not sure how many tuple cases are actually existed.

Sorry, something went wrong.

Uh oh!

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

All reactions

@corona10 corona10 Nov 9, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I agree that tuple case is easy to add but that would be based on how many boolean operations are existed for the tuple at the real world workload.

Sorry, something went wrong.

Uh oh!

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

Eclips4 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
corona10 and others added 2 commits November 9, 2024 21:00
@corona10
nit
aa8a81c
@corona10
Address code review
1f4a350
mpage
mpage requested changes Nov 10, 2024
View reviewed changes

@mpage mpage left a comment •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for doing this! Looks good overall. In addition to the comment inline, we're also going to need to update _GUARD_TYPE_VERSION to load tp->tp_version tag using an FT_ATOMIC_LOAD_UINT32_RELAXED.

My review raced with your updates, I hope the comments still make sense.

Sorry, something went wrong.

Uh oh!

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

corona10 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Python/specialize.c Resolved

Uh oh!

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

Comment thread Python/specialize.c Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 10, 2024
@bedevere-app

bedevere-app Bot commented Nov 10, 2024

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added the awaiting changes label Nov 10, 2024
@corona10
Address code review
23e190e
@corona10
corona10 requested a review from mpage November 10, 2024 08:26
Hustlersambitionz

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@mpage
mpage requested a review from markshannon November 14, 2024 03:23
corona10 added 3 commits November 16, 2024 11:18
@corona10
Merge remote-tracking branch 'upstream/main' into pythongh-115999-bool
a213390
@corona10
Address code review
e68dc65
@corona10
Address code review
b27f916
@corona10

corona10 commented Nov 16, 2024

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Nov 16, 2024
@bedevere-app

bedevere-app Bot commented Nov 16, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@markshannon, @mpage: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app
bedevere-app Bot requested a review from mpage November 16, 2024 02:34
@corona10

corona10 commented Nov 16, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Mark,
I have addressed your code review especially for #126616 (comment)

I am okay with surrounding #ifdef Py_STATS but it will need extra PR for specialize and unspecialize function, so I prefer to handle it separately, and I believe that @mpage will handle this. (or I will submit the patch for this)

Please take a look :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10
nit
249efd1
mpage
mpage approved these changes Nov 16, 2024
View reviewed changes

@mpage mpage left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I still don't understand the rationale for keeping the gotos, but I care more about seeing this PR move forward. Accepting to unblock.

Sorry, something went wrong.

Uh oh!

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

corona10 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Nov 16, 2024
corona10 added 2 commits November 22, 2024 00:04
@corona10
Merge remote-tracking branch 'upstream/main' into pythongh-115999-bool
c08f8b7
@corona10
Address code review
6bc4c90
@corona10

corona10 commented Nov 21, 2024

Copy link
Copy Markdown
Member Author

@mpage I 've followed the changes from #127030, Would you like to take a look again?

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10
Use TO_BOOL for SPECIALIZATION_FAIL
542e4dd
mpage
mpage requested changes Nov 21, 2024
View reviewed changes

@mpage mpage left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM!

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 21, 2024
@bedevere-app

bedevere-app Bot commented Nov 21, 2024

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added the awaiting changes label Nov 21, 2024
mpage
mpage approved these changes Nov 21, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Nov 21, 2024
@corona10

corona10 commented Nov 21, 2024

Copy link
Copy Markdown
Member Author

I am merging this PR, @markshannon. Please let me know if we have to handle more things in the future PRs. Matt and I will try to adjust what you concerns :) cc @mpage

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10
corona10 merged commit 78a530a into python:main Nov 21, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 21, 2024
@corona10
corona10 deleted the gh-115999-bool branch November 21, 2024 22:52
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
@corona10 @ebonnal
pythongh-115999: Add free-threaded specialization for TO_BOOL (py…
0da364f
…thongh-126616)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eendebakpt eendebakpt eendebakpt left review comments
@mpage mpage mpage approved these changes
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
+1 more reviewer
@Hustlersambitionz Hustlersambitionz Hustlersambitionz left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

skip news topic-free-threading

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.

5 participants

@corona10 @mpage @eendebakpt @markshannon @Hustlersambitionz
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 01402520 — 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.