[html5] JSON parsing in Web Worker
atwilson at chromium.org
Tue Dec 28 10:51:04 PST 2010
Objects passed via message ports (including the intrinsic port for dedicated
workers) are cloned. I can't speak for other implementations, but in WebKit
I believe cloned objects aren't JSON encoded/decoded, but instead there is
another native mechanism for cloning these objects that will likely be
faster than JSON encoding.
That said, I'm not sure that "parsing large JSON files" is the best
WebWorker use case, depending on how you're doing the parsing and how large
the files are.
On Tue, Dec 28, 2010 at 10:35 AM, Igor Minar <iiminar at gmail.com> wrote:
> I'm exploring the possibilities of using web workers for parsing large
> JSON files outside of the main UI thread.
> I found several references that this could be one of the use cases for
> web workers (e.g. oreilly's intro to web workers ). However, the
> more I read about webworkers, the less attractive they are for this
> purpose, mainly because of how data is passed from worker to the main
> Please correct me if I'm wrong, but my understanding is that any data
> that is returned in the message from the worker, is copied rather than
> shared and it seems that this is often implemented by serializing the
> data into a json string and then deserializing it in the main script.
> Is this right? Because if it is, then what's the point of parsing the
> json string in worker thread, just to serialize it and then parse it
> again in the main thread.
> I'd love to be wrong about this because the concept of workers looks
> like a perfect match for my use case (parsing large json payloads
> quickly without affecting the UI), but my trivial microbenchmarks show
> that the overhead of passing the data to, as well as from the
> webworker is just too big to use it for this purpose.
>  http://answers.oreilly.com/topic/1358-introducing-the-web-workers-api/
> Help mailing list
> Help at lists.whatwg.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Help