You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DEV build seems to have O(n^2) in registerGraph name resolution for createSignal in onMount when using signals from props #1322
When invoking createSignal multiple times in onMount, there is a noticeable performance degradation in DEV build, when certain conditions are met. Performance recording call tree indicates that the registerGraph function is taking majority of the time.
The registerGraph function creates for a unique name for the signal in DEV builds, and does this in a loop, so I presume the issue is that in some cases the same name is given to the registerGraph for a large number of signals, and the loop has to try all of them every time a new signal is added.
Expected onMount duration is around 10ms, but actual onMount duration is around 3000ms.
Screenshots or Videos
Platform
OS: Windows
Browser: Chrome, Edge
Additional context
Note that this issue is only present in DEV build, as the registerGraph is not used in production.
There are several workarounds for this issue. The first seems to be not to use signals from props in onMount, as in https://stackblitz.com/edit/solid-vite-pgsggu?file=src/index.tsx which apparently alters the name generation for the signals in such a way that the issue disappears (in this example, removing the use of props.rows was enough). The second is to use createSignal(false, { internal: true }), which suppresses the name generation for the signal. The third option is to provide unique names for the signals in question, for example createSignal(false, { name: `selectedCells[${row}][${col}]` }).
For Dev when a signal name is generated it uses a rather expensive method(serialization) to generate a hash which may also increase in complexity as the object grows
Yeah I've been working with @thetarnav on figuring out if we can just remove all of this. It was an experiment.. seems sort of ill advised at this point. We've found otherways to make dev tools work better.
Activity
LiQuidProQuo commentedon Oct 31, 2022
For Dev when a signal name is generated it uses a rather expensive method(serialization) to generate a hash which may also increase in complexity as the object grows
solid/packages/solid/src/reactive/signal.ts
Lines 1048 to 1078 in 454ed51
then if the hash already exists it will loop with an increment until a free name is found
solid/packages/solid/src/reactive/signal.ts
Line 1085 in 454ed51
The good news is that it's a dev only feature, and performance testing should generally be done on a production build.
ryansolid commentedon Oct 31, 2022
Yeah I've been working with @thetarnav on figuring out if we can just remove all of this. It was an experiment.. seems sort of ill advised at this point. We've found otherways to make dev tools work better.