toActionObject is slow due to Object.defineProperty -- Can it be replaced? #2488
Unanswered
theRobinator
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Added #2491 to fix this 👍 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Super curious if your solution have seen any other bottlenecks with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I work on a relatively-good-sized website and we're using XState on a large portion of our pages. We do heavy caching, but we still end up rendering pages with XState on them about 10 times per second all day. Today I was looking into how to speed up page rendering, and I ended up running the Node profiler on an instance. It showed me this:
As you can see,
toActionObject
is taking more than a third of the total time for rendering a page. When I looked into it further, I found this:It's just
Object.defineProperty
that takes up all that time! A bit of Googling showed me that this can be made faster by simply setting the property instead of usingObject.defineProperty
-- but thentoString
would be enumerable.So my question is, is it safe to make this change? If so, I'm happy to submit a PR.
Beta Was this translation helpful? Give feedback.
All reactions