Skip to content

Commit

Permalink
io_uring: disable IORING_SETUP_DEFER_TASKRUN
Browse files Browse the repository at this point in the history
Benefits unclear for now
  • Loading branch information
Cloudef committed Jun 21, 2024
1 parent 98a543e commit b51bcd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions examples/coro.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(), .{});
Expand Down
22 changes: 11 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'');
Expand Down
6 changes: 5 additions & 1 deletion src/aio/IoUring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b51bcd2

Please sign in to comment.