-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Zipping files is extremely slow with archiver or jszip #12397
Comments
I experienced a similar issue. I had to switch the library to PIzzip, which is a synchronous fork of the library and it worked okay. I'd also add that I worked with small docx documents, and while Node took a couple of dozens milliseconds to generate a buffer, it took 30x more time in Bun (around 1-1.5 seconds) |
see old PR #11770 |
does this still reproduce for you in Bun 1.1.29? |
@nektro I haven't noticed any changes. JSZip is still significantly (10x+ times) slower for me. When I switch to Pizzip it's fast. |
@nektro I'm trying to reproduce the issue outside of my project and no success so far, it works good. I'm using easy-template-x same way in my test and in my project. But performance in my project is horrible (it can take 100-500x to export/setFile compared to test). I'm trying to narrow the issue. It happens only in Bun though, in Node there's no difference |
@nektro I could narrow it down to the point that some import makes it suddenly much slower. However I couldn't find what exact import |
@whekin, @nektro, I had similar issues attempting to isolate and debug this earlier this year. I managed to narrow it down to my code running in the context of an HTTP server (or the official Bun lambda runtime), which a full project is likely to feature, but one tends to omit in a standalone test with a CLI script. See: #11054 for the code to reproduce this as well as a benchmark script + results, it might help either of you. Also note: I just tested v1.1.31 and the slowdown is still present. |
The issue is caused by us draining tasks from |
Hi ! |
What version of Bun is running?
1.1.18+5a0b93523
What platform is your computer?
Darwin 23.4.0 arm64 arm
What steps can reproduce the bug?
[jszip](https://github.com/Stuk/jszip)
orarchiver
13442
in my test)Rough script:
What is the expected behavior?
The script should complete in a couple of seconds. That's what happens with Node.
What do you see instead?
The script is extremely slow: if I log progress, I see 0.01% to 0.1% progress every second. Needless to say the script would complete in several minutes or possibly hours.
Additional information
I tried both archiver and jszip, hoping the problem was specific to an implementation. No difference.
I also tried replacing
fs.readFileAsync(path)
withBun.file(path).blob()
but it made no difference. Loading all files in memory and adding them to thezip
instance takes a second at most (including with Bun).The time is then spent by the zipping method.
The text was updated successfully, but these errors were encountered: