Skip to content
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

Improve performance of the libzim version #767

Closed
mossroy opened this issue Oct 29, 2021 · 3 comments
Closed

Improve performance of the libzim version #767

mossroy opened this issue Oct 29, 2021 · 3 comments
Labels
Milestone

Comments

@mossroy
Copy link
Contributor

mossroy commented Oct 29, 2021

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 mossroy added this to the v3.3 milestone Oct 29, 2021
@Jaifroid Jaifroid modified the milestones: v3.3, v3.4, v3.6 Jan 31, 2022
@Jaifroid
Copy link
Member

Jaifroid commented Dec 5, 2022

We may have to look for a different WASM File System if the disabling of SharedArrayBuffer goes ahead in Chrome. See openzim/javascript-libzim#22.

@kelson42
Copy link
Collaborator

kelson42 commented Jan 9, 2023

Seems to me this ticket belongs to repository openzim/javascript-libzim.

@Jaifroid
Copy link
Member

Jaifroid commented Jan 9, 2023

Yes, it's the "same" issue (sort of) that I've been struggling with in openzim/javascript-libzim#42. The problem is that mossroy's suggestion of a pool of Web workers won't help with the issue I identified there, i.e. that the file takes a very long time to load on (probably) ARM-based systems, or on systems with slow I/O. Closing in favour of that issue, but will copy mossroy's comment there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants