From b51bcd2d8e307a1d169d18040ebc1221a1551ea3 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Fri, 21 Jun 2024 16:21:38 +0900 Subject: [PATCH] io_uring: disable IORING_SETUP_DEFER_TASKRUN Benefits unclear for now --- examples/coro.zig | 2 ++ flake.nix | 22 +++++++++++----------- src/aio/IoUring.zig | 6 +++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/examples/coro.zig b/examples/coro.zig index e4f0674..77678af 100644 --- a/examples/coro.zig +++ b/examples/coro.zig @@ -91,6 +91,8 @@ fn client() !void { } pub fn main() !void { + // var mem: [4096 * 1024]u8 = undefined; + // var fba = std.heap.FixedBufferAllocator.init(&mem); var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{}; defer _ = gpa.deinit(); var scheduler = try coro.Scheduler.init(gpa.allocator(), .{}); diff --git a/flake.nix b/flake.nix index 5ca6666..feb9c55 100644 --- a/flake.nix +++ b/flake.nix @@ -73,22 +73,22 @@ ``` % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ------------------ - 45.31 0.000087 14 6 io_uring_enter - 24.48 0.000047 23 2 io_uring_setup - 9.38 0.000018 4 4 mmap - 6.77 0.000013 3 4 munmap - 5.73 0.000011 5 2 close - 2.60 0.000005 5 1 bind - 2.08 0.000004 4 1 listen - 1.56 0.000003 1 2 setsockopt - 1.56 0.000003 3 1 io_uring_register - 0.52 0.000001 1 1 gettid + 0.00 0.000000 0 2 close + 0.00 0.000000 0 4 mmap + 0.00 0.000000 0 4 munmap 0.00 0.000000 0 5 rt_sigaction + 0.00 0.000000 0 1 bind + 0.00 0.000000 0 1 listen + 0.00 0.000000 0 2 setsockopt 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 arch_prctl + 0.00 0.000000 0 1 gettid 0.00 0.000000 0 2 prlimit64 + 0.00 0.000000 0 2 io_uring_setup + 0.00 0.000000 0 6 io_uring_enter + 0.00 0.000000 0 1 io_uring_register ------ ----------- ----------- --------- --------- ------------------ - 100.00 0.000192 5 33 total + 100.00 0.000000 0 33 total ``` EOF ''); diff --git a/src/aio/IoUring.zig b/src/aio/IoUring.zig index e366f8e..eeb2d37 100644 --- a/src/aio/IoUring.zig +++ b/src/aio/IoUring.zig @@ -170,7 +170,11 @@ inline fn uring_init_inner(n: u16, flags: u32) !std.os.linux.IoUring { inline fn uring_init(n: u16) aio.Error!std.os.linux.IoUring { const flags: []const u32 = &.{ - std.os.linux.IORING_SETUP_SINGLE_ISSUER | std.os.linux.IORING_SETUP_DEFER_TASKRUN, // 6.1 + // Disabled for now, this seems to increase syscalls a bit + // However, it may still be beneficial from latency perspective + // I need to play this with more later, and if there's no single answer + // then it might be better to be exposed as a tunable. + // std.os.linux.IORING_SETUP_SINGLE_ISSUER | std.os.linux.IORING_SETUP_DEFER_TASKRUN, // 6.1 std.os.linux.IORING_SETUP_SINGLE_ISSUER | std.os.linux.IORING_SETUP_COOP_TASKRUN, // 6.0 std.os.linux.IORING_SETUP_COOP_TASKRUN, // 5.9 0, // 5.4