uringmachine 0.19.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +3 -4
  3. data/CHANGELOG.md +32 -1
  4. data/TODO.md +0 -39
  5. data/examples/bm_fileno.rb +33 -0
  6. data/examples/bm_mutex.rb +85 -0
  7. data/examples/bm_mutex_single.rb +33 -0
  8. data/examples/bm_queue.rb +29 -29
  9. data/examples/bm_send.rb +2 -5
  10. data/examples/bm_snooze.rb +20 -42
  11. data/examples/bm_write.rb +4 -1
  12. data/examples/fiber_scheduler_demo.rb +15 -51
  13. data/examples/fiber_scheduler_fork.rb +24 -0
  14. data/examples/nc_ssl.rb +71 -0
  15. data/ext/um/extconf.rb +5 -15
  16. data/ext/um/um.c +310 -74
  17. data/ext/um/um.h +66 -29
  18. data/ext/um/um_async_op.c +1 -1
  19. data/ext/um/um_async_op_class.c +2 -2
  20. data/ext/um/um_buffer.c +1 -1
  21. data/ext/um/um_class.c +178 -31
  22. data/ext/um/um_const.c +51 -3
  23. data/ext/um/um_mutex_class.c +1 -1
  24. data/ext/um/um_op.c +37 -0
  25. data/ext/um/um_queue_class.c +1 -1
  26. data/ext/um/um_stream.c +5 -5
  27. data/ext/um/um_stream_class.c +3 -0
  28. data/ext/um/um_sync.c +28 -39
  29. data/ext/um/um_utils.c +59 -19
  30. data/grant-2025/journal.md +353 -0
  31. data/grant-2025/tasks.md +135 -0
  32. data/lib/uringmachine/fiber_scheduler.rb +316 -57
  33. data/lib/uringmachine/version.rb +1 -1
  34. data/lib/uringmachine.rb +6 -0
  35. data/test/test_fiber_scheduler.rb +640 -0
  36. data/test/test_stream.rb +2 -2
  37. data/test/test_um.rb +722 -54
  38. data/uringmachine.gemspec +5 -5
  39. data/vendor/liburing/.github/workflows/ci.yml +94 -1
  40. data/vendor/liburing/.github/workflows/test_build.c +9 -0
  41. data/vendor/liburing/configure +27 -0
  42. data/vendor/liburing/examples/Makefile +6 -0
  43. data/vendor/liburing/examples/helpers.c +8 -0
  44. data/vendor/liburing/examples/helpers.h +5 -0
  45. data/vendor/liburing/liburing.spec +1 -1
  46. data/vendor/liburing/src/Makefile +9 -3
  47. data/vendor/liburing/src/include/liburing/barrier.h +11 -5
  48. data/vendor/liburing/src/include/liburing/io_uring/query.h +41 -0
  49. data/vendor/liburing/src/include/liburing/io_uring.h +51 -0
  50. data/vendor/liburing/src/include/liburing/sanitize.h +16 -4
  51. data/vendor/liburing/src/include/liburing.h +458 -121
  52. data/vendor/liburing/src/liburing-ffi.map +16 -0
  53. data/vendor/liburing/src/liburing.map +8 -0
  54. data/vendor/liburing/src/sanitize.c +4 -1
  55. data/vendor/liburing/src/setup.c +7 -4
  56. data/vendor/liburing/test/232c93d07b74.c +4 -16
  57. data/vendor/liburing/test/Makefile +15 -1
  58. data/vendor/liburing/test/accept.c +2 -13
  59. data/vendor/liburing/test/bind-listen.c +175 -13
  60. data/vendor/liburing/test/conn-unreach.c +132 -0
  61. data/vendor/liburing/test/fd-pass.c +32 -7
  62. data/vendor/liburing/test/fdinfo.c +39 -12
  63. data/vendor/liburing/test/fifo-futex-poll.c +114 -0
  64. data/vendor/liburing/test/fifo-nonblock-read.c +1 -12
  65. data/vendor/liburing/test/futex.c +1 -1
  66. data/vendor/liburing/test/helpers.c +99 -2
  67. data/vendor/liburing/test/helpers.h +9 -0
  68. data/vendor/liburing/test/io_uring_passthrough.c +6 -12
  69. data/vendor/liburing/test/mock_file.c +379 -0
  70. data/vendor/liburing/test/mock_file.h +47 -0
  71. data/vendor/liburing/test/nop.c +2 -2
  72. data/vendor/liburing/test/nop32-overflow.c +150 -0
  73. data/vendor/liburing/test/nop32.c +126 -0
  74. data/vendor/liburing/test/pipe.c +166 -0
  75. data/vendor/liburing/test/poll-race-mshot.c +13 -1
  76. data/vendor/liburing/test/read-write.c +4 -4
  77. data/vendor/liburing/test/recv-mshot-fair.c +81 -34
  78. data/vendor/liburing/test/recvsend_bundle.c +1 -1
  79. data/vendor/liburing/test/resize-rings.c +2 -0
  80. data/vendor/liburing/test/ring-query.c +322 -0
  81. data/vendor/liburing/test/ringbuf-loop.c +87 -0
  82. data/vendor/liburing/test/ringbuf-read.c +4 -4
  83. data/vendor/liburing/test/runtests.sh +2 -2
  84. data/vendor/liburing/test/send-zerocopy.c +43 -5
  85. data/vendor/liburing/test/send_recv.c +103 -32
  86. data/vendor/liburing/test/shutdown.c +2 -12
  87. data/vendor/liburing/test/socket-nb.c +3 -14
  88. data/vendor/liburing/test/socket-rw-eagain.c +2 -12
  89. data/vendor/liburing/test/socket-rw-offset.c +2 -12
  90. data/vendor/liburing/test/socket-rw.c +2 -12
  91. data/vendor/liburing/test/sqe-mixed-bad-wrap.c +87 -0
  92. data/vendor/liburing/test/sqe-mixed-nop.c +82 -0
  93. data/vendor/liburing/test/sqe-mixed-uring_cmd.c +153 -0
  94. data/vendor/liburing/test/timestamp.c +56 -19
  95. data/vendor/liburing/test/vec-regbuf.c +2 -4
  96. data/vendor/liburing/test/wq-aff.c +7 -0
  97. metadata +37 -15
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/uringmachine'
4
+ require 'openssl'
5
+
6
+ HOST = ARGV[0]
7
+ PORT = ARGV[1].to_i
8
+
9
+ machine = UringMachine.new
10
+
11
+ conn_fd = machine.socket(Socket::AF_INET, Socket::SOCK_STREAM, 0, 0);
12
+ machine.connect(conn_fd, HOST, PORT)
13
+
14
+ class FakeIO < File
15
+ def initialize(machine, fd)
16
+ @machine = machine
17
+ @fd = fd
18
+ end
19
+
20
+ def nonblock=(x)
21
+ p 'nonblock=': x
22
+ end
23
+
24
+ def sync
25
+ p sync: true
26
+ true
27
+ end
28
+
29
+ def write(buf)
30
+ p write: buf
31
+ @machine.write(fd, buf)
32
+ end
33
+
34
+ def read(maxlen = 4096, buf = nil)
35
+ p read: [maxlen, buf]
36
+ buf ||= +''
37
+ _res = @machine.read(@fd, buf, maxlen)
38
+ buf
39
+ end
40
+ end
41
+
42
+ conn_io = FakeIO.new(machine, conn_fd)
43
+
44
+ ssl_io = OpenSSL::SSL::SSLSocket.new(conn_io)
45
+
46
+ stdin_fd = STDIN.fileno
47
+ stdout_fd = STDOUT.fileno
48
+
49
+ f_writer = Fiber.new do
50
+ bgidw = machine.setup_buffer_ring(4096, 1024)
51
+ machine.read_each(stdin_fd, bgidw) do |buf|
52
+ ssl_io.write(buf)
53
+ end
54
+ end
55
+ machine.schedule(f_writer, nil)
56
+
57
+ f_reader = Fiber.new do
58
+ buffer = +''
59
+ loop do
60
+ ssl_io.read(4096, buffer)
61
+ break if buffer.empty?
62
+
63
+ machine.write(stdout_fd, buf)
64
+ end
65
+ end
66
+ machine.schedule(f_reader, nil)
67
+
68
+ trap('SIGINT') { exit! }
69
+ loop do
70
+ machine.sleep(60)
71
+ end
data/ext/um/extconf.rb CHANGED
@@ -19,19 +19,12 @@ def get_config
19
19
  version, major_revision, distribution = m[1].to_i, m[2].to_i, m[4]
