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-112087: Update list_get_item_ref to optimistically avoid locking#116353

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

Merged

Conversation

corona10
Copy link
Member

@corona10corona10 commentedMar 5, 2024
edited by bedevere-appbot
Loading

@corona10
Copy link
MemberAuthor

!buildbot nogil

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@corona10 for commiteda29bc 🤖

The command will test the builders whose names match following regular expression:nogil

The builders matched are:

  • AMD64 Ubuntu NoGIL Refleaks PR
  • x86-64 MacOS Intel ASAN NoGIL PR
  • ARM64 MacOS M1 Refleaks NoGIL PR
  • x86-64 MacOS Intel NoGIL PR
  • AMD64 Windows Server 2022 NoGIL PR
  • AMD64 Ubuntu NoGIL PR
  • ARM64 MacOS M1 NoGIL PR

@corona10corona10 marked this pull request as ready for reviewMarch 5, 2024 13:07
@corona10corona10 requested a review fromcolesburyMarch 5, 2024 13:07
@corona10
Copy link
MemberAuthor

!buildbot nogil

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@corona10 for commit9071dd4 🤖

The command will test the builders whose names match following regular expression:nogil

The builders matched are:

  • AMD64 Ubuntu NoGIL Refleaks PR
  • x86-64 MacOS Intel ASAN NoGIL PR
  • ARM64 MacOS M1 Refleaks NoGIL PR
  • x86-64 MacOS Intel NoGIL PR
  • AMD64 Windows Server 2022 NoGIL PR
  • AMD64 Ubuntu NoGIL PR
  • ARM64 MacOS M1 NoGIL PR

@corona10
Copy link
MemberAuthor

@colesbury

IIUC, This PR should be the last PR for#112087
Please let me know if I missed some parts.

if (ob_item == NULL) {
return NULL;
}
Py_ssize_t cap = _Py_atomic_load_ssize_relaxed(&op->allocated);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is okay for now, but we need to store the capacity at the start of theob_item allocation in the free-threaded build.

corona10 reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We may need to create a issue for tracking this.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's necessary for thread-safety so I think it's covered by#112087

corona10 reacted with thumbs up emoji
Copy link
MemberAuthor

@corona10corona10Mar 5, 2024
edited
Loading

Choose a reason for hiding this comment

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

By the way, we already store theop->allocated at theob_item allocation.
So adding assertion will be enough?
assert(cap != -1 && cap >= size);

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We currently store it in thePyListObject. We also need to store it in the same memory allocation as theob_item array, like a pre-header.

Here are some pointers to the relevant code in nogil-3.12:

The problem with the current code is that the list may be resized concurrently with the access. The bounds check may be stale. Putting the value of "allocated" as an immutable field avoids this problem.

corona10 reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Ah, I got it. I understood what you want to say. Let's handle it at a separate PR.

@corona10corona10 requested a review fromcolesburyMarch 5, 2024 15:34
corona10and others added2 commitsMarch 6, 2024 05:01
Co-authored-by: Sam Gross <colesbury@gmail.com>
@corona10corona10 requested a review fromcolesburyMarch 5, 2024 20:04
Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

This looks good to me. I think it's best to address the capacity/allocated changes in a separate PR.

corona10 reacted with thumbs up emoji
@corona10corona10 merged commitd2f1b0e intopython:mainMar 5, 2024
@corona10corona10 deleted the gh-112087-single-item-locked branchMarch 5, 2024 23:21
adorilson pushed a commit to adorilson/cpython that referenced this pull requestMar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull requestApr 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@colesburycolesburycolesbury approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@corona10@bedevere-bot@colesbury

[8]ページ先頭

©2009-2025 Movatter.jp