perf(native): avoid zeroing large shmem modules array - #1966
Merged
Conversation
When creating native backend shmem, zero the crash context only up to modules[]. This initializes the header, configuration, paths, platform state, and module count that must start from zero before a crash. Leave modules[] uninitialized during startup. It is the multi-megabyte tail of the shmem crash context, and crash handling treats it as valid only up to module_count before filling it. Add a unit test that verifies the initialization boundary: the byte before modules[] is zeroed, while modules[] itself keeps its previous contents. See: #1852
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1966 +/- ##
==========================================
+ Coverage 76.15% 76.18% +0.02%
==========================================
Files 94 94
Lines 22216 22222 +6
Branches 3941 3942 +1
==========================================
+ Hits 16919 16930 +11
+ Misses 4411 4407 -4
+ Partials 886 885 -1 🚀 New features to boost your workflow:
|
limbonaut
approved these changes
Aug 10, 2026
JoshuaMoelans
approved these changes
Aug 10, 2026
1 task
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.

When creating shared memory for the native backend and daemon, zero the crash context only up to
module_count. Leaving the trailing ~8 MiBmodules[]array uninitialized is safe, because the array access is guarded bymodule_count.This shaves off ~40% of the current native backend startup time on Linux:
Before
After
Partial fix to: