Skip to content
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

julia_gc: fix detection of already scanned root task #5726

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ static jl_datatype_t * DatatypeGapObj;
static jl_datatype_t * DatatypeSmallBag;
static jl_datatype_t * DatatypeLargeBag;

static jl_task_t * ScannedRootTask;

static size_t MaxPoolObjSize;
static int FullGC;
static UInt StartTime, TotalTime;
Expand Down Expand Up @@ -565,6 +567,8 @@ static void GapRootScanner(int full)
jl_ptls_t ptls = jl_get_ptls_states();
jl_task_t * task = (jl_task_t *)jl_get_current_task();

ScannedRootTask = task;

// We figure out the end of the stack from the current task. While
// `stack_bottom` is passed to InitBags(), we cannot use that if
// current_task != root_task.
Expand Down Expand Up @@ -615,9 +619,8 @@ static void GapRootScanner(int full)
// Julia callback
static void GapTaskScanner(jl_task_t * task, int root_task)
{
// If it is the current task, it has been scanned by GapRootScanner()
// already.
if (task == (jl_task_t *)jl_get_current_task())
// If this task has been scanned by GapRootScanner() already, skip it
if (task == ScannedRootTask)
return;

int rescan = 1;
Expand Down Expand Up @@ -689,6 +692,7 @@ static void PreGCHook(int full)
// Julia callback
static void PostGCHook(int full)
{
ScannedRootTask = 0;
TotalTime += SyTime() - StartTime;
#ifdef COLLECT_MARK_CACHE_STATS
/* printf("\n>>>Attempts: %ld\nHit rate: %lf\nCollision rate: %lf\n",
Expand Down
Loading