Repository navigation
Reduce count and work of signals - #1441
Draft
jacob-kofoed wants to merge 12 commits into
Draft
jacob-kofoed wants to merge 12 commits into
jacob-kofoed wants to merge 12 commits into
Conversation
|
✅ SSR Benchmark: No regressions or improvements — performance and memory are 1:1. |
|
✅ Issues Benchmark: No regressions or improvements — performance is 1:1. |
⚡ Nordcraft Runtime Performance Benchmark
|
jacob-kofoed
force-pushed
the
mm-signal-perf
branch
2 times, most recently
from
October 27, 2026 09:58
12c6c9d to
7f75405
Compare
jacob-kofoed
force-pushed
the
mm-signal-perf
branch
from
October 27, 2026 14:43
f4239a3 to
b8a03a6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved correctness regressions affect signal delivery, rendering, formula evaluation, and custom-element theme updates.
7 open issues
Do not infer legacy context usage from Function.length · New Compare repeat entry keys before skipping list updates · New Preserve newline rendering when using textContent · New Read current value during reentrant subscriber notifications · New Register subscriber before sending the initial notification · New Use a prototype-free object for the formula cache · New Restore theme listener and refresh theme on reconnect · New
What changed in this PR
This PR reduces signal allocation and repeated work across runtime rendering, component initialization, and formula evaluation.
Changes:
- Adds mapped subscriptions, lifecycle-scoped signal forks, and static-formula fast paths.
- Streamlines DOM updates, repeated-node rendering, and subscription cleanup.
- Reduces allocation and repeated evaluation in formula and API helpers, with focused tests.
| File | Description |
|---|---|
packages/runtime/src/utils/subscribeCustomProperty.ts |
Adds direct custom-property binding and static-value handling. |
packages/runtime/src/utils/nodes.ts |
Uses supported state-preserving DOM moves. |
packages/runtime/src/utils/isStaticFormula.ts |
Adds preview-aware static-formula detection. |
packages/runtime/src/utils/isStaticFormula.test.ts |
Tests static-formula detection. |
packages/runtime/src/utils/getThemeSignal.ts |
Adds cookie-listener cleanup. |
packages/runtime/src/utils/createFormulaCache.ts |
Creates entries only for cacheable formulas. |
packages/runtime/src/signal/signal.ts |
Adds mapped subscriptions, forks, and shared update options. |
packages/runtime/src/signal/signal.test.ts |
Tests mapped subscriptions and fork cleanup. |
packages/runtime/src/page.main.ts |
Streamlines page signals, theme initialization, and metadata updates. |
packages/runtime/src/events/handleAction.ts |
Simplifies state updates and action cleanup. |
packages/runtime/src/editor/previewAutofocus.ts |
Replaces intermediate signals with mapped subscriptions. |
packages/runtime/src/editor-preview.main.ts |
Uses a fork for preview-root lifecycle management. |
packages/runtime/src/custom-element/ToddleComponent.ts |
Streamlines initialization and exposed formula signals. |
packages/runtime/src/context/subscribeToContext.ts |
Initializes context directly and skips static subscriptions. |
packages/runtime/src/components/renderComponent.ts |
Uses mapped attribute subscriptions. |
packages/runtime/src/components/createText.ts |
Simplifies text subscriptions and DOM writes. |
packages/runtime/src/components/createSlot.ts |
Uses forks for slotted-child signals. |
packages/runtime/src/components/createNode.ts |
Optimizes conditional and repeated-node updates. |
packages/runtime/src/components/createElement.ts |
Streamlines attributes, styles, children, and event processing. |
packages/runtime/src/components/createComponent.ts |
Reduces initialization and attribute-update overhead. |
packages/runtime/src/api/sortApis.ts |
Skips sorting trivial API lists. |
packages/runtime/src/api/createAPIv2.ts |
Reuses forced-update options and simplifies state writes. |
packages/runtime/src/api/createAPI.ts |
Replaces payload signals with mapped subscriptions. |
packages/lib/formulas/sort_by/handler.ts |
Evaluates sorting keys once per item. |
packages/lib/formulas/get/handler.ts |
Reuses the core path-lookup helper. |
packages/core/src/utils/collections.test.ts |
Adds path-lookup coverage. |
packages/core/src/formula/functionFormula.ts |
Conditionally supplies legacy context based on handler arity. |
Review effort: Balanced
| prev && | ||
| Array.isArray(list) && | ||
| list.length === prev.length && | ||
| list.every((item, i) => item === prev[i]![1]) |
| dataSignal.subscribeMap( | ||
| (data) => String(applyFormula(value, ctx, data, valuePath)), | ||
| (value) => { | ||
| elem.textContent = value |
| for (const subscriber of this.subscribers) { | ||
| subscriber.notify(this.value) | ||
| } | ||
| this.subscribers.forEach(notifySubscriber, this.value) |
| : { canCache: false, keys: [] } | ||
| let cacheInput: any | ||
| let cacheData: any | ||
| const cache: FormulaCache = {} |
Comment on lines
64
to
66
| dataSignal.subscriptions.push(() => { | ||
| cookieStore.removeEventListener('change', onCookieChange) | ||
| }) |
jacob-kofoed
force-pushed
the
mm-signal-perf
branch
from
October 30, 2026 12:21
e759227 to
35e4219
Compare
jacob-kofoed
force-pushed
the
mm-signal-perf
branch
from
November 1, 2026 12:21
2ba3fdb to
cd4dce8
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.

No description provided.