feat(turbopack): Attempt to detect and warn about slow file IO (#66057)
We'd like to warn users if they have particularly slow file IO, so that they can correct the problem themselves, and don't send us reports of poor performance. - Feature request: https://vercel.slack.com/archives/C03KAR5DCKC/p1716051650641529 - Tweet about how Bun does this: https://x.com/jarredsumner/status/1637549427677364224 - Bun implementation: https://github.com/oven-sh/bun/blob/06a9aa80c38b08b3148bfeabe560697956d38a64/src/install/install.zig#L3038 **Why 100ms?** Bun used to use 10ms, found it too noisy, and switched to 100ms. This benchmark should run non-blocking in the background and should not meaningfully slow down server startup (even on slow disks). ## Simulated Testing I looked around and found https://github.com/schoentoon/slowpokefs/. It hasn't been updated in 10 years, but still seems to build fine. In a nextjs project directory, turn `.next` into an artifically slow mount point: ``` fusermount -uz .next; rm -rf .next .next.real && mkdir .next .next.real && ~/slowpokefs/slowpokefs -m 50 -M 50 --no-slow-read -F .next.real .next ``` <img width="695" alt="Screenshot 2024-05-21 at 4 14 58 PM" src="https://github.com/vercel/next.js/assets/180404/217d7692-33cf-42b7-bbf7-5a530b9e0df1"> Run `pnpm dev --turbo` and see that the warning is generated. ## "Real World" Testing The following tests are from a linux VM using virtiofs to connect to a 5400 RPM USB 2.0 HDD with APFS: Only the .next is on an HDD (bind mount): Otherwise idle disk: `4.86ms 4.44ms 5.31ms` Otherwise busy disk (copying files): `69.34ms 53.75ms 25.12ms` The whole project directory is on the HDD (more realistic): Otherwise idle disk: `20.29ms 35.61ms 48.12ms` Otherwise busy disk (copying files): `131.40ms 21.71ms 87.33ms` Most of the time the threshold was not reached, but the 131.40ms test did trigger the warning! Fixes PACK-3087
Showing
Please
register
or
sign in
to comment