Very slow serialization of js function result
See original GitHub issueConsider the script
function main(splash, args)
f = splash:jsfunc([[
function () {
var result = []
for (var i = 0; i < 5000; i++) {
result.push({
i_value: [i],
const_value: 'foo',
})
}
return result; // JSON.stringify(result);
}
]])
s0 = splash:get_perf_stats()
result = f()
s1 = splash:get_perf_stats()
return {
time=s1.walltime - s0.walltime,
length=#result,
}
end
this takes around 0.20 s. If we change the value to const_value: ['foo'],
then time goes up to 0.25 – 0.30 s. If we return result as a JSON string instead (commented out) then it takes 0.05 – 0.07 s in both cases. So it looks like passing a big nested value from JS to the script is quite slow.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
slow serialization for some cases (happens in Node.js 10) #3
With some testing I found that setting the space option to something other than a value that results in no space fixes the...
Read more >Crystal: slow json serialization of structs containing large strings
I'm wondering why json serialization of structs containing large strings is slow in Crystal. ... Considering Crystal is usually very fast (on par ......
Read more >Sia: an ultra fast serializer in pure JavaScript | by Pouya Eghbali
Type checking is heavy, object and array creation is time consuming, but the most expensive and heaviest operation is working with strings.
Read more >Serializing Complex Objects in JavaScript - Toptal
The JSON serializer is around 6-7 times slower than native serialization. The experimental protobufs serializer is around 13 times slower than the JSON ......
Read more >Is postMessage slow? - surma.dev
The data shows that the complexity of the object is a strong factor in how long it takes to serialize and deserialize an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is for jsfunc, evaljs, wait_for_resume, maybe some other functions, so I think FAQ + links from individual functions in Lua API is good
I think option 1 is good, another variant would be adding this to the
jsfunc
docs.