rework build system memory allocations #20603
Labels
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
bug
Observed behavior contradicts documented or intended behavior
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
zig build system
std.Build, the build runner, `zig build` subcommand, package management
Milestone
Extracted from #20580.
Zig version:
0.14.0-dev.283+1d20ff11d
Currently, the build runner sets up a thread-safe arena backed by page allocation and then uses it for everything. This made sense when the build runner was a short-lived process, but now that the
--watch
feature is introduced, there is a cyclical component that needs to manage resources more sustainably. As it stands, a little bit of memory leaks with every detected file system update.The goal is to move to the following scheme:
b.allocator
should be removed in order to audit all allocations. This will cause a lot of breakage in user scripts, unfortunately, but it needs to be done so that it can be replaced withb.graph.arena
for the single-threaded configure-phase allocations, or agpa
parameter passed to make() - and in the latter case it needs to have memory management logic added.After completing the rework, let's use leak detection to make sure there are no more obvious leaks for common
--watch
workflows. The typical workflow to quit--watch
is Ctrl+C, so some debugging trick will be needed to triggergpa.deinit()
.Related:
The text was updated successfully, but these errors were encountered: