[roll] Roll fuchsia [starnix][perf] Trim epoll_wait overhead when events are ready

epoll_wait() did per-call work even when events were already ready, the
common case in busy event loops: it read the clock to compute its
deadline, and EpollFileObject::wait() heap-allocated its pending and
result lists and a hash set to deduplicate pending events, reallocated
its recheck list, and registered and immediately removed a waiter
callback for every level-triggered fd that was still ready.

Compute the deadline only when the wait is about to block (an infinite
timeout needs no clock read at all). Keep up to 16 pending items and
results inline, the max_events of Android's Looper, and find repeated
items by scanning the earlier ones, with a hash set only for longer
lists. Also keep the recheck list's allocation across waits, and make
Waiter::wake_immediately() run the handler and notify the waiter
directly.

The timeout now starts after the first readiness check, less than a
microsecond later than before, well within the 50 us default timer
slack that Linux applies to epoll timeouts of non-realtime tasks.

fuchsia.starnix.gvisor_benchmarks:
                             x64                vim3
    EpollAllEvents/2       3041 ns   -7.0%     3983 ns  -10.7%
    EpollAllEvents/8       7007 ns   -7.6%    11.09 us   -9.5%
    EpollAllEvents/64     43.84 us  -10.4%    84.75 us   -9.5%
    EpollAllEvents/512    333.6 us  -10.3%    713.0 us   -8.3%
    EpollAllEvents/1024   698.4 us  -10.9%     2415 us  -14.4%

EpollTimeout/1 is 0.2 us (x64) and 0.5 us (vim3) longer because of the
later timeout start. The few other metrics that perfcompare flagged are
in unrelated code.

Test: starnix_core_tests and gVisor epoll, eventfd and pipe tests (CQ).
Original-Original-Bug: 577120110
Original-Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1906749
Original-Original-Revision: 4cc1a157b6592f0fcd0df94d5764869498d0464f
GitOrigin-RevId: 643ac7931184daea8ac3e78194354e3f7917e061
Change-Id: I2f989860c066f174c1f486c8887a3f320623f3e9
Reviewed-on: https://fuchsia-review.googlesource.com/c/integration/+/1926037
Cr-Commit-Position: refs/heads/main@{#208949}
1 file changed
tree: 93879da9fa5737929298dcfaf72f23d6b10de12a
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. cobalt
  6. flower
  7. jiri.lock
  8. MILESTONE
  9. minimal
  10. prebuilts
  11. README.md
  12. stem
  13. test_durations
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.

Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance in one of the communication channels documented at get involved.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.