Skip to content

compiler: preserve task starts during trimming#61499

Open
quinnj wants to merge 2 commits intomasterfrom
codex/task-trim-rooting-main
Open

compiler: preserve task starts during trimming#61499
quinnj wants to merge 2 commits intomasterfrom
codex/task-trim-rooting-main

Conversation

@quinnj
Copy link
Copy Markdown
Member

@quinnj quinnj commented Apr 4, 2026

Teach trim reachability to treat task creation as a deferred callback edge so task entry thunks survive trimming, and add verifier and trimming coverage for concrete and unresolved task starts.

An example trim-compile test where the proposed changes here "fix" rooting the Task code is: https://github.com/JuliaServices/Reseau.jl/blob/main/test/tls_trim_safe.jl#L43 (i.e. we can remove the entrypoint rooting and the Task code still survives trimming).

I'm working on some additional higher-level HTTP trim tests in this PR, but need to massage unrelated verifier errors first (getting close). I've confirmed in some local, lower-level server/client tests that these changes also fix things.

DISLCAIMER: I'm not familiar with this code at all and heavily relied on codex AI/LLM to propose the fix, so apologies if this is way off or not the direction we want to go. At least from the little I do understand, it seems reasonable to key off of jl_new_task, but I'm not sure if there are other entrypoints/Task-related intrinsics we'd still be missing.

quinnj and others added 2 commits April 4, 2026 16:42
Teach trim reachability to treat task creation as a deferred callback edge so task entry thunks survive trimming, and add verifier and trimming coverage for concrete and unresolved task starts.

Co-authored-by: OpenAI Codex <codex@openai.com>
(cherry picked from commit 4833746c443d83829ce134ac9279b349fd9cc38d)
Switch the SecretBuffer GC-shred warning away from structured logging so the finalizer task does not pull the logging stack into trim verification.

Co-authored-by: OpenAI Codex <codex@openai.com>
Comment thread base/secretbuffer.jl
end

function final_shred!(s::SecretBuffer)
!isshredded(s) && @async @warn("a SecretBuffer was `shred!`ed by the GC; use `shred!` manually after use to minimize exposure.")
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.

These drive by changes aren't great. This should either go in a different PR or to the juliac.jl list of pirate fixes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, this just caused the tests to fail w/ the Task fixes because it was now flagging the @warn as non-trim-compile-able. So you're saying we should do that fix first in a separate PR and then rebase this off that?

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.

Yes, this should be a separate PR

@gbaraldi gbaraldi requested a review from topolarity April 6, 2026 16:22
@vchuravy
Copy link
Copy Markdown
Member

vchuravy commented Apr 6, 2026

x-ref: #58014 and #59221

The former is about the handling of finalizers (and Tasks were discussed) and the latter is a more principled approach of teaching inference about Tasks and their properties, it's a much larger change, but I think the change in abstract_eval_task_builtin would cover the handling of trimming.

@quinnj
Copy link
Copy Markdown
Member Author

quinnj commented Apr 6, 2026

Yeah, if #59221 will get in, that certainly seems like the best way to fix (+ all the other benefits!).

@quinnj
Copy link
Copy Markdown
Member Author

quinnj commented Apr 30, 2026

Bump; I would really love to have Tasks trim-compileable, whether its with this approach or another. Would this be a good triage discussion topic?

@oscardssmith
Copy link
Copy Markdown
Member

triage is probably the wrong audience, but agreed that we should figure out how to do this

@topolarity
Copy link
Copy Markdown
Member

I'm a bit reluctant to merge dedicated --trim support for Tasks before #59221, but it might be possible to accomplish this (at least as a band-aid solution) via a similar @cfunction hack to what we have in libuv.jl

BTW Task support (and multi-threading in general) is on my radar for --trim for 1.14 (#61319), but it may be a couple of months before that sweep starts in earnest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants