feat(runtime): gate node:dgram behind mod-dgram (binary size)#5163
Closed
proggeramlug wants to merge 1 commit into
Closed
feat(runtime): gate node:dgram behind mod-dgram (binary size)#5163proggeramlug wants to merge 1 commit into
mod-dgram (binary size)#5163proggeramlug wants to merge 1 commit into
Conversation
`node:dgram` (UDP sockets — `crate::dgram` + `crate::dgram_reactor`, ~43 KB incl. the `js_dgram_*` externs codegen emits direct calls to) is now compiled only when a program imports it. The compiler detects `module: "dgram"` in the HIR (a dgram namespace can only arise from the import) and forwards `perry-runtime/mod-dgram` to the auto-optimize build; a program that never uses dgram links none of it (hello-world −~0.1 MB). No speed change. This is the first instance of a general per-Node-module gating pattern: cfg the module impl + its `native_module_dispatch` arm + its gc root-scanner registration behind a `mod-<x>` feature, enabled from compile-time usage detection. dgram is detected via HIR (it's runtime-only, so absent from `native_module_imports`, which tracks only stdlib modules). The dgram dispatch arm + the gc_init `dgram_reactor` root-scanner registration are cfg-gated so the off build links cleanly; codegen only emits `js_dgram_*` calls for dgram programs, which get the feature on, so no dangling symbols.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First instance of a per-Node-module gating pattern:
node:dgram(UDP sockets —crate::dgram+crate::dgram_reactor, ~43 KB incl. thejs_dgram_*externs codegen emits direct calls to) is now compiled only when a program imports it.Result
hello-world drops ~0.1 MB (dgram off). A real dgram program (createSocket/bind/send/on-message) auto-enables the feature, links + runs correctly. No speed change — pure cfg gate.
How
mod-dgramcargo feature (indefault) gatescrate::dgram+crate::dgram_reactor, the("dgram", …)dispatch arm, and thegc_initdgram-reactor root-scanner registration.module: "dgram"in the HIR (a dgram namespace can only arise from importing it) →ctx.uses_dgram→ forwardsperry-runtime/mod-dgram+ cache-keys it. dgram is runtime-only, so it's not innative_module_imports(that set tracks onlyrequires_stdlibmodules) — HIR detection is the correct signal.js_dgram_*calls for dgram programs (which get the feature on), so the off build links cleanly with no dangling symbols (verified via auto-optimize link of both a dgram program and hello-world).The big remaining lever (de-coupling console/process from the monolithic
dispatch_native_module_methodso all dispatch-only modules dead-strip, ~400 KB) is a deeper refactor for a separate, supervised PR.