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

esbuild watch caused high disk i/o #750

Closed
connor4312 opened this issue Feb 4, 2021 · 5 comments
Closed

esbuild watch caused high disk i/o #750

connor4312 opened this issue Feb 4, 2021 · 5 comments

Comments

@connor4312
Copy link

connor4312 commented Feb 4, 2021

I have happily adopted esbuild and started using it for new projects. A couple days after I first tried it and complained there was no watch mode, watch mode was released -- thank you! ❤️

This morning I had watch mode running on a project and noticed my computer slowed down a good deal. I opened task manager and saw the esbuild was thrashing the disk pretty hard.

image

The command was:

esbuild web/src/index.tsx --bundle --tsconfig=tsconfig.json --outfile=web/public/index.js --format=iife --sourcemap --watch  --define:process.env.NODE_ENV=\"production\"

It had been running fine for several hours previously, and after restarting it it went back to normal; unfortunately I don't have a reproduction. And didn't have the wherewithal at the time to try to collect any sort of traces before killing it, but I wanted to let you know regardless.

This was running inside an Ubuntu Docker container using Docker's WSL2 backend.

@evanw
Copy link
Owner

evanw commented Feb 4, 2021

Thanks for the report. Watch mode uses polling so it relies on your operating system to keep file metadata in RAM. I have no idea what the Docker <-> WSL2 <-> Windows file system driver setup is like but I could imagine it not caching stuff effectively.

FWIW you don't need to use esbuild's built-in watch mode if you don't want to or if it's not working for you. Feel free to use esbuild's build API with any of the many other file watching libraries out there. Some other well-known ones are watchexec and chokidar.

@connor4312
Copy link
Author

Except for this one moment, esbuild's watch has been working beautifully (in containers and windows itself)

@mitschabaude
Copy link

I want to report what I assume is a related problem:

After starting esbuild in watch mode, it continually keeps increasing RAM usage by about 1-2 MB per second (!).

My OS is Ubuntu, but this was also experienced by a co-worker with another Linux distro. We noticed it when his laptop was brought to its knees, with 4 GB RAM usage by esbuild alone ;)

@evanw
Copy link
Owner

evanw commented Feb 4, 2021

Ah wow ok that's terrible. I haven't experienced that myself but I'll try to reproduce it.

Edit: That was dumb. The GC is just off when using --watch with the CLI. I disable the GC with the CLI for speed. The GC is not disabled for --serve but I forgot to add --watch to the list of flags that need GC enabled. Thanks for pointing this out. I'll push out a fix soon. A workaround in the meantime would be to use the JS build API.

@evanw evanw closed this as completed in 3a706d4 Feb 4, 2021
@connor4312
Copy link
Author

Good find! Though I don't think that's my issue. I'll make a fork of esbuild that runs a pprof server so that I can get more information for you if I'm un/lucky enough to hit this again.

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

Successfully merging a pull request may close this issue.

3 participants