perf: speed up V8 snapshot deserialization#1977
Open
bartlomieju wants to merge 1 commit into
Open
Conversation
Two optimizations targeting the hot deserialization loop: 1. Skip write barriers during non-user-code deserialization. During startup/shared-heap/context deserialization all objects are allocated in old space and incremental marking is not active, so every write barrier is a guaranteed no-op — but each still pays ~8 instructions of MemoryChunk lookups and branch checks per slot write. 2. Compile out trace_deserialization flag checks from the hot bytecode dispatch loop (31 occurrences). Replace with TRACE_DESER macros that compile to nothing unless V8_ENABLE_TRACE_DESERIALIZATION is defined, reducing icache pressure in ReadSingleBytecodeData.
5f136f0 to
deced33
Compare
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
trace_deserializationflag checks. 31if (v8_flags.trace_deserialization)checks in the bytecode dispatch loop bloatReadSingleBytecodeDataand hurt icache. Replaced withTRACE_DESERmacros that compile to nothing unlessV8_ENABLE_TRACE_DESERIALIZATIONis defined.Estimated combined improvement: ~15-25% of total snapshot deserialization time (~2-3ms out of ~11ms on Apple Silicon).
Test plan
cd v8 && git am -3 ../patches/0004-*.patchdeno run --v8-flags=--profile-deserialization empty.jsbefore/after