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.
 
Maybe so.
But to encircle an unkown problem you always exclude all things you tested and know they are working spotless, starting by creating a stable environment you can trust to test in, maybe even stripped down to the max to get as few additional error sources as possible, but not causing even more problems by being something not reliable itself.

Basic rule of engineering:
You either do something unknown with known tools, or learning unknown tools on something known.
But never use unknown tools on an unknown job. That's almost a guarantee for desaster.

You see at this very moment 16-CURRENT ain't anything but a reliable version of the OS.
That's like trying to find out why there is a puddle on the floor while you are in a carcass house still under construction not even having a roof, yet.
You may spend time to examine the plumbing while the water also simply could just be rain. :cool:
 
Back
Top