summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--9ns/src/nine.zig32
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,