bun
bun copied to clipboard
Performance spikes with Bun.file
Version
0.1.5
Platform
Linux clemster-desktop 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
What steps will reproduce the bug?
It is honestly as simple as calling Bun.file methods:
const file = Bun.file(file_path);
const text = await file.text();
const blob = await file.arrayBuffer();
How often does it reproduce? Is there a required condition?
The issue is quite random, but it seems to become more severe over time.
What is the expected behavior?
Bun is regularly able to get 0-5ms on file reads, I'd like to see it achieve this speed range consistently, without 500ms-4s spikes
What do you see instead?
I see 500ms-4s spikes, right after the same piece of code produces 0-5ms
Additional information
- I use a Hono webserver in the screenshots, although this hasn't caused any other performance issues.
- I run my Linux on a dying harddrive
Maybe that is restricted by the OS file descriptors for the old hard drive.
Maybe that is restricted by the OS file descriptors for the old hard drive.
I'll give this a shot on windows ^
After a lot of hastling with windows, I ended up using a virtual machine (which did use my ssd). Its much more consistent but the same issue is still there, getting worse over time at unacceptable levels:
This might be a hard-drive issue, but there also is an event loop issue where the event loop may idle when it shouldn't https://github.com/oven-sh/bun/issues/490
If you're only using Bun.file() to send static content, you should instead use new Response(Bun.file(path))
, as that will use an optimized syscall for HTTP and it should produce more consistent (and better) performance
Bun.write()
also seems to have this same problem.