perf: lazy-load FFI, KV, cron, signals, and fs_events modules#33324
Closed
bartlomieju wants to merge 1 commit intomainfrom
Closed
perf: lazy-load FFI, KV, cron, signals, and fs_events modules#33324bartlomieju wants to merge 1 commit intomainfrom
bartlomieju wants to merge 1 commit intomainfrom
Conversation
Move rarely-used Deno API modules from eager evaluation to lazy loading using the existing createLazyLoader/propWritableLazyLoaded pattern. These modules are now only evaluated when their APIs are first accessed, reducing snapshot heap size. Lazy-loaded modules: - ext:deno_ffi/00_ffi.js (Deno.dlopen, UnsafeCallback, etc.) - ext:deno_kv/01_db.ts (Deno.openKv, Kv, etc.) - ext:deno_cron/01_cron.ts (Deno.cron) - ext:deno_os/40_signals.js (Deno.addSignalListener, etc.) - ext:runtime/40_fs_events.js (Deno.watchFs) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
Not worth complexity for now |
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.
Summary
Move rarely-used Deno API modules from eager evaluation to lazy loading using the existing
createLazyLoader/propWritableLazyLoadedpattern (same as WebGPU and QUIC). These modules are now only evaluated when their APIs are first accessed, reducing snapshot heap size.Lazy-loaded modules:
ext:deno_ffi/00_ffi.js—Deno.dlopen,UnsafeCallback,UnsafePointer,UnsafePointerView,UnsafeFnPointerext:deno_kv/01_db.ts—Deno.openKv,Kv,KvU64,KvListIterator,AtomicOperationext:deno_cron/01_cron.ts—Deno.cronext:deno_os/40_signals.js—Deno.addSignalListener,Deno.removeSignalListenerext:runtime/40_fs_events.js—Deno.watchFsImpact: ~430 fewer V8 objects deserialized at startup, ~51 fewer functions in the snapshot. Modest for these small modules, but establishes the pattern for larger lazy-loading efforts (node compat layer via
import defer).Context
Profiling showed Deno deserializes 84,780 V8 objects at startup vs Node's 26,326 (3.2x). The bulk comes from eagerly evaluating all polyfill modules. This PR applies lazy loading to the low-hanging fruit — modules that are rarely needed at startup. The larger reduction will come from deferring the node compat layer once
import defersupport lands (#32360).Test plan
deno run,deno evalwork correctlyDeno.watchFsworks (lazy-loaded on access)Deno.addSignalListenerworks (lazy-loaded on access)🤖 Generated with Claude Code