How effective is Chokidar (Node.js)?

I have a caching mechanism on the server that caches all files that are accessed in the root directory. I am thinking about using Chokidar to view the entire directory tree (recursively) to modify the file and update the cache accordingly. But I'm worried about what happens if the subdirectory contains hundreds of thousands of files. How effective is Chokidar?

+6
source share
1 answer

The effectiveness of Chokidar depends on which operating system it is running on.

On OS X, it uses a module that provides access to the fsevents native API, which is extremely efficient.

Other systems use the node.js fs.watch or fs.watchFile API. Under the hood of fs.watch , various system APIs are used to notify about changes that can be quite effective. fs.watchFile uses a statistical survey that would definitely be inappropriate for directories larger than you describe.

My suggestion is that you set the chokidar usePolling: false option and give it a try while monitoring your CPU load.

Update (July 2015): Chokidar has improved significantly since it was originally written, and the survey is no longer default on any platform.

+9
source

Source: https://habr.com/ru/post/955865/


All Articles