Hacker News new | ask | show | jobs
by pie_flavor 1034 days ago
Common misconception - it's not opening or writing files that can take a second, it's closing them.
1 comments

This definitely also used to be true on macOS. Bun previously would just request the max ulimit for file descriptors and then not close them. Most tools don't realize there are hard and soft limits to file descriptors, and the hard limit is usually much higher.

On Linux, not closing file descriptors makes opening new ones on multiple threads occasionally lock for 30ms or more. Early versions of `bun build` were something like 5x slower on Linux compared to macOS until we narrowed down that the bug was caused by not closing file descriptors.

Here likely meant that system level hooks of antiviral software are invoked on CloseFile call when you do writes, not on OpenFile.

You may want to take a look on https://youtu.be/qbKGw8MQ0i8?si=HO5b0MuljPQN9Sb2