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
This is more of an annoyance than a bug since the correct value ends up being returned, but unnecessary computation takes place (which in my use case is causing significant performance degradations).
The issue occurs when a unowned derived value depends on some state, then that state is updated, but the derived value evaluates to the same thing based on the new state. From this point on the derived value is always flagged as MAYBE_DIRTY and so is re-computed each time it is read.
Step 0: first-time read of derived value
computing...
derived value: true
Step 1: update root value, should re-compute derived value
computing...
derived value: true
Step 2: read derived value again, should not re-compute derived value
computing...
derived value: true
We're having to revert back to using stores because of the performance hit caused by this.
We have derived values that are updated very infrequently but are read a high volume of times and they are being recomputed each time.
Essentially we need a way of having eagerly evaluated derived values.
We could switch the values to $state and then use $effects to update them, but the docs recommend against that.
Any ideas for best way to solve this problem?
Describe the bug
This is more of an annoyance than a bug since the correct value ends up being returned, but unnecessary computation takes place (which in my use case is causing significant performance degradations).
The issue occurs when a unowned derived value depends on some state, then that state is updated, but the derived value evaluates to the same thing based on the new state. From this point on the derived value is always flagged as
MAYBE_DIRTY
and so is re-computed each time it is read.Reproduction
https://svelte.dev/playground/hello-world?version=5.30.1#H4sIAAAAAAAAE7VSTU_jMBD9K6MRUlMpBMrRpJWQQMteirQLJ8zBSSbFwh1H9rgsqvLfV1EoX9sVB8T1ffn52VtksyZUeE7BbqiBjXGJINBh7dddEmowx9Y6iqhutyhP3SAeAMx31rOuK-KGnAxYZSLtw2vPQiwRFZaxDraThWYtbeJarGcIibMpbAdMiyMBA3M4iGKEstn09BWvBrwZ2xbVU5ZNYb7YGbXUnqN3VDi_yjSOl7C8KopC4y5GSyBJgcFACbPjZ7R_oflj0OS3UAfHClobohyKXQ8TmQZ8C83b4SbTPeZ3CjXJodqn2ln_f_5MQeoaIwTBexnjcoj3PrnmzYvtbzTMeXL6je1O1DjJuzwwK2P5pSR7-bToV8r9S51fLS9GutdcHr3-PC6rJOIZPNfO1g_zbUjcL37dLOH68gKuL38uf5RHo2ahGXMU-iOoJCTq73IUY92j5QZVa1yk_i82oS0vSQMAAA==
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: