Slow performance with large options object
matkl opened this issue · 8 comments
Stringifying large objects can be slow. Removing JSON.stringify()
here makes my renders 20 ms faster.
Line 41 in cfe7920
Hi, it's not recommend to use debug in production environment.
It's the limit of debug
, do you have any idea to debug here without JSON.stringify
?
The problem here is that JSON.stringify
is called before debug and therefore is called in production environment.
I'd suggest to remove the state from the debug arguments if passing the state without stringifying is not possible.
OK, I looked up the debug
documentation and you can check if the debug target is enabled. Wrapping the call with
if (debug.enabled) { // do stuff... }
will fix the issue.
The problem here is that JSON.stringify is called before debug and therefore is called in production environment.
Yes, it is. It's because debug
cannot handle with BigInt, so here we use a replacer hack in JSON.stringify
.
OK, I looked up the
debug
documentation and you can check if the debug target is enabled. Wrapping the call with
if (debug.enabled) { // do stuff... }
will fix the issue.
debug
is enabled only if here's a DEBUG
environment, so you should not set this environment in production in most cases.
Of course I'm not enabling debug in production. The issue is about JSON.stringify(state, bigIntReplacer())
being called on every render in production mode.
Thanks, released via v6.2.3