Skip to content

GH-126491: GC: Mark objects reachable from roots before doing cycle collection#126502

Merged
markshannon merged 35 commits intopython:mainfrom
faster-cpython:mark-first-gc
Nov 18, 2024
Merged

GH-126491: GC: Mark objects reachable from roots before doing cycle collection#126502
markshannon merged 35 commits intopython:mainfrom
faster-cpython:mark-first-gc

Conversation

@markshannon
Copy link
Member

@markshannon markshannon commented Nov 6, 2024

This PR:

  • Performs a marking step before the incremental cycle collection
  • Rescans the stack before each increment
  • Removes lazy dict tracking as the lazy tracking optimization no longer pays off.

Performance is excellent. Speedup is 4%, with a 100% speedup on one GC benchmark.

Stats show the GC is run more frequently and collects more objects, but does only ~60% of the work.

This PR also:

  • Makes detaching an object's dict a bit more robust in case of a memory error.
  • Increases the threshold in a GC test. This test is to check for uncontrolled growth, so the exact threshold doesn't matter.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants