deno
1eebdde5 - perf(core): reduce native callback snapshot overhead (#35121)

Commit
72 days ago
perf(core): reduce native callback snapshot overhead (#35121) ## Summary This reduces startup snapshot deserialization overhead from native callback function shapes. The stack does three things: - creates native accessor callbacks with `ConstructorBehavior::Throw`, avoiding useless accessor `.prototype` graphs - uses direct V8 functions for snapshotted top-level ops instead of FunctionTemplates by default - adds an explicit `#[op2(constructable)]` opt-in for top-level ops that must preserve a public JS function prototype/constructor shape ## Snapshot Size Measured with debug builds: ```sh deno run --v8-flags=--profile-deserialization empty.js ``` Summing the three `Deserializing ... (N bytes)` rows, excluding the final `Serializing to ...` row: | build | total deserialized bytes | delta | | --- | ---: | ---: | | `main@upstream` | 4,768,928 | - | | this PR | 4,466,352 | -302,576 bytes | That is a 6.34% reduction in the deserialized snapshot byte total for this measurement. Breakdown: | section | `main@upstream` | this PR | delta | | --- | ---: | ---: | ---: | | read-only space | 991,144 | 991,144 | 0 | | isolate | 2,561,136 | 2,518,976 | -42,160 | | context #2 | 1,216,648 | 956,232 | -260,416 | Saved local binaries used for the comparison: - `/tmp/deno-accessor-snapshot-binaries/deno-baseline-main-upstream` - `/tmp/deno-accessor-snapshot-binaries/deno-current-constructable-stack` ## Validation ```sh cargo test -p deno_core_testing resource_test cargo test -p deno_ops op2::tests cargo check -p deno_core -p deno_core_testing -p deno_ops ```
Author
Parents
Loading