kiwix-js icon indicating copy to clipboard operation
kiwix-js copied to clipboard

Improve performance of the libzim version

Open mossroy opened this issue 4 years ago • 0 comments

Currently, the performance of the libzim version of kiwix-js is worse than the plain javascript version, although the ZIM accesses are much faster with libzim (compiled in wasm).

After adding some timers in the code, we found that it comes from the fact that the WebWorker requested by the emscripten build is mono-threaded : all calls are enqueued and handled one after the other one.

There is almost no overhead of copying the Array in the WebWorker (to have a transferable object).

I currently don't see any other idea than using a pool of WebWorkers instead of only one. It would increase the memory usage because each one would hold its own instance of libzim (with its own cache etc). I don't see how to have a single instance of libzim shared among several WebWorkers for now

We might technically use the libzim directly in the ServiceWorker, instead of a WebWorker. But we can't access the files from the ServiceWorker

mossroy avatar Oct 29 '21 16:10 mossroy