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-113884: Refactor `queue.SimpleQueue` to use a ring buffer to store items by mpage · Pull Request #114259 · python/cpython

Conversation

@mpage

@mpage mpage commented Jan 18, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Using a ring buffer instead of a Python list will simplify the process of making queue.SimpleQueue thread-safe in free-threaded builds. The ring buffer implementation has no places where critical sections may be released.

  • Issue: Make queue.SimpleQueue thread-safe in --disable-gil builds #113884

Sorry, something went wrong.

Uh oh!

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

All reactions
@mpage
Refactor queue.SimpleQueue to use a ring buffer to store items
b6c1407
Using a ring buffer instead of a Python list will simplify the
process of making `queue.SimpleQueue` thread-safe in free-threaded
builds. The ring buffer implementation has no places where critical
sections may be released.
@bedevere-app bedevere-app Bot mentioned this pull request Jan 18, 2024
Make queue.SimpleQueue thread-safe in --disable-gil builds #113884
Closed
@blurb-it
📜🤖 Added by blurb_it.
1ec875b
@mpage
mpage marked this pull request as ready for review January 18, 2024 20:59
@mpage
mpage requested a review from rhettinger as a code owner January 18, 2024 20:59
@bedevere-app bedevere-app Bot added the awaiting review label Jan 18, 2024
@mpage mpage mentioned this pull request Jan 18, 2024
gh-113884: Make queue.SimpleQueue thread-safe in --disable-gil builds #114161
Merged
@colesbury
colesbury requested a review from erlend-aasland January 18, 2024 21:07
colesbury
colesbury approved these changes Jan 18, 2024
View reviewed changes

@colesbury colesbury 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.

@erlend-aasland, would you be able to review this?

Sorry, something went wrong.

Uh oh!

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

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Jan 18, 2024
@erlend-aasland erlend-aasland self-assigned this Jan 18, 2024
erlend-aasland
erlend-aasland reviewed Jan 18, 2024
View reviewed changes

@erlend-aasland erlend-aasland 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.

Thanks for doing the refactoring first!

Sorry, something went wrong.

Uh oh!

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

mpage reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

Comment thread Modules/_queuemodule.c Resolved

Uh oh!

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

mpage added 5 commits January 18, 2024 16:49
@mpage
Use a plain decref when clearing items
350306d
@mpage
Update comment for retrieving items from the ringbuf
63fa483
@mpage
Explicitly discard return value when shrinking ringbuf
ead8814
@mpage
Assert valid occupancy when adding to ringbuf
7e54296
@mpage
Add RingBuf APIs for empty/length
49956aa
To help reduce future churn.
@rhettinger
rhettinger removed their request for review January 19, 2024 04:12
@mpage

mpage commented Jan 19, 2024

Copy link
Copy Markdown
Contributor Author

@erlend-aasland - I think I've addressed all of your comments. Would you please take another look?

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

erlend-aasland added 2 commits January 19, 2024 12:50
@erlend-aasland
NEWS is not needed; this is an internal change only
c472447
@erlend-aasland
Inline RingBuf_IsEmpty logic
9c0a58c
@erlend-aasland erlend-aasland added the skip news label Jan 19, 2024
@erlend-aasland
erlend-aasland enabled auto-merge (squash) January 19, 2024 11:56
@erlend-aasland

erlend-aasland commented Jan 19, 2024

Copy link
Copy Markdown
Contributor

Thanks a lot, @mpage and @colesbury 🙏

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland
erlend-aasland merged commit 28eacf2 into python:main Jan 19, 2024
@bedevere-app bedevere-app Bot removed the awaiting core review label Jan 19, 2024
@mpage
mpage deleted the gh-113884-simplequeue-ringbuf-refactor branch January 19, 2024 17:38
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
@mpage @kulikjak
pythongh-113884: Refactor queue.SimpleQueue to use a ring buffer to…
208f0a7
… store items (python#114259)

Use a ring buffer instead of a Python list in order to simplify the
process of making queue.SimpleQueue thread-safe in free-threaded
builds. The ring buffer implementation has no places where critical
sections may be released.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@mpage @aisk
pythongh-113884: Refactor queue.SimpleQueue to use a ring buffer to…
fd8141d
… store items (python#114259)

Use a ring buffer instead of a Python list in order to simplify the
process of making queue.SimpleQueue thread-safe in free-threaded
builds. The ring buffer implementation has no places where critical
sections may be released.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@mpage @Glyphack
pythongh-113884: Refactor queue.SimpleQueue to use a ring buffer to…
25a152f
… store items (python#114259)

Use a ring buffer instead of a Python list in order to simplify the
process of making queue.SimpleQueue thread-safe in free-threaded
builds. The ring buffer implementation has no places where critical
sections may be released.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@erlend-aasland erlend-aasland erlend-aasland left review comments
@colesbury colesbury colesbury approved these changes

Uh oh!

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

Assignees

@erlend-aasland erlend-aasland

Labels

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.

3 participants

@mpage @erlend-aasland @colesbury
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.