Antigravity-cli consumes 800% CPU

It's what the gemini-4-hydrogen says:
Summary
Linux Go applications (using fsnotify / Go's netpoll epoll poller) spin at 800%+ CPU and flood
logs with read : resource temporarily unavailable (EAGAIN) under FreeBSD 16.0-CURRENT's
Linuxulator.

Root Cause
  1. Non-blocking inotify fd creation:
    Go's fsnotify opens an inotify descriptor with IN_NONBLOCK | IN_CLOEXEC
    (linux_inotify_init1() -> linux_inotify_init_flags() in
    sys/compat/linux/linux_file.c, which maps it to O_NONBLOCK). When the event queue is empty,
    inotify_read() in sys/kern/vfs_inotify.c immediately returns EWOULDBLOCK
    (EAGAIN).
  2. epoll_ctl(EPOLL_CTL_ADD) fails with EINVAL when EPOLLOUT is included:
    Go's Linux netpoll registers file descriptors into epoll with EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLET.
    • In sys/compat/linux/linux_event.c, epoll_to_kevent() emits both
      EVFILT_READ (for LINUX_EPOLL_EVRD) and EVFILT_WRITE (for
      LINUX_EPOLL_EVWR), and linux_epoll_ctl() passes them to kern_kevent_fp(..., nevents = 0, ...).
    • However, inotify_kqfilter() in sys/kern/vfs_inotify.c (and similarly
      timerfd_kqfilter() in sys/kern/sys_timerfd.c) rejects any filter other than
      EVFILT_READ with EINVAL.
    • Because nevents == 0, kqueue_kevent() in sys/kern/kern_event.c immediately
      fails the entire epoll_ctl() call with EINVAL.
    • On real Linux, epoll_ctl() accepts EPOLLOUT on inotify and
      timerfd descriptors without error (it simply never reports them as writable).
  3. Resulting busy loop:
    Because epoll_ctl() fails, Go's internal/poll cannot park the goroutine via
    epoll_wait. Every Read() on the O_NONBLOCK inotify fd immediately
    returns EAGAIN (resource temporarily unavailable), and fsnotify's event loop
    retries in a tight infinite loop with no backoff, saturating multiple CPU cores and generating gigabytes of error
    logs.
 
Back
Top