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
I did some brief profiling with eslint, and found that a significant time spent linting our codebase was due to the state-snapshot-rule. Here is a single file example (note: the file has about 1300 lines of code):
time TIMING=1 pnpm exec eslint REDACTED-PATH/Playground.tsx
REDACTED-PATH/Playground.tsx
394:9 warning Better to just use proxy state valtio/state-snapshot-rule
422:5 warning Better to just use proxy state valtio/state-snapshot-rule
✖ 2 problems (0 errors, 2 warnings)
Rule | Time (ms) | Relative
:---------------------------------------|----------:|--------:
valtio/state-snapshot-rule | 51.368 | 32.2%
react/jsx-no-constructed-context-values | 15.081 | 9.5%
simple-import-sort/imports | 10.509 | 6.6%
react/no-direct-mutation-state | 10.086 | 6.3%
react/no-danger-with-children | 7.334 | 4.6%
react/no-typos | 6.383 | 4.0%
react/require-render-return | 6.233 | 3.9%
@typescript-eslint/naming-convention | 4.980 | 3.1%
react-hooks/exhaustive-deps | 3.521 | 2.2%
react/jsx-uses-react | 2.264 | 1.4%
TIMING=1 pnpm exec eslint REDACTED-PATH/Playground.tsx 21.42s user 4.65s system 123% cpu 21.173 total
As you can see, a single file takes 21s with the rule enabled. If I disable the rule, the entire file only takes ~15s:
So, a 20% speedup after disabling this rule. Note that this is using eslint v7 (we're out of date), but I have also tried using v9 during an upgrade attempt and found very similar results. There is a chance this is something extremely specific to our codebase's use of types, but it's unclear to me how only state-snapshot-rule would be affected by that.
I apologize for not doing a deeper investigation, such as profiling/flamecharts, and just reporting! But I figured it was worth relaying our experience in case there was something obvious either we're doing wrong or that can be done to improve the performance of the rule. For now, we're going to disable the rule because it tends to also have false positives, which have reduced our developers' confidence (e.g. most most everyone was ignoring it! 🙃). Regardless, thank you for making this rule because it helped everyone learn 🚀
The text was updated successfully, but these errors were encountered:
Hello there!
I did some brief profiling with eslint, and found that a significant time spent linting our codebase was due to the
state-snapshot-rule
. Here is a single file example (note: the file has about 1300 lines of code):As you can see, a single file takes 21s with the rule enabled. If I disable the rule, the entire file only takes ~15s:
When multiplied across the codebase, the difference in timing is more noticeable. Before:
After disabling:
So, a 20% speedup after disabling this rule. Note that this is using eslint v7 (we're out of date), but I have also tried using v9 during an upgrade attempt and found very similar results. There is a chance this is something extremely specific to our codebase's use of types, but it's unclear to me how only
state-snapshot-rule
would be affected by that.I apologize for not doing a deeper investigation, such as profiling/flamecharts, and just reporting! But I figured it was worth relaying our experience in case there was something obvious either we're doing wrong or that can be done to improve the performance of the rule. For now, we're going to disable the rule because it tends to also have false positives, which have reduced our developers' confidence (e.g. most most everyone was ignoring it! 🙃). Regardless, thank you for making this rule because it helped everyone learn 🚀
The text was updated successfully, but these errors were encountered: