Skip to content

Commit fb8d0fc

Browse files
author
Mike Terhar
authored
Increase inotify watchers in docs (#694)
1 parent 590a7a9 commit fb8d0fc

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

guides/troubleshooting/inotify-watch-limits.md

+27-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ There are three kernel tuning options related to the `inotify` system:
5050
To see the values for these settings that are applicable to your workspace, run:
5151

5252
```console
53-
$ sysctl fs.inotify.{max_queued_events,max_user_instances,max_user_watches}
53+
sysctl fs.inotify.{max_queued_events,max_user_instances,max_user_watches}
54+
```
55+
56+
You should see output similar to the following:
57+
58+
```text
5459
fs.inotify.max_queued_events = 16384
5560
fs.inotify.max_user_instances = 128
5661
fs.inotify.max_user_watches = 8192
@@ -69,8 +74,9 @@ To identify the programs consuming `inotify` watches, you can use a script that
6974
summarizes the information available in the `/proc` filesystem, such as
7075
[`inotify-consumers`].
7176

72-
This script will show the names of programs along with the number of `inotify`
73-
watches registered with the kernel:
77+
Running `./inotify-consumers` will show the names of programs along with the
78+
number of `inotify` watches registered with the kernel, which will look like the
79+
following:
7480

7581
```console
7682
$ ./inotify-consumers
@@ -94,7 +100,7 @@ $ ./inotify-consumers
94100
https://github.com/fatso83/dotfiles/blob/master/utils/scripts/inotify-consumers
95101

96102
To see the specific files that the tools track for changes, you can use `strace`
97-
to monitor invocations of the `inotify_add_watch` system call:
103+
to monitor invocations of the `inotify_add_watch` system call, for example:
98104

99105
```console
100106
$ strace --follow-forks --trace='inotify_add_watch' inotifywait --quiet test
@@ -154,7 +160,7 @@ For example, you can create a file called `/etc/sysctl.d/watches.conf` and
154160
include the following contents:
155161

156162
```text
157-
fs.inotify.max_user_watches = 65536
163+
fs.inotify.max_user_watches = 10485760
158164
```
159165

160166
Alternatively, you can use the following DaemonSet with `kubectl apply`:
@@ -186,10 +192,21 @@ spec:
186192
initContainers:
187193
- name: sysctl
188194
image: alpine:3
195+
env:
196+
# Each inotify watch consumes kernel memory, and existing container memory
197+
# limits do not account for this. While you can set an arbitrary limit here,
198+
# note that permitting large numbers of watches may result in performance
199+
# degradation and out-of-memory errors. The required memory per watcher is
200+
# platform-dependent and defined as INOTIFY_WATCH_COST in fs/notify:
201+
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/notify/inotify/inotify_user.c
202+
#
203+
# The default in this file is 10 million watchers per user.
204+
- name: "USER_WATCHES_MAX"
205+
value: "10485760"
189206
command:
190207
- sysctl
191208
- -w
192-
- fs.inotify.max_user_watches=16384
209+
- fs.inotify.max_user_watches=$(USER_WATCHES_MAX)
193210
resources:
194211
requests:
195212
cpu: 10m
@@ -269,5 +286,7 @@ program sets the `fs.inotify.max_user_watches` setting.
269286
a blog post describing a user's preferred settings, including file
270287
exclusions
271288

272-
If none of these steps resolve the issue, please
273-
[contact us](https://coder.com/contact) for further support.
289+
If none of these steps resolve the issue, please [contact us] for further
290+
support.
291+
292+
[contact us]: https://coder.com/contact

0 commit comments

Comments
 (0)