Skip to content
Closed
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
Fix unused function warning
  • Loading branch information
colesbury committed Jun 3, 2025
commit ce9232b8ab26869b1d33ab851f82708ec79ef555
2 changes: 2 additions & 0 deletions Objects/obmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ free_work_item(uintptr_t ptr, delayed_dealloc_cb cb, void *state)
}
}

#ifdef Py_GIL_DISABLED
static int
should_advance_qsbr(_PyThreadStateImpl *tstate, size_t size)
{
Expand All @@ -1159,6 +1160,7 @@ should_advance_qsbr(_PyThreadStateImpl *tstate, size_t size)
}
return 0;
}
Comment on lines +1146 to +1162

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need early return here?
It looks like it will be same eventually.

Suggested change
should_advance_qsbr(_PyThreadStateImpl *tstate, size_t size)
{
// If the deferred memory exceeds 1 MiB, we force an advance in the
// shared QSBR sequence number to limit excess memory usage.
static const size_t QSBR_DEFERRED_LIMIT = 1024 * 1024;
if (size > QSBR_DEFERRED_LIMIT) {
tstate->qsbr->memory_deferred = 0;
return 1;
}
tstate->qsbr->memory_deferred += size;
if (tstate->qsbr->memory_deferred > QSBR_DEFERRED_LIMIT) {
tstate->qsbr->memory_deferred = 0;
return 1;
}
return 0;
}
should_advance_qsbr(_PyThreadStateImpl *tstate, size_t size)
{
// If the deferred memory exceeds 1 MiB, we force an advance in the
// shared QSBR sequence number to limit excess memory usage.
static const size_t QSBR_DEFERRED_LIMIT = 1024 * 1024;
tstate->qsbr->memory_deferred += size;
if (tstate->qsbr->memory_deferred > QSBR_DEFERRED_LIMIT) {
tstate->qsbr->memory_deferred = 0;
return 1;
}
return 0;
}

#endif

static void
free_delayed(uintptr_t ptr, size_t size)
Expand Down