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

Appearance settings

Incremental "mark alive" pass for cyclic GC #126511

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add WITH_GC_MARK_ALIVE and WITH_GC_TIMING_STATS
  • Loading branch information
nascheme committed Oct 26, 2024
commit 12ceba2e6ed365b1204141a9121b4adb6232fcd8
53 changes: 45 additions & 8 deletions 53 Include/internal/pycore_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,43 @@ struct gc_generation_stats {
Py_ssize_t uncollectable;
};

// if true, enable GC timing statistics
#define WITH_GC_TIMING_STATS 1

#if WITH_GC_TIMING_STATS

#define QUANTILE_COUNT 5
#define MARKER_COUNT (QUANTILE_COUNT * 3 + 2)

typedef struct {
double q[MARKER_COUNT];
double dn[MARKER_COUNT];
double np[MARKER_COUNT];
int n[MARKER_COUNT];
int count;
double max;
} p2_engine;

struct gc_timing_state {
/* timing statistics computed by P^2 algorithm */
p2_engine auto_all; // timing for all automatic collections
p2_engine auto_full; // timing for full (gen2) automatic collections
/* Total time spent inside cyclic GC */
PyTime_t gc_total_time;
/* Time spent inside incremental mark part of cyclic GC */
PyTime_t gc_mark_time;
/* Maximum GC pause time */
PyTime_t gc_max_pause;
/* Total number of times GC was run */
PyTime_t gc_runs;
};
#endif // WITH_GC_TIMING_STATS


// if true, enable the GC mark alive feature
#define WITH_GC_MARK_ALIVE 1

#if WITH_GC_MARK_ALIVE
struct gc_mark_state {
/* Objects in oldest generation that have be determined to be alive */
PyGC_Head old_alive;
Expand All @@ -297,15 +334,9 @@ struct gc_mark_state {
int mark_steps;
/* Number of steps available before full collection */
int mark_steps_total;
/* Total time spent inside cyclic GC */
PyTime_t gc_total_time;
/* Time spent inside incremental mark part of cyclic GC */
PyTime_t gc_mark_time;
/* Maximum GC pause time */
PyTime_t gc_max_pause;
/* Total number of times GC was run */
PyTime_t gc_runs;
};
#endif // WITH_GC_MARK_ALIVE


struct _gc_runtime_state {
/* List of objects that still need to be cleaned up, singly linked
Expand All @@ -329,8 +360,14 @@ struct _gc_runtime_state {
PyObject *garbage;
/* a list of callbacks to be invoked when collection is performed */
PyObject *callbacks;
#if WITH_GC_MARK_ALIVE
/* state for the incremental "mark alive" logic */
struct gc_mark_state mark_state;
#endif
#if WITH_GC_TIMING_STATS
/* state for GC timing statistics */
struct gc_timing_state timing_state;
#endif

/* This is the number of objects that survived the last full
collection. It approximates the number of long lived objects
Expand Down
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.