gotail icon indicating copy to clipboard operation
gotail copied to clipboard

Why not use fsnotify to detect writes instead of polling?

Open alexzorin opened this issue 10 years ago • 0 comments

I was hoping to use this library for parsing some logs, but in Go 1.5 it eats a full 2 CPU cores smashing its head against bufio.Reader.ReadString when no data is even available. Not too suitable when it is not the lone (nor primary) application on the server.

I only realized this as I went to deploy and saw the load averages on the machines explode, going into strace and seeing millions of syscall.Read.

fsnotify provides a Write event - why not let the system wake you when there is more data to read?

Edit: I have rewritten with fsnotify, and CPU is totally idle, using epoll on Linux, compared to fully loaded with gotail.

alexzorin avatar Sep 04 '15 08:09 alexzorin