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 — Describe GC for free-threaded build in the GC design doc by colesbury · Pull Request #1263 · python/devguide

Conversation

@colesbury

@colesbury colesbury commented Jan 24, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This updates the garbage collector design page to describe the implementation of the GC for Python 3.13's free-threaded build.


📚 Documentation preview 📚: https://cpython-devguide--1263.org.readthedocs.build/

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
@colesbury
Describe GC for free-threaded build in the GC design doc
42fbbc4
@colesbury
colesbury requested a review from pablogsal January 24, 2024 21:48
@colesbury

colesbury commented Jan 24, 2024

Copy link
Copy Markdown
Contributor Author

I think there's still some more I should add to the document, but I wanted to first get feedback on the general approach of mixing the descriptions of the two designs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@colesbury colesbury mentioned this pull request Jan 24, 2024
gh-112529: Implement GC for free-threaded builds python/cpython#114262
Merged
ezio-melotti
ezio-melotti reviewed Jan 24, 2024
View reviewed changes
Comment thread internals/garbage-collector.rst Outdated
Comment on lines +56 to +60
CPython contains two GC implementations starting in version 3.13. One implementation
is used in the default build and relies on the global interpreter lock for
thread-safety. The other implementation is used in the free-threaded build. Both
implementations use the same basic algorithms, but operate on different data
structures.

@ezio-melotti ezio-melotti Jan 24, 2024

Copy link
Copy Markdown
Member

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.

This could use a list to make the difference between the two builds stand out more, and to mirror the two sections below. Something like:

Suggested change
CPython contains two GC implementations starting in version 3.13. One implementation
is used in the default build and relies on the global interpreter lock for
thread-safety. The other implementation is used in the free-threaded build. Both
implementations use the same basic algorithms, but operate on different data
structures.
Starting in version 3.13, CPython contains two GC implementations starting in version 3.13:
* the default build implementation relies on the global interpreter lock for
thread-safety;
* the free-threaded build ...
Both implementations use the same basic algorithms, but operate on different data
structures.

Here you could also add link to :term:s like GC and GIL using intersphinx.

Sorry, something went wrong.

Uh oh!

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

All reactions

@colesbury colesbury Jan 25, 2024

Copy link
Copy Markdown
Contributor 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 added a section at the end to summarize the differences between the two implementations. I was hesitant to add it here because we introduce a number of the concepts later on in the document.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread internals/garbage-collector.rst
object -----> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ \
| ob_tid | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
| pad | ob_mutex | ob_gc_bits | ob_ref_local | |

@ezio-melotti ezio-melotti Jan 24, 2024

Copy link
Copy Markdown
Member

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.

Do each --+ mark one bit? If so, ob_tid, ob_ref_shared and *ob_type are 2 bytes (16 bits), but this fields don't seem to match the description, since ob_gc_bits takes ~4 bits and ob_ref_local 6.

Sorry, something went wrong.

Uh oh!

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

All reactions

@colesbury colesbury Jan 24, 2024

Copy link
Copy Markdown
Contributor 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.

No -- each row is 64-bits (on 64-bit platforms), but otherwise the fields pad, ob_mutex, ob_gc_bits, and ob_ref_local are not to scale.

I'm not sure what to do about this. It'd be nice if the diagram were to scale, but I think that would require the diagram to be very wide -- ob_gc_bits is only 1 byte, but 10 characters.

Sorry, something went wrong.

Uh oh!

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

ezio-melotti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@ezio-melotti ezio-melotti Jan 24, 2024

Copy link
Copy Markdown
Member

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.

It might be enough to just add a note after the diagram saying that e.g. "Note that pad, ob_mutex, ob_gc_bits, and ob_ref_local are not to scale and take X, Y, Z, W bytes respectively."

Another option, if those 4 values are related, could be to use a single name (like "free-threaded info bytes") and then break that down afterwards, either in text or with a separate "zoomed in" diagram.

Sorry, something went wrong.

Uh oh!

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

colesbury reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread internals/garbage-collector.rst Resolved

Uh oh!

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

Comment thread internals/garbage-collector.rst Resolved

Uh oh!

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

colesbury and others added 2 commits January 25, 2024 13:59
@colesbury @ezio-melotti
Apply suggestions from code review
be769e7
Co-authored-by: Ezio Melotti <[email protected]>
@colesbury
Add 'Differences between GC implementations' section
c7a44c5
@ambv

ambv commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

Let's get this in and iterate on the live document.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@ambv
ambv merged commit fe3722d into python:main Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ezio-melotti ezio-melotti ezio-melotti left review comments
@pablogsal pablogsal Awaiting requested review from pablogsal

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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

@colesbury @ambv @ezio-melotti
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.