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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -4
- data/CHANGELOG.md +32 -1
- data/TODO.md +0 -39
- data/examples/bm_fileno.rb +33 -0
- data/examples/bm_mutex.rb +85 -0
- data/examples/bm_mutex_single.rb +33 -0
- data/examples/bm_queue.rb +29 -29
- data/examples/bm_send.rb +2 -5
- data/examples/bm_snooze.rb +20 -42
- data/examples/bm_write.rb +4 -1
- data/examples/fiber_scheduler_demo.rb +15 -51
- data/examples/fiber_scheduler_fork.rb +24 -0
- data/examples/nc_ssl.rb +71 -0
- data/ext/um/extconf.rb +5 -15
- data/ext/um/um.c +310 -74
- data/ext/um/um.h +66 -29
- data/ext/um/um_async_op.c +1 -1
- data/ext/um/um_async_op_class.c +2 -2
- data/ext/um/um_buffer.c +1 -1
- data/ext/um/um_class.c +178 -31
- data/ext/um/um_const.c +51 -3
- data/ext/um/um_mutex_class.c +1 -1
- data/ext/um/um_op.c +37 -0
- data/ext/um/um_queue_class.c +1 -1
- data/ext/um/um_stream.c +5 -5
- data/ext/um/um_stream_class.c +3 -0
- data/ext/um/um_sync.c +28 -39
- data/ext/um/um_utils.c +59 -19
- data/grant-2025/journal.md +353 -0
- data/grant-2025/tasks.md +135 -0
- data/lib/uringmachine/fiber_scheduler.rb +316 -57
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +6 -0
- data/test/test_fiber_scheduler.rb +640 -0
- data/test/test_stream.rb +2 -2
- data/test/test_um.rb +722 -54
- data/uringmachine.gemspec +5 -5
- data/vendor/liburing/.github/workflows/ci.yml +94 -1
- data/vendor/liburing/.github/workflows/test_build.c +9 -0
- data/vendor/liburing/configure +27 -0
- data/vendor/liburing/examples/Makefile +6 -0
- data/vendor/liburing/examples/helpers.c +8 -0
- data/vendor/liburing/examples/helpers.h +5 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/src/Makefile +9 -3
- data/vendor/liburing/src/include/liburing/barrier.h +11 -5
- data/vendor/liburing/src/include/liburing/io_uring/query.h +41 -0
- data/vendor/liburing/src/include/liburing/io_uring.h +51 -0
- data/vendor/liburing/src/include/liburing/sanitize.h +16 -4
- data/vendor/liburing/src/include/liburing.h +458 -121
- data/vendor/liburing/src/liburing-ffi.map +16 -0
- data/vendor/liburing/src/liburing.map +8 -0
- data/vendor/liburing/src/sanitize.c +4 -1
- data/vendor/liburing/src/setup.c +7 -4
- data/vendor/liburing/test/232c93d07b74.c +4 -16
- data/vendor/liburing/test/Makefile +15 -1
- data/vendor/liburing/test/accept.c +2 -13
- data/vendor/liburing/test/bind-listen.c +175 -13
- data/vendor/liburing/test/conn-unreach.c +132 -0
- data/vendor/liburing/test/fd-pass.c +32 -7
- data/vendor/liburing/test/fdinfo.c +39 -12
- data/vendor/liburing/test/fifo-futex-poll.c +114 -0
- data/vendor/liburing/test/fifo-nonblock-read.c +1 -12
- data/vendor/liburing/test/futex.c +1 -1
- data/vendor/liburing/test/helpers.c +99 -2
- data/vendor/liburing/test/helpers.h +9 -0
- data/vendor/liburing/test/io_uring_passthrough.c +6 -12
- data/vendor/liburing/test/mock_file.c +379 -0
- data/vendor/liburing/test/mock_file.h +47 -0
- data/vendor/liburing/test/nop.c +2 -2
- data/vendor/liburing/test/nop32-overflow.c +150 -0
- data/vendor/liburing/test/nop32.c +126 -0
- data/vendor/liburing/test/pipe.c +166 -0
- data/vendor/liburing/test/poll-race-mshot.c +13 -1
- data/vendor/liburing/test/read-write.c +4 -4
- data/vendor/liburing/test/recv-mshot-fair.c +81 -34
- data/vendor/liburing/test/recvsend_bundle.c +1 -1
- data/vendor/liburing/test/resize-rings.c +2 -0
- data/vendor/liburing/test/ring-query.c +322 -0
- data/vendor/liburing/test/ringbuf-loop.c +87 -0
- data/vendor/liburing/test/ringbuf-read.c +4 -4
- data/vendor/liburing/test/runtests.sh +2 -2
- data/vendor/liburing/test/send-zerocopy.c +43 -5
- data/vendor/liburing/test/send_recv.c +103 -32
- data/vendor/liburing/test/shutdown.c +2 -12
- data/vendor/liburing/test/socket-nb.c +3 -14
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -12
- data/vendor/liburing/test/socket-rw.c +2 -12
- data/vendor/liburing/test/sqe-mixed-bad-wrap.c +87 -0
- data/vendor/liburing/test/sqe-mixed-nop.c +82 -0
- data/vendor/liburing/test/sqe-mixed-uring_cmd.c +153 -0
- data/vendor/liburing/test/timestamp.c +56 -19
- data/vendor/liburing/test/vec-regbuf.c +2 -4
- data/vendor/liburing/test/wq-aff.c +7 -0
- metadata +37 -15
data/examples/nc_ssl.rb
ADDED
|
@@ -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.
|
|
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
|
-
|
|
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'
|