Skip to content

Add API to disable full collections#61087

Merged
gbaraldi merged 1 commit intomasterfrom
gb/disable-full-collectiin
Feb 26, 2026
Merged

Add API to disable full collections#61087
gbaraldi merged 1 commit intomasterfrom
gb/disable-full-collectiin

Conversation

@gbaraldi
Copy link
Member

Keeping this a ccall before adding a julia level API so we can back out if wanted later

@nsajko nsajko added the GC Garbage collector label Feb 19, 2026
@gbaraldi gbaraldi requested review from topolarity and removed request for d-netto, qinsoon and udesou February 19, 2026 14:54
@topolarity topolarity added backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13 labels Feb 19, 2026
@topolarity
Copy link
Member

Despite being featureful, this is a low-risk change that we'd like to have available on 1.12 so I have marked it for backport.

@tz-lom
Copy link

tz-lom commented Feb 19, 2026

I wonder why you decided to give ability to disable forced FULL GCs instead of just providing a tuning knob to tune when full GC is forced?

gc_record_full_sweep_reason(FULL_SWEEP_REASON_FORCED_FULL_SWEEP);
}
if (gc_disable_auto_full_sweep && collection != JL_GC_FULL) {
sweep_full = 0;
Copy link

@tz-lom tz-lom Feb 19, 2026

Choose a reason for hiding this comment

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

please take a note - we are monitoring content of gc_record_full_sweep_reason and gc_num during pre/post gc hooks to understand what runtime decided to do.
please make sure that we would be able to reconstruct that FULL GC scheduled but cancelled

Copy link

Choose a reason for hiding this comment

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

@gbaraldi
Hi Gabriel
I've noticed that you merged this PR without answering question above.
can you reply to that one?
To illustrate issue I've prepared small repo with two demo files that I've collected:
https://github.com/tz-lom/gctest

you can see that with auto_full_collection enabled it is impossible to tell that it FULL GC was not done (except from timing which is much lower, but that is not reliable source of knowledge).
Do I miss something or can I distinguish it differently?

On top of that, I think it would be nice to expose this interface to Julia too, we are controlling GC from Julia most of the time (as GC strategy varies per interface call)

Please reply

Copy link
Member Author

@gbaraldi gbaraldi Feb 27, 2026

Choose a reason for hiding this comment

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

Well, if you disabled full sweeps manually I guess you can query that for your instrumentation. (It's pretty tricky because the main heuristics always change the next GC. Not the current one). Also hypothetically, knowing that the GC would've run a full sweep but didn't because it was manually disabled can be useful to figure out if, when possible, a manual full GC should be ran.

As for the API, I'm slightly wary about adding a Julia level API for this to be back ported. If we like this feature we can add it for non released versions of Julia, but on 1.12 I feel more comfortable keeping this something one has to look for and ccall. In case we decide to go for a different API

@gbaraldi
Copy link
Member Author

I wonder why you decided to give ability to disable forced FULL GCs instead of just providing a tuning knob to tune when full GC is forced?

Not sure exactly what you mean. This makes it so if the user manually asks for a full GC we still do it, we just don't do it automatically. I don't believe exposing any tuning knobs here is a good idea.

@tz-lom
Copy link

tz-lom commented Feb 19, 2026

I wonder why you decided to give ability to disable forced FULL GCs instead of just providing a tuning knob to tune when full GC is forced?

Not sure exactly what you mean. This makes it so if the user manually asks for a full GC we still do it, we just don't do it automatically. I don't believe exposing any tuning knobs here is a good idea.

I meant that there are two constants to control when Full GC is forced, instead of a flag to opt-out from full GC it could be just variable instead of hardcoded constant.
On a second consideration indeed this approach is more generic across different implementations of GC so it is probably better.

@KristofferC KristofferC mentioned this pull request Feb 25, 2026
36 tasks
@gbaraldi gbaraldi merged commit 370a2a0 into master Feb 26, 2026
12 checks passed
@gbaraldi gbaraldi deleted the gb/disable-full-collectiin branch February 26, 2026 20:25
KristofferC pushed a commit that referenced this pull request Mar 3, 2026
Keeping this a ccall before adding a julia level API so we can back out
if wanted later

(cherry picked from commit 370a2a0)
KristofferC pushed a commit that referenced this pull request Mar 3, 2026
Keeping this a ccall before adding a julia level API so we can back out
if wanted later

(cherry picked from commit 370a2a0)
@KristofferC KristofferC mentioned this pull request Mar 3, 2026
56 tasks
topolarity pushed a commit that referenced this pull request Mar 3, 2026
Keeping this a ccall before adding a julia level API so we can back out
if wanted later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13 GC Garbage collector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants