-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance - use JSON.parse while sending the json to browser. #1457
Comments
Related: marko-js/warp10#2 |
Slightly related: it should be safe to replace the |
@tigt after Marko initializes it actually replaces the global key with an object which has a |
Overall the impact of this in benchmarking seemed to be minimal and there are benefits to our JS based serialization approach (deduping, smaller runtime, more data types, etc). |
Description
From recent talks from v8 team, we know that
JSON.parse approach is much faster compared to the JavaScript object literal. JSON.parse() is much faster than JavaScript evaluation
. I got inspiration from the below article to make this changehttps://v8.dev/blog/cost-of-javascript-2019#json
Why
This may be effective when you use handful of stateful components in your marko app and marko ships those to the browser. In the above case, browser takes time to parse and compile JS, I have made a small comparison with a sample JSON file in my machine. Below are the results
Before changes
After changes
Possible Implementation & Open Questions
We know that marko uses
warp10
internally to serialize the data while sending it to browser. We can make this change as suggested below in this file https://github.com/marko-js/marko/blob/master/src/runtime/components/index.js#L188Kindly share any thoughts, concerns or feedback.
CC: @DylanPiercey @mlrawlings
Is this something you're interested in working on?
Yes
The text was updated successfully, but these errors were encountered: