diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 13:14:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-30 13:15:05 -0300 |
| commit | 705be665742fa0332585a4321640b5e2245610cb (patch) | |
| tree | e3953d65327e58cfefcaad8935fcf68487a8cae0 /9ns | |
| parent | 4af5c9594a5e69a09d452d037d1c89ade5691475 (diff) | |
| download | cloud9-705be665742fa0332585a4321640b5e2245610cb.tar.gz cloud9-705be665742fa0332585a4321640b5e2245610cb.zip | |
9ns: a mount's tag window and worker pool are 256, wider than a server parks per connection, so held reads no longer deadlock it
Every read a server parks holds one of the session's tags and pins one
bridge worker. With 32 tags and 31 workers, 31 held event reads (a
follower each) took every worker. The next READ, even `cat layout`,
queued behind them forever, so the whole mount hung. The window is now
256 tags and 255 workers, more than pardes parks per connection (128,
past which it refuses "too many reads waiting: 128" and so frees the
worker). A mount can then hold everything such a server parks and still
serve the rest. Workers are still started only as needed.
The multiplexing test's fake server (cloud9.Server, 64 requests in
flight) cannot park 256. A runtime Session.window, which defaults to
max_tags, lets it fill a window of 32 the same way.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to '9ns')
| -rw-r--r-- | 9ns/src/nine.zig | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/9ns/src/nine.zig b/9ns/src/nine.zig index 8b0a867..c7abbe6 100644 --- a/9ns/src/nine.zig +++ b/9ns/src/nine.zig @@ -40,15 +40,14 @@ pub const dontcare = cloud9.Stat{ }; /// Requests one session keeps in flight at once (one more tag is kept for a -/// Tflush). Every parked read a mount serves holds one, so the window is -/// twice the 16 of cloud9's default client: 32, which is what cloud9's -/// file server engine parks per connection (`fs.Options.slot_capacity`, -/// the engine pardes serves with). A mount can therefore never have more -/// requests parked on such a server than it will park, and never meets its -/// refusal (Rerror "Resource temporarily unavailable" for the one past the -/// cap). Raising this past 32 means raising the server's `slot_capacity` -/// with it (for pardes, its editor `fs.Options`). -pub const max_tags: usize = 32; +/// Tflush). Every parked read a mount serves holds one tag and pins one +/// bridge worker (`bridge.max_workers` is one fewer), so the window must be +/// wider than any server parks per connection: pardes parks 128 +/// (`fs.Options.slot_capacity` in its editor options) and refuses the next +/// with `too many reads waiting: 128`, which frees the worker. With 256 a +/// mount can hold every read such a server parks and still have workers +/// for the rest of its traffic (a `cat layout` beside 128 held event reads). +pub const max_tags: usize = 256; pub const Client = cloud9.ClientWith(max_tags); /// The `Io` the locks here (and the bridge's) hand to `std.Io.Mutex` and @@ -90,6 +89,10 @@ pub const Session = struct { out_buf: []u8, /// Negotiated maximum message size. msize: u32, + /// Requests sent at once, at most `max_tags`: a call past it waits for a + /// tag as one past the client's window does. Narrowed by tests whose + /// fake server holds fewer. + window: usize = max_tags, next_fid: u32 = 1, free_fids: std.ArrayList(u32) = .empty, /// Per-fid iounit learned from open/create (0 = none); used to chunk read/write. @@ -368,7 +371,8 @@ pub const Session = struct { s.mutex.unlock(io); s.wlock.lockUncancelable(io); s.mutex.lockUncancelable(io); - const tag = s.client.submit(req) catch |e| { + const full = s.client.pending() >= s.window; + const tag = (if (full) error.NoTags else s.client.submit(req)) catch |e| { s.wlock.unlock(io); switch (e) { error.NoTags => { @@ -1950,14 +1954,18 @@ test "multiplexing: with every tag parked, a call waits for a tag instead of fai var fs: FakeServer = .{ .fd = -1, .msize = 8192, .file_len = 50, .hang_offset = 0, .on_flush = .rflush, .release_on_stat = true }; var pair = try fs.start(); defer pair.close(); + // The fake's cloud9.Server holds 64 requests; a window of 32 fills the + // same way the whole one does. + const window = 32; + pair.session.window = window; var pi = try PipeInterrupt.init(33); defer pi.deinit(); - var reads: [max_tags]ParkedRead = undefined; + var reads: [window]ParkedRead = undefined; for (&reads) |*r| r.* = .{ .caller = try pair.newCaller() }; defer for (&reads) |*r| FakeServer.Pair.freeCaller(r.caller); reads[0].caller.interrupt = pi.interface(); for (&reads) |*r| try r.start(); - try testing.expect(eventually(HungAtLeast{ .fs = &fs, .n = max_tags })); + try testing.expect(eventually(HungAtLeast{ .fs = &fs, .n = window })); const Stat = struct { caller: *Caller, |
