mirror of
https://github.com/python/cpython.git
synced 2026-05-06 12:49:07 -04:00
GH-148726: Add heap_size to generational GC (#149195)
This commit is contained in:
+2
-1
@@ -601,6 +601,7 @@ PyDoc_STRVAR(_remote_debugging_GCMonitor_get_gc_stats__doc__,
|
||||
" - collected: Total number of collected objects.\n"
|
||||
" - uncollectable: Total number of uncollectable objects.\n"
|
||||
" - candidates: Total objects considered and traversed.\n"
|
||||
" - heap_size: number of live objects.\n"
|
||||
" - duration: Total collection time, in seconds.\n"
|
||||
"\n"
|
||||
"Raises:\n"
|
||||
@@ -1563,4 +1564,4 @@ skip_optional_kwonly:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=1151e58683dab9f4 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=36674f4cb8a653f3 input=a9049054013a1b77]*/
|
||||
|
||||
@@ -53,6 +53,7 @@ read_gc_stats(struct gc_stats *stats, int64_t iid, PyObject *result,
|
||||
SET_FIELD(PyLong_FromSsize_t, items->collected);
|
||||
SET_FIELD(PyLong_FromSsize_t, items->uncollectable);
|
||||
SET_FIELD(PyLong_FromSsize_t, items->candidates);
|
||||
SET_FIELD(PyLong_FromSsize_t, items->heap_size);
|
||||
|
||||
SET_FIELD(PyFloat_FromDouble, items->duration);
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ static PyStructSequence_Field GCStatsInfo_fields[] = {
|
||||
{"collected", "Total number of collected objects"},
|
||||
{"uncollectable", "Total number of uncollectable objects"},
|
||||
{"candidates", "Total objects considered and traversed"},
|
||||
{"heap_size", "Number of live objects"},
|
||||
{"duration", "Total collection time, in seconds"},
|
||||
{NULL}
|
||||
};
|
||||
@@ -151,7 +152,7 @@ PyStructSequence_Desc GCStatsInfo_desc = {
|
||||
"_remote_debugging.GCStatsInfo",
|
||||
"Information about a garbage collector stats sample",
|
||||
GCStatsInfo_fields,
|
||||
9
|
||||
10
|
||||
};
|
||||
|
||||
/* ============================================================================
|
||||
@@ -1225,6 +1226,7 @@ Returns:
|
||||
- collected: Total number of collected objects.
|
||||
- uncollectable: Total number of uncollectable objects.
|
||||
- candidates: Total objects considered and traversed.
|
||||
- heap_size: number of live objects.
|
||||
- duration: Total collection time, in seconds.
|
||||
|
||||
Raises:
|
||||
@@ -1235,7 +1237,7 @@ Raises:
|
||||
static PyObject *
|
||||
_remote_debugging_GCMonitor_get_gc_stats_impl(GCMonitorObject *self,
|
||||
int all_interpreters)
|
||||
/*[clinic end generated code: output=f73f365725224f7a input=09e647719c65f9e4]*/
|
||||
/*[clinic end generated code: output=f73f365725224f7a input=12f7c1a288cf2741]*/
|
||||
{
|
||||
RemoteDebuggingState *st = RemoteDebugging_GetStateFromType(Py_TYPE(self));
|
||||
return get_gc_stats(&self->offsets, all_interpreters, st->GCStatsInfo_Type);
|
||||
|
||||
@@ -2731,8 +2731,7 @@ has_deferred_refcount(PyObject *self, PyObject *op)
|
||||
static PyObject *
|
||||
get_tracked_heap_size(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
// Generational GC doesn't track heap_size, return -1.
|
||||
return PyLong_FromInt64(-1);
|
||||
return PyLong_FromInt64(PyInterpreterState_Get()->gc.heap_size);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
||||
Reference in New Issue
Block a user