perf(agera): speed up effect runs by splitting warmup and rerun paths - #178
Merged
Conversation
Split `runEffect` into small `warmupEffect` and `runEffect` specializations so V8 can inline them into the effect creation and flush paths, and gate the `noMount` and `notifyMounted` lifecycle hooks behind `isMountableUsed`. Effect benchmark improves from ~345 to ~320 ns/op (~7% faster). Bump size limits by 10-20 B in `agera`, `kida` and `store` to account for the duplicated run bodies.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
==========================================
+ Coverage 83.88% 83.94% +0.05%
==========================================
Files 138 138
Lines 2973 2983 +10
Branches 559 563 +4
==========================================
+ Hits 2494 2504 +10
Misses 340 340
Partials 139 139 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
@codex make review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Jul 21, 2026
Merged
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
Split
runEffectinto two small specializations —warmupEffect(first run:fn(true), nopurgeDeps) andrunEffect(rerun:fn(), withpurgeDeps) — and gate thenoMount/notifyMountedlifecycle hooks behindisMountableUsed.Why
Profiling the
effectbenchmark against alien-signals showed the singlerunEffectbody was too large for TurboFan to inline into the effect creation and flush paths — the unconditional lifecycle hook calls kept it above the inlining threshold. Ablation experiments confirmed guards alone recover nothing, while per-call-site specialization recovers about half of the gap:effect-agera-alien.jslatency avgThe
notifyMountedgate is safe:mountedListenerscan only be populated throughlink()→incrementEffectCount(), which already requiresisMountableUsed.The rerun path now calls
e.fn()with no arguments (previously an explicitundefined) — indistinguishable for callbacks, the spec assertion updated accordingly.Size
Duplicated run bodies cost a few bytes after brotli; size limits bumped minimally: agera All publics 2.46→2.47 kB, agera Popular 1.87→1.88 kB, kida/store Popular 2.21→2.23 kB. Signal-only bundles are unaffected (
warmupEffecttree-shakes out).🤖 Generated with Claude Code