Open Bug 850185 Opened 11 years ago Updated 2 years ago

[Workers] postMessage is sometimes slower than JSON.stringify

Categories

(Core :: DOM: Workers, defect, P3)

defect

Tracking

()

People

(Reporter: Yoric, Unassigned)

References

(Blocks 1 open bug)

Details

While attempting to improve bug 850184, I have run a few benchmarks on JSON.stringify + TextEncode vs postMessage for huge JSON objects. Some of the results are surprising. As it turns out, in my test case, JSON.stringify is faster than postMessage. I suspect that this is not expected.
I don't understand what you're trying to compare here.  postMessage sends stuff to a different thread, JSON.stringify doesn't, no?
Yes, I was just surprised because I expect that, for a huge object, the cost of serialization in postMessage dominates any other cost cost. If my understanding is correct, I am therefore comparing two serialization mechanisms: postMessage's and JSON.stringify. Given that JSON.stringify is anything but optimal, I expected postMessage's algorithm to be quite faster.
Well we haven't really tried to optimize structured cloning.  A profile would be useful here.
Priority: -- → P3
Worth investigating in the future.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.