Reduce v2 self-host memory#27366
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c229f3f46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fn (b &Builder) should_prune_native_backend_modules(arch pref.Arch) bool { | ||
| return b.pref.single_backend || arch == .arm64 | ||
| } |
There was a problem hiding this comment.
Limit ARM64 backend pruning to compiler backend files
This makes every ARM64 native build populate skip_modules for module basenames like x64, c, v, eval, and cleanc. The SSA builder’s filter only checks b.cur_module in b.skip_modules (not the file path), so any reachable user/imported module with one of those names is dropped entirely on ARM64 even though it is not an unused compiler backend. This was previously gated by --single-backend; the new arch == .arm64 default can produce missing functions or broken output for ordinary ARM64 builds that happen to use one of these module names.
Useful? React with 👍 / 👎.
Summary
Impact
ARM64 v2 self-host peak RSS drops from ~9.25 GB to ~4.12 GB on:
./v2 --no-parallel -nocache -gc none -backend arm64 -O0 -o /tmp/v2_mem_final v2.v.Cleanc remains heavier on this branch. Current measurement:
./v2 --no-parallel -nocache -gc none -backend cleanc -O0 -o /tmp/v2_mem_final_cleanc v2.vThis does not reach the <1 GB target; remaining memory is dominated by transformed AST + backend-specific generated representation overlap and should be handled by the flat-AST/direct-lowering work.
Validation
../../v -gc none -cc cc -o v2 v2.v./v -gc none vlib/v2/types/checker_test.v./v -gc none vlib/v2/transformer/propagate_types_from_flat_test.v./v -gc none vlib/v2/transformer/transformer_v2_darwin_test.v./v -gc none vlib/v2/abi/abi_test.v./v -gc none vlib/v2/builder/target_os_test.vcd cmd/v2 && sh test_all.sh