remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.21k stars 1.72k forks source link

[WIP] perf: filter by ext on chokidar side #2111

Open pahan35 opened 1 year ago

pahan35 commented 1 year ago

I noticed that nodemon uses a lot of CPU while watching my current project.

I investigated it and found that it is chokidar who consumes lots of resources. I found this issue https://github.com/paulmillr/chokidar/issues/1162.

I looked into the problem through the context of nodemon and found that chokidar watches all the files even if we are interested in files with specific extensions.

So, I made this change https://github.com/paulmillr/chokidar/pull/1274 and proposed it to the chokidar.

If talking in numbers, before that change, I had watched 29 892 files and had usage of CPU. It started from the range 198 - 203 at the beginning and stoped at level 217 - 219 after 5-10 restarts. if retrieved via ps -C node -wwo pid,%cpu,%mem,cmd

After these changes, I started having 20 140 files watched and CPU usage at 173 - 181 at the beginning, which is a noticeable reduction for my system.

@remy and community, if you consider these changes to be a meaningful improvement, please help me get the PR https://github.com/paulmillr/chokidar/pull/1274 merged.

Also, feel free to share your feedback if you see some improvements in the work I did.

Thanks in advance!

netlify[bot] commented 1 year ago

Deploy Preview for nodemon ready!

Name Link
Latest commit 348503425bd37043cee9c2934ac2ad758bc7b177
Latest deploy log https://app.netlify.com/sites/nodemon/deploys/64233527b32673000787622a
Deploy Preview https://deploy-preview-2111--nodemon.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.