Skip to content

perf(generator): don't collect garbage while generating the task graph - #1075

Closed
jcristau wants to merge 1 commit into
taskcluster:mainfrom
jcristau:perf-generator-gc
Closed

jcristau wants to merge 1 commit into
taskcluster:mainfrom
jcristau:perf-generator-gc

Conversation

@jcristau

@jcristau jcristau commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Generating a task graph creates millions of objects that stay alive until the end, so each collection traverses an ever growing heap without freeing anything. Disable the garbage collector while running each phase of the generator, restoring its previous state before yielding to the caller, and while loading a TaskGraph from JSON.

Children loading kinds inherit the disabled collector, which also keeps them from writing to every page they share with the parent.

Re-enabling the collector in children, or only freezing the heap after loading kinds and each phase (gc.freeze), measured slower in Firefox's taskgraph, with peak memory the same in all cases.

Generating a task graph creates millions of objects that stay alive
until the end, so each collection traverses an ever growing heap
without freeing anything. Disable the garbage collector while running
each phase of the generator, restoring its previous state before
yielding to the caller, and while loading a TaskGraph from JSON.

Children loading kinds inherit the disabled collector, which also keeps
them from writing to every page they share with the parent.

Re-enabling the collector in children, or only freezing the heap after
loading kinds and each phase (gc.freeze), measured slower in Firefox's
taskgraph, with peak memory the same in all cases.
@jcristau
jcristau requested a review from a team as a code owner October 8, 2026 14:22
@jcristau
jcristau requested a review from bhearsum October 8, 2026 14:22
@jcristau
jcristau marked this pull request as draft October 8, 2026 14:33
@jcristau jcristau closed this Oct 8, 2026
@jcristau
jcristau deleted the perf-generator-gc branch October 8, 2026 14:36
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.

1 participant