Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

Increase syscall timeouts to decrease CPU usage? #58

@phred

Description

@phred

I've been running https://github.com/azer/boxcars locally, which uses fsnotify to watch a single configuration file. Today I noticed that it's taking up 0.2% CPU even when idle, which struck me as odd.

Digging in, I found that it was due to the 100ms timeout that fsnotify uses for a timeout on the kevent() system call. As an experiment, I increased it to 1 second, and even 10 seconds. In both cases: CPU usage drops to 0%, and events still trigger as soon as the file modification happens.

Other than for tests, which should run quickly, is there any reason NOT to increase the syscall timeout? The kevent call is in a goroutine, so it doesn't matter if it's blocked. I'd rather that my programs sleep until events are ready instead of retriggering the syscall 10 times per second.

In any case, I'm keeping my local modification, as it works for me. :-) Thanks for this nice and clean little library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions