Repository navigation
fib v1.10.0: 30 commits since v1.9.1. This release changes how fib's own code hands work to its pools, so that no pool can wait on itself. Pool sizes now follow memory as well as CPUs. Task pool queues can be watched and sampled. ModeAdaptive no longer stalls when many submitters wait on a full queue. There is one breaking rename in Config.
Breaking change
Config.IOPollersis nowConfig.SplitEventLoops, andConfig.IOPollerCountis nowConfig.EventLoopCount. (88f104a)- The loops these fields create only wait for readiness, accept connections and read shared UDP sockets. A TCP connection's reads,
OnDataand writes all run on a worker, so "IO" was misleading. - In
Settings, the fields are nowSplitEventLoops,EventLoopCountandEventLoops(the loops actually created). The startup log keys change to match. - The old names have no deprecated alias. A bool alias would silently change what one of the two spellings means.
- To upgrade, rename the two fields where you set them. The defaults have not changed.
- The loops these fields create only wait for readiness, accept connections and read shared UDP sockets. A TCP connection's reads,
No pool waits on itself
Engine.Hand/Connection.HandandEngine.TryHand/Connection.TryHandhand a function to a pool through an event loop. (7933f75, 90742ca)- Neither the caller nor the loop ever waits.
- The loop offers the function with
TryGo. If the pool's queue is full, the loop keeps the function in a list for that pool and offers it again shortly. Handis for notifications that must run: wake-ups, the end of a request or connection, results for callbacks.TryHandis for new work that a busy process may refuse. It returnsErrPoolBusywhile the pool's queue is full or work it turned away is still waiting.
- fib's own code now uses these.
- Before, a task could wait to submit to its own pool. Once every worker of that pool waited, none was left to make room, and the pool stopped for good.
- This could happen with HTTP/2 flushers, body callbacks and cancellations, gRPC queued calls, arpc callbacks and client callbacks.
TestPoolSubmissionslists every submission in fib and fails on any that could wait on its own pool.
- Visible behaviour changes:
- When the client pool is busy, a dial or SOCKS lookup fails with
ErrPoolBusy. - When the handler pool is busy, a pprof capture answers 503 with
Retry-After. sidepool.Postnever drops a callback and never waits. Past fib-notify's queue of 131,072, a callback runs on a goroutine of its own.sidepool.PostSpilledcounts these.
- When the client pool is busy, a dial or SOCKS lookup fails with
- HTTP/2 flushes are offered to the handler pool with
TryGo. When that pool's queue is full, they go to the newfib-flushside pool. On the benchmark host, h2load stayed within ±1% of v1.9.1 at 1, 10 and 100 streams per connection. (c7b7cd9) TaskPool.Stoppedis new.Go,GoTaskandGoTasksnow document the rule that a pool's task must not wait on its own pool.
Pool sizes follow memory
- Every pool's worker ceiling is now limited by memory as well as CPUs. (9eb174b)
- Each pool gets a share of half the process's memory: the machine's or its cgroup's, divided among prefork children.
- Ceilings come out lower than before on small machines and under prefork. For example, on 8 CPUs and 512 MiB, the engine and handshake pools get 1,228 workers, instead of 8,000 and 65,536.
- A machine whose memory cannot be read keeps the CPU-based ceilings.
- The sizes can be set:
Config.StreamWorkerCountsets the stream pool's ceiling.Config.SidePools(sidepool.Sizing) sets the side pools' ceilings and queues.sidepool.Configure,Current,DefaultSizingandCustomapply and report the side pool sizes.
- The startup settings list is now logged at debug level, with the settings changed from fib's defaults named in its header.
Engine.LogSettingsstill prints it at info level.
Task pool queues are watched
- A queue is watched only once a submission finds it deep (50% full). A watcher goroutine samples the queues that are being watched every 500 ms. It logs at 50, 75, 90 and 100% full, at most once every 10 s per pool and level. It stops watching a queue after 2 s of calm, and has no timer while every queue is shallow. (90742ca, 759cb6a, a0815fc, d9616c3)
- New APIs:
TaskPool.QueueStats,TaskPool.QueuedandTaskPool.Samplereport one pool.taskpool.Samplesamples every live pool, fib's own pools included, for a status or metrics endpoint.taskpool.SetAutoSampleandSetSampleIntervalswitch the watcher and set its interval.Engine.StatsgainsHandQueued,HandMaxQueued,HandRejectedandHandWarnings.
Fixes
- taskpool: ModeAdaptive no longer stalls when many submitters wait for room on a full queue. (a9696d4)
- What went wrong: submitters waited on a condition variable under the shard lock, and a draining worker woke all of them at once. Each woken submitter took the lock in turn, and the workers waited behind them, so the queue ran empty while submitters piled up.
- The fix: waiting submitters now block on a token channel without taking the lock. A worker at the low-water mark grants one token for each free cell.
- Measured on a 16-thread Ryzen 7800X3D: 4M 10ms tasks at 10k workers went from 5.27 to 4.27 s (the floor is 4.0), and 10M tasks at 50k workers from 2.43 to 2.10 s. Other benchmarks changed by ±1% or less.
- core:
Engineis back to 1,128 bytes. A loop's hand queue is now made on first use. With this and the lazy queue watcher, HTTP/1 throughput in HttpArena is back to the v1.8.0 baseline. (8f08d1e) - http3/quic: a timer that finds nothing due no longer starts the held send's clock. Before, it could send an acknowledgement on its own, ahead of the answer it should have joined. (b884c2e)
- http3/interop: the interop runner checks the requirements of the QUIC Interop Runner itself, which dropped pyshark upstream. The conformance peer moves to x/net v0.57.0 for GO-2026-5026. (abe2078)
Other
taskpool/benchmarknow compares with agilePool too. (56219b9)- The README is now the intro, the features, a comparison with net/http and the documentation index. The tutorial and the reference pages cover the rest. (7404d01)
- Development rules in
docs/rules.mdcover cleaning up, CI tests only in feature tasks, and test timeouts. - Several timing-sensitive tests no longer depend on runner speed: HTTP idle timer, HTTP/2 reset flush, duplex after close, QUIC and DHT floods, accept burst.
CI on 80f12d4 is green on Linux, macOS and Windows: all 39 jobs passed, none skipped (run 46107643276).
Full changelog: v1.9.1...v1.10.0