20
20
 
21
21
  combined_version = version.to_i * 100 + major_revision.to_i
22
- raise "UringMachine requires kernel version 6.4 or newer!" if combined_version < 604
22
+ raise "UringMachine requires kernel version 6.7 or newer!" if combined_version < 607
23
23
 
24
24
  {
25
25
  kernel_version: combined_version,
26
- submit_all_flag: combined_version >= 518,
27
- coop_taskrun_flag: combined_version >= 519,
28
- single_issuer_flag: combined_version >= 600,
29
26
  prep_bind: combined_version >= 611,
30
- prep_listen: combined_version >= 611,
31
- prep_cmd_sock: combined_version >= 607,
32
- prep_futex: combined_version >= 607,
33
- prep_waitid: combined_version >= 607,
34
- prep_read_multishot: combined_version >= 607
27
+ prep_listen: combined_version >= 611
35
28
  }
36
29
  end
37
30
 
@@ -56,15 +49,12 @@ if !find_library('uring', nil, File.join(liburing_path, 'src'))
56
49
  raise "Couldn't find liburing.a"
57
50
  end
58
51
 
52
+ have_func("&rb_process_status_new")
53
+
59
54
  $defs << "-DUM_KERNEL_VERSION=#{config[:kernel_version]}"
60
- $defs << '-DHAVE_IORING_SETUP_SUBMIT_ALL' if config[:submit_all_flag]
61
- $defs << '-DHAVE_IORING_SETUP_COOP_TASKRUN' if config[:coop_taskrun_flag]
62
55
  $defs << '-DHAVE_IO_URING_PREP_BIND' if config[:prep_bind]
63
56
  $defs << '-DHAVE_IO_URING_PREP_LISTEN' if config[:prep_listen]
64
- $defs << '-DHAVE_IO_URING_PREP_CMD_SOCK' if config[:prep_cmd_sock]
65
- $defs << '-DHAVE_IO_URING_PREP_FUTEX' if config[:prep_futex]
66
- $defs << '-DHAVE_IO_URING_PREP_WAITID' if config[:prep_waitid]
67
- $defs << '-DHAVE_IO_URING_PREP_READ_MULTISHOT' if config[:prep_read_multishot]
57
+
68
58
  $CFLAGS << ' -Wno-pointer-arith'
69
59
 
70
60
  CONFIG['optflags'] << ' -fno-strict-aliasing'