曦远 (DealiAxy)一份私人的文字刊物

StarBlog
返回文章列表折页手记阅读全文
杂七杂八

Modify Inotify Watches Limit to Improve IDEA Performance

Official documentation For an intelligent IDE, it is essential to be in the know about any external changes in files it is working with - e.g. changes made by VCS, or build tools, or code generators etc. For that reaso

曦远 (DealiAxy)约 5 分钟
目录4 个章节

Official documentation

For an intelligent IDE, it is essential to be in the know about any external changes in files it is working with - e.g. changes made by VCS, or build tools, or code generators etc. For that reason, IntelliJ platform spins background process to monitor such changes. The method it uses is platform-specific, and on Linux, it is the Inotify facility.

Inotify requires a "watch handle" to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.

To prevent this situation it is recommended to increase the watches limit (to, say, 512K)

In short, when IDEA is running, a background process constantly scans the project folder for file changes. On Linux this is implemented using the Inotify feature, but Linux has a watch handle limit — simply put, a watch size limit. Typically this limit is smaller than what our projects need, so IDEA has to frequently scan the project directories itself instead of using the system feature, which causes it to lag.

The way to fix this is to change the system configuration and raise this limit.

Solution

Add the following line to either /etc/sysctl.conf file or a new *.conf file (e.g. idea.conf) under /etc/sysctl.d/ directory:

fs.inotify.max_user_watches = 524288

Then run this command to apply the change:

sudo sysctl -p --system

Official documentation

https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit

About


Learn more on my WeChat Official Account:DealiAxy Every post was in my blog:blog.deali.cn