uringmachine 0.22.1 → 0.23.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/CHANGELOG.md +12 -2
- data/TODO.md +24 -138
- data/benchmark/README.md +1 -1
- data/benchmark/bm_io_pipe.rb +14 -0
- data/benchmark/common.rb +5 -0
- data/benchmark/read_each.rb +83 -0
- data/benchmark/send.rb +31 -36
- data/ext/um/extconf.rb +7 -1
- data/ext/um/um.c +131 -8
- data/ext/um/um.h +8 -0
- data/ext/um/um_class.c +34 -0
- data/ext/um/um_const.c +0 -2
- data/ext/um/um_op.c +20 -2
- data/ext/um/um_utils.c +27 -0
- data/grant-2025/journal.md +2 -2
- data/grant-2025/tasks.md +7 -12
- data/lib/uringmachine/version.rb +1 -1
- data/test/helper.rb +5 -4
- data/test/test_fiber_scheduler.rb +1 -17
- data/test/test_um.rb +299 -62
- data/vendor/liburing/configure +4 -2
- data/vendor/liburing/src/Makefile +1 -0
- data/vendor/liburing/test/min-timeout-wait.c +57 -2
- data/vendor/liburing/test/min-timeout.c +22 -0
- metadata +4 -3
- /data/benchmark/{chart.png → chart_all.png} +0 -0
data/test/test_um.rb
CHANGED
|
@@ -39,7 +39,7 @@ class SQPOLLTest < Minitest::Test
|
|
|
39
39
|
m.write_async(w, 'foo')
|
|
40
40
|
|
|
41
41
|
# thread should timeout
|
|
42
|
-
|
|
42
|
+
t.join(0.03)
|
|
43
43
|
assert_nil buf
|
|
44
44
|
ensure
|
|
45
45
|
t.kill rescue nil
|
|
@@ -220,31 +220,6 @@ class ScheduleTest < UMBaseTest
|
|
|
220
220
|
assert_kind_of TOError, e
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
def test_timeout_stress
|
|
224
|
-
skip
|
|
225
|
-
# GC.stress = true
|
|
226
|
-
c = 0
|
|
227
|
-
fs = 100.times.map {
|
|
228
|
-
machine.spin {
|
|
229
|
-
q = UM::Queue.new
|
|
230
|
-
1000.times {
|
|
231
|
-
machine.sleep rand(0.001..0.005)
|
|
232
|
-
begin
|
|
233
|
-
machine.timeout(rand(0.001..0.06), TOError) do
|
|
234
|
-
machine.shift(q)
|
|
235
|
-
end
|
|
236
|
-
rescue => _e
|
|
237
|
-
c += 1
|
|
238
|
-
STDOUT << '*' if c % 1000 == 0
|
|
239
|
-
end
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
machine.join(*fs)
|
|
244
|
-
ensure
|
|
245
|
-
GC.stress = false
|
|
246
|
-
end
|
|
247
|
-
|
|
248
223
|
def test_timeout_with_raising_block
|
|
249
224
|
e = nil
|
|
250
225
|
begin
|
|
@@ -580,8 +555,6 @@ end
|
|
|
580
555
|
|
|
581
556
|
class ReadEachTest < UMBaseTest
|
|
582
557
|
def test_read_each
|
|
583
|
-
skip if UringMachine.kernel_version < 607
|
|
584
|
-
|
|
585
558
|
r, w = IO.pipe
|
|
586
559
|
bufs = []
|
|
587
560
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
@@ -610,8 +583,6 @@ class ReadEachTest < UMBaseTest
|
|
|
610
583
|
|
|
611
584
|
# send once and close write fd
|
|
612
585
|
def test_read_each_raising_1
|
|
613
|
-
skip if UringMachine.kernel_version < 607
|
|
614
|
-
|
|
615
586
|
r, w = IO.pipe
|
|
616
587
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
617
588
|
assert_equal 0, bgid
|
|
@@ -634,8 +605,6 @@ class ReadEachTest < UMBaseTest
|
|
|
634
605
|
|
|
635
606
|
# send once and leave write fd open
|
|
636
607
|
def test_read_each_raising_2
|
|
637
|
-
skip if UringMachine.kernel_version < 607
|
|
638
|
-
|
|
639
608
|
r, w = IO.pipe
|
|
640
609
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
641
610
|
assert_equal 0, bgid
|
|
@@ -659,8 +628,6 @@ class ReadEachTest < UMBaseTest
|
|
|
659
628
|
|
|
660
629
|
# send twice
|
|
661
630
|
def test_read_each_raising_3
|
|
662
|
-
skip if UringMachine.kernel_version < 607
|
|
663
|
-
|
|
664
631
|
r, w = IO.pipe
|
|
665
632
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
666
633
|
assert_equal 0, bgid
|
|
@@ -684,8 +651,6 @@ class ReadEachTest < UMBaseTest
|
|
|
684
651
|
end
|
|
685
652
|
|
|
686
653
|
def test_read_each_break
|
|
687
|
-
skip if UringMachine.kernel_version < 607
|
|
688
|
-
|
|
689
654
|
r, w = IO.pipe
|
|
690
655
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
691
656
|
|
|
@@ -710,8 +675,6 @@ class ReadEachTest < UMBaseTest
|
|
|
710
675
|
end
|
|
711
676
|
|
|
712
677
|
def test_read_each_bad_file
|
|
713
|
-
skip if UringMachine.kernel_version < 607
|
|
714
|
-
|
|
715
678
|
_r, w = IO.pipe
|
|
716
679
|
bgid = machine.setup_buffer_ring(4096, 1024)
|
|
717
680
|
|
|
@@ -826,6 +789,163 @@ class WriteTest < UMBaseTest
|
|
|
826
789
|
end
|
|
827
790
|
end
|
|
828
791
|
|
|
792
|
+
class WritevTest < UMBaseTest
|
|
793
|
+
def test_writev
|
|
794
|
+
r, w = IO.pipe
|
|
795
|
+
|
|
796
|
+
assert_equal 0, machine.metrics[:ops_pending]
|
|
797
|
+
res = machine.writev(w.fileno, 'foo', 'bar', 'baz')
|
|
798
|
+
assert_equal 9, res
|
|
799
|
+
assert_equal 0, machine.metrics[:ops_pending]
|
|
800
|
+
assert_equal 'foobarbaz', r.readpartial(9)
|
|
801
|
+
|
|
802
|
+
res = machine.writev(w.fileno, 'oofoof', 'rabrab')
|
|
803
|
+
assert_equal 12, res
|
|
804
|
+
assert_equal 'oofoofrabrab', r.readpartial(12)
|
|
805
|
+
end
|
|
806
|
+
|
|
807
|
+
def test_writev_incomplete
|
|
808
|
+
r, w = UM.pipe
|
|
809
|
+
strs = ['1' * 256, '2' * 30000, '3' * 256]
|
|
810
|
+
total_len = strs.map(&:bytesize).reduce(:+)
|
|
811
|
+
|
|
812
|
+
prelim_len = (65536 - 3);
|
|
813
|
+
prelim_msg = '*' * prelim_len
|
|
814
|
+
machine.write(w, prelim_msg)
|
|
815
|
+
|
|
816
|
+
reads = []
|
|
817
|
+
f = machine.spin {
|
|
818
|
+
loop {
|
|
819
|
+
buf = +''
|
|
820
|
+
res = machine.read(r, buf, 8192)
|
|
821
|
+
break if res == 0
|
|
822
|
+
|
|
823
|
+
reads << buf
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
res = machine.writev(w, *strs)
|
|
828
|
+
assert_equal total_len, res
|
|
829
|
+
|
|
830
|
+
machine.close(w)
|
|
831
|
+
machine.join(f)
|
|
832
|
+
|
|
833
|
+
msg_read = reads.join
|
|
834
|
+
msg_expected = [prelim_msg, *strs].join
|
|
835
|
+
|
|
836
|
+
assert_equal msg_expected, msg_read
|
|
837
|
+
ensure
|
|
838
|
+
machine.close(w) rescue nil
|
|
839
|
+
machine.close(r) rescue nil
|
|
840
|
+
machine.join(f)
|
|
841
|
+
end
|
|
842
|
+
|
|
843
|
+
def test_writev_close_r
|
|
844
|
+
r, w = UM.pipe
|
|
845
|
+
strs = ['1' * 256, '2' * 30000, '3' * 256]
|
|
846
|
+
|
|
847
|
+
prelim_len = (65536 - 3);
|
|
848
|
+
prelim_msg = '*' * prelim_len
|
|
849
|
+
machine.write(w, prelim_msg)
|
|
850
|
+
|
|
851
|
+
f = machine.spin {
|
|
852
|
+
buf = +''
|
|
853
|
+
3.times { machine.read(r, buf, 8192) }
|
|
854
|
+
machine.close(w)
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
assert_raises(Errno::EBADF) { machine.writev(w, *strs) }
|
|
858
|
+
ensure
|
|
859
|
+
machine.close(w) rescue nil
|
|
860
|
+
machine.close(r) rescue nil
|
|
861
|
+
machine.join(f)
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
class TOError < RuntimeError; end
|
|
865
|
+
|
|
866
|
+
def test_writev_timeout
|
|
867
|
+
r, w = UM.pipe
|
|
868
|
+
strs = ['1' * 256, '2' * 30000, '3' * 256]
|
|
869
|
+
|
|
870
|
+
prelim_len = (65536 - 3);
|
|
871
|
+
prelim_msg = '*' * prelim_len
|
|
872
|
+
machine.write(w, prelim_msg)
|
|
873
|
+
|
|
874
|
+
assert_raises(TOError) {
|
|
875
|
+
machine.timeout(0.01, TOError) {
|
|
876
|
+
machine.writev(w, *strs)
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
ensure
|
|
880
|
+
machine.close(w) rescue nil
|
|
881
|
+
machine.close(r) rescue nil
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
def test_writev_bad_fd
|
|
885
|
+
r, _w = UM.pipe
|
|
886
|
+
|
|
887
|
+
assert_equal 0, machine.metrics[:ops_pending]
|
|
888
|
+
assert_raises(Errno::EBADF) do
|
|
889
|
+
machine.writev(r, 'foo', 'bar')
|
|
890
|
+
end
|
|
891
|
+
assert_equal 0, machine.metrics[:ops_pending]
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
def test_writev_zero_length
|
|
895
|
+
r, w = IO.pipe
|
|
896
|
+
|
|
897
|
+
res = machine.write(w.fileno, '')
|
|
898
|
+
assert_equal 0, res
|
|
899
|
+
|
|
900
|
+
res = machine.writev(w.fileno, '', '')
|
|
901
|
+
assert_equal 0, res
|
|
902
|
+
|
|
903
|
+
buf1 = IO::Buffer.new(0)
|
|
904
|
+
buf2 = IO::Buffer.new(0)
|
|
905
|
+
res = machine.writev(w.fileno, buf1, buf2)
|
|
906
|
+
assert_equal 0, res
|
|
907
|
+
|
|
908
|
+
w.close
|
|
909
|
+
assert_equal '', r.read
|
|
910
|
+
end
|
|
911
|
+
|
|
912
|
+
def test_writev_io_buffer
|
|
913
|
+
r, w = UM.pipe
|
|
914
|
+
|
|
915
|
+
buf1 = IO::Buffer.new(5)
|
|
916
|
+
buf1.set_string('Hello')
|
|
917
|
+
buf2 = IO::Buffer.new(6)
|
|
918
|
+
buf2.set_string(' world')
|
|
919
|
+
|
|
920
|
+
machine.writev(w, buf1, buf2)
|
|
921
|
+
machine.close(w)
|
|
922
|
+
|
|
923
|
+
str = +''
|
|
924
|
+
machine.read(r, str, 8192)
|
|
925
|
+
assert_equal 'Hello world', str
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
def test_writev_invalid_buffer
|
|
929
|
+
_r, w = UM.pipe
|
|
930
|
+
assert_raises(UM::Error) {
|
|
931
|
+
machine.writev(w, 'abc', [])
|
|
932
|
+
}
|
|
933
|
+
end
|
|
934
|
+
|
|
935
|
+
def test_writev_with_file_offset
|
|
936
|
+
fn = "/tmp/um_#{SecureRandom.hex}"
|
|
937
|
+
IO.write(fn, 'foobar')
|
|
938
|
+
|
|
939
|
+
fd = machine.open(fn, UM::O_WRONLY)
|
|
940
|
+
result = machine.writev(fd, 'bar', 'baz', 2)
|
|
941
|
+
assert_equal 6, result
|
|
942
|
+
assert_equal 'fobarbaz', IO.read(fn)
|
|
943
|
+
ensure
|
|
944
|
+
machine.close(fd)
|
|
945
|
+
FileUtils.rm(fn) rescue nil
|
|
946
|
+
end
|
|
947
|
+
end
|
|
948
|
+
|
|
829
949
|
class WriteAsyncTest < UMBaseTest
|
|
830
950
|
def test_write_async
|
|
831
951
|
r, w = IO.pipe
|
|
@@ -1100,6 +1220,82 @@ class AcceptEachTest < UMBaseTest
|
|
|
1100
1220
|
ensure
|
|
1101
1221
|
s.close
|
|
1102
1222
|
end
|
|
1223
|
+
|
|
1224
|
+
def test_accept_each_bad_fd
|
|
1225
|
+
queue = UM::Queue.new
|
|
1226
|
+
assert_raises(Errno::ENOTSOCK) { machine.accept_each(STDOUT.fileno) }
|
|
1227
|
+
end
|
|
1228
|
+
end
|
|
1229
|
+
|
|
1230
|
+
class AcceptIntoQueueTest < UMBaseTest
|
|
1231
|
+
def setup
|
|
1232
|
+
super
|
|
1233
|
+
@port = assign_port
|
|
1234
|
+
@server = TCPServer.open('127.0.0.1', @port)
|
|
1235
|
+
@server_fd = @server.fileno
|
|
1236
|
+
end
|
|
1237
|
+
|
|
1238
|
+
def teardown
|
|
1239
|
+
@server&.close rescue nil
|
|
1240
|
+
super
|
|
1241
|
+
end
|
|
1242
|
+
|
|
1243
|
+
def test_accept_into_queue
|
|
1244
|
+
conns = []
|
|
1245
|
+
t = Thread.new do
|
|
1246
|
+
sleep 0.05
|
|
1247
|
+
3.times do
|
|
1248
|
+
conns << TCPSocket.new('127.0.0.1', @port)
|
|
1249
|
+
end
|
|
1250
|
+
end
|
|
1251
|
+
|
|
1252
|
+
queue = UM::Queue.new
|
|
1253
|
+
f = machine.spin do
|
|
1254
|
+
machine.accept_into_queue(@server_fd, queue)
|
|
1255
|
+
end
|
|
1256
|
+
t.join
|
|
1257
|
+
machine.sleep(0.01)
|
|
1258
|
+
assert_equal 3, queue.count
|
|
1259
|
+
ensure
|
|
1260
|
+
machine.close(@server_fd)
|
|
1261
|
+
machine.schedule(f, nil)
|
|
1262
|
+
machine.join(f)
|
|
1263
|
+
t&.kill
|
|
1264
|
+
end
|
|
1265
|
+
|
|
1266
|
+
def test_accept_into_queue_interrupted
|
|
1267
|
+
count = 0
|
|
1268
|
+
terminated = nil
|
|
1269
|
+
queue = UM::Queue.new
|
|
1270
|
+
f = @machine.spin do
|
|
1271
|
+
machine.accept_into_queue(@server_fd, queue)
|
|
1272
|
+
rescue UM::Terminate
|
|
1273
|
+
terminated = true
|
|
1274
|
+
end
|
|
1275
|
+
|
|
1276
|
+
s = TCPSocket.new('127.0.0.1', @port)
|
|
1277
|
+
@machine.sleep(0.01)
|
|
1278
|
+
|
|
1279
|
+
assert_equal 1, queue.count
|
|
1280
|
+
refute terminated
|
|
1281
|
+
|
|
1282
|
+
@machine.schedule(f, UM::Terminate.new)
|
|
1283
|
+
@machine.sleep(0.01)
|
|
1284
|
+
|
|
1285
|
+
assert f.done?
|
|
1286
|
+
assert terminated
|
|
1287
|
+
ensure
|
|
1288
|
+
s.close
|
|
1289
|
+
end
|
|
1290
|
+
|
|
1291
|
+
def test_accept_into_queue_bad_fd
|
|
1292
|
+
queue = UM::Queue.new
|
|
1293
|
+
assert_raises(Errno::ENOTSOCK) { machine.accept_into_queue(STDOUT.fileno, queue) }
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
def test_accept_into_queue_bad_queue
|
|
1297
|
+
assert_raises(TypeError) { machine.accept_into_queue(@server_fd, nil) }
|
|
1298
|
+
end
|
|
1103
1299
|
end
|
|
1104
1300
|
|
|
1105
1301
|
class SocketTest < UMBaseTest
|
|
@@ -1190,7 +1386,6 @@ class SendTest < UMBaseTest
|
|
|
1190
1386
|
t&.kill
|
|
1191
1387
|
end
|
|
1192
1388
|
|
|
1193
|
-
|
|
1194
1389
|
def test_send_io_buffer
|
|
1195
1390
|
@port = assign_port
|
|
1196
1391
|
@server = TCPServer.open('127.0.0.1', @port)
|
|
@@ -1263,6 +1458,55 @@ class SendTest < UMBaseTest
|
|
|
1263
1458
|
end
|
|
1264
1459
|
end
|
|
1265
1460
|
|
|
1461
|
+
class SendvTest < UMBaseTest
|
|
1462
|
+
def setup
|
|
1463
|
+
super
|
|
1464
|
+
@s1, @s2 = UM.socketpair(UM::AF_UNIX, UM::SOCK_STREAM, 0)
|
|
1465
|
+
end
|
|
1466
|
+
|
|
1467
|
+
def teardown
|
|
1468
|
+
@machine.close(@s1)
|
|
1469
|
+
@machine.close(@s2)
|
|
1470
|
+
super
|
|
1471
|
+
end
|
|
1472
|
+
|
|
1473
|
+
def test_sendv
|
|
1474
|
+
skip "Unavailable on kernel version < 6.17" if UM.kernel_version < 617
|
|
1475
|
+
|
|
1476
|
+
ret = machine.sendv(@s1, 'foo', 'bar', 'baz')
|
|
1477
|
+
assert_equal 9, ret
|
|
1478
|
+
|
|
1479
|
+
buf = +''
|
|
1480
|
+
ret = machine.read(@s2, buf, 8192)
|
|
1481
|
+
assert_equal 9, ret
|
|
1482
|
+
assert_equal 'foobarbaz', buf
|
|
1483
|
+
end
|
|
1484
|
+
|
|
1485
|
+
def test_sendv_io_buffer
|
|
1486
|
+
skip "Unavailable on kernel version < 6.17" if UM.kernel_version < 617
|
|
1487
|
+
|
|
1488
|
+
buf1 = IO::Buffer.new(6)
|
|
1489
|
+
buf1.set_string('foobar')
|
|
1490
|
+
|
|
1491
|
+
buf2 = IO::Buffer.new(3)
|
|
1492
|
+
buf2.set_string('baz')
|
|
1493
|
+
|
|
1494
|
+
ret = machine.sendv(@s1, buf1, buf2)
|
|
1495
|
+
assert_equal 9, ret
|
|
1496
|
+
|
|
1497
|
+
buf = +''
|
|
1498
|
+
ret = machine.read(@s2, buf, 8192)
|
|
1499
|
+
assert_equal 9, ret
|
|
1500
|
+
assert_equal 'foobarbaz', buf
|
|
1501
|
+
end
|
|
1502
|
+
|
|
1503
|
+
def test_sendv_invalid_buffer
|
|
1504
|
+
skip "Unavailable on kernel version < 6.17" if UM.kernel_version < 617
|
|
1505
|
+
|
|
1506
|
+
assert_raises(UM::Error) { machine.sendv(@s1, [], 'abc') }
|
|
1507
|
+
end
|
|
1508
|
+
end
|
|
1509
|
+
|
|
1266
1510
|
class RecvTest < UMBaseTest
|
|
1267
1511
|
def setup
|
|
1268
1512
|
super
|
|
@@ -1694,7 +1938,6 @@ class QueueTest < UMBaseTest
|
|
|
1694
1938
|
}
|
|
1695
1939
|
|
|
1696
1940
|
t1.join
|
|
1697
|
-
q = UM::Queue.new
|
|
1698
1941
|
machine.push(worker_queue, :STOP)
|
|
1699
1942
|
t2.join
|
|
1700
1943
|
|
|
@@ -2019,7 +2262,7 @@ class WaitidTest < UMBaseTest
|
|
|
2019
2262
|
end
|
|
2020
2263
|
|
|
2021
2264
|
def test_waitid_status
|
|
2022
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2265
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2023
2266
|
|
|
2024
2267
|
msg = 'hello from child'
|
|
2025
2268
|
_rfd, wfd = UM.pipe
|
|
@@ -2039,7 +2282,7 @@ class WaitidTest < UMBaseTest
|
|
|
2039
2282
|
end
|
|
2040
2283
|
|
|
2041
2284
|
def test_waitid_status_invalid_pid
|
|
2042
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2285
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2043
2286
|
|
|
2044
2287
|
assert_raises(Errno::ECHILD) {
|
|
2045
2288
|
machine.waitid_status(UM::P_PID, Process.pid + 1, UM::WEXITED)
|
|
@@ -2047,7 +2290,7 @@ class WaitidTest < UMBaseTest
|
|
|
2047
2290
|
end
|
|
2048
2291
|
|
|
2049
2292
|
def test_waitid_status_invalid_idtype
|
|
2050
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2293
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2051
2294
|
|
|
2052
2295
|
assert_raises(Errno::EINVAL) {
|
|
2053
2296
|
machine.waitid_status(1234, 0, UM::WEXITED)
|
|
@@ -2055,7 +2298,7 @@ class WaitidTest < UMBaseTest
|
|
|
2055
2298
|
end
|
|
2056
2299
|
|
|
2057
2300
|
def test_waitid_status_invalid_options
|
|
2058
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2301
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2059
2302
|
|
|
2060
2303
|
assert_raises(Errno::EINVAL) {
|
|
2061
2304
|
machine.waitid_status(P_ALL, 0, 1234)
|
|
@@ -2063,7 +2306,7 @@ class WaitidTest < UMBaseTest
|
|
|
2063
2306
|
end
|
|
2064
2307
|
|
|
2065
2308
|
def test_waitid_status_P_ALL
|
|
2066
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2309
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2067
2310
|
|
|
2068
2311
|
msg = 'hello from child'
|
|
2069
2312
|
_rfd, wfd = UM.pipe
|
|
@@ -2083,7 +2326,7 @@ class WaitidTest < UMBaseTest
|
|
|
2083
2326
|
end
|
|
2084
2327
|
|
|
2085
2328
|
def test_waitid_status_P_PGID
|
|
2086
|
-
skip if !machine.respond_to?(:waitid_status)
|
|
2329
|
+
skip "waitid_status not available" if !machine.respond_to?(:waitid_status)
|
|
2087
2330
|
|
|
2088
2331
|
msg = 'hello from child'
|
|
2089
2332
|
_rfd, wfd = UM.pipe
|
|
@@ -2198,8 +2441,6 @@ class SendBundleTest < UMBaseTest
|
|
|
2198
2441
|
end
|
|
2199
2442
|
|
|
2200
2443
|
def test_send_bundle_splat
|
|
2201
|
-
skip if UringMachine.kernel_version < 610
|
|
2202
|
-
|
|
2203
2444
|
bgid = machine.setup_buffer_ring(0, 8)
|
|
2204
2445
|
assert_equal 0, bgid
|
|
2205
2446
|
|
|
@@ -2216,8 +2457,6 @@ class SendBundleTest < UMBaseTest
|
|
|
2216
2457
|
end
|
|
2217
2458
|
|
|
2218
2459
|
def test_send_bundle_array
|
|
2219
|
-
skip if UringMachine.kernel_version < 610
|
|
2220
|
-
|
|
2221
2460
|
bgid = machine.setup_buffer_ring(0, 8)
|
|
2222
2461
|
assert_equal 0, bgid
|
|
2223
2462
|
|
|
@@ -2234,8 +2473,6 @@ class SendBundleTest < UMBaseTest
|
|
|
2234
2473
|
end
|
|
2235
2474
|
|
|
2236
2475
|
def test_send_bundle_non_strings
|
|
2237
|
-
skip if UringMachine.kernel_version < 610
|
|
2238
|
-
|
|
2239
2476
|
bgid = machine.setup_buffer_ring(0, 8)
|
|
2240
2477
|
assert_equal 0, bgid
|
|
2241
2478
|
|
|
@@ -2360,28 +2597,28 @@ class MetricsTest < UMBaseTest
|
|
|
2360
2597
|
end
|
|
2361
2598
|
|
|
2362
2599
|
def test_metrics_ops
|
|
2363
|
-
|
|
2600
|
+
_r, w = UM.pipe
|
|
2364
2601
|
|
|
2365
2602
|
f = machine.spin { machine.sleep(0.001) }
|
|
2366
|
-
assert_equal [0, 0, 1,
|
|
2603
|
+
assert_equal [0, 0, 1, 255, 0], ops_metrics
|
|
2367
2604
|
machine.snooze
|
|
2368
|
-
assert_equal [1, 1, 0,
|
|
2605
|
+
assert_equal [1, 1, 0, 256, 0], ops_metrics
|
|
2369
2606
|
machine.submit
|
|
2370
|
-
assert_equal [1, 0, 0,
|
|
2607
|
+
assert_equal [1, 0, 0, 256, 0], ops_metrics
|
|
2371
2608
|
machine.join(f)
|
|
2372
|
-
assert_equal [0, 0, 0,
|
|
2609
|
+
assert_equal [0, 0, 0, 256, 0], ops_metrics
|
|
2373
2610
|
|
|
2374
2611
|
machine.write_async(w, 'foo')
|
|
2375
|
-
assert_equal [1, 1, 0,
|
|
2612
|
+
assert_equal [1, 1, 0, 255, 1], ops_metrics
|
|
2376
2613
|
machine.submit
|
|
2377
|
-
assert_equal [1, 0, 0,
|
|
2614
|
+
assert_equal [1, 0, 0, 255, 1], ops_metrics
|
|
2378
2615
|
machine.snooze
|
|
2379
|
-
assert_equal [0, 0, 0,
|
|
2616
|
+
assert_equal [0, 0, 0, 256, 0], ops_metrics
|
|
2380
2617
|
|
|
2381
2618
|
machine.write_async(w, 'foo')
|
|
2382
|
-
assert_equal [1, 1, 0,
|
|
2619
|
+
assert_equal [1, 1, 0, 255, 1], ops_metrics
|
|
2383
2620
|
machine.snooze
|
|
2384
|
-
assert_equal [0, 0, 0,
|
|
2621
|
+
assert_equal [0, 0, 0, 256, 0], ops_metrics
|
|
2385
2622
|
ensure
|
|
2386
2623
|
machine.join(f)
|
|
2387
2624
|
end
|
data/vendor/liburing/configure
CHANGED
|
@@ -120,8 +120,9 @@ print_config() {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
# Default CFLAGS
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
ENV_CFLAGS="${CFLAGS}"
|
|
124
|
+
CFLAGS="${CFLAGS:+$CFLAGS }-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -include config-host.h"
|
|
125
|
+
BUILD_CFLAGS="${ENV_CFLAGS}"
|
|
125
126
|
|
|
126
127
|
# Print configure header at the top of $config_host_h
|
|
127
128
|
echo "/*" > $config_host_h
|
|
@@ -588,6 +589,7 @@ fi
|
|
|
588
589
|
echo "CC=$cc" >> $config_host_mak
|
|
589
590
|
print_config "CC" "$cc"
|
|
590
591
|
echo "CXX=$cxx" >> $config_host_mak
|
|
592
|
+
echo "BUILD_CFLAGS=$BUILD_CFLAGS" >> $config_host_mak
|
|
591
593
|
print_config "CXX" "$cxx"
|
|
592
594
|
|
|
593
595
|
# generate io_uring_version.h
|
|
@@ -237,9 +237,9 @@ static int test_min_wait_equal(struct io_uring *ring)
|
|
|
237
237
|
|
|
238
238
|
int main(int argc, char *argv[])
|
|
239
239
|
{
|
|
240
|
-
struct io_uring ring1, ring2;
|
|
240
|
+
struct io_uring ring1, ring2, ring3;
|
|
241
241
|
struct io_uring_params p = { };
|
|
242
|
-
int ret;
|
|
242
|
+
int ret, no_sq_poll = 0;
|
|
243
243
|
|
|
244
244
|
if (argc > 1)
|
|
245
245
|
return 0;
|
|
@@ -259,6 +259,11 @@ int main(int argc, char *argv[])
|
|
|
259
259
|
else if (ret != T_SETUP_OK)
|
|
260
260
|
return ret;
|
|
261
261
|
|
|
262
|
+
p.flags = IORING_SETUP_SQPOLL;
|
|
263
|
+
ret = t_create_ring_params(8, &ring3, &p);
|
|
264
|
+
if (ret != T_SETUP_OK)
|
|
265
|
+
no_sq_poll = 1;
|
|
266
|
+
|
|
262
267
|
ret = test_already(&ring1);
|
|
263
268
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
264
269
|
return ret;
|
|
@@ -267,6 +272,12 @@ int main(int argc, char *argv[])
|
|
|
267
272
|
if (ret == T_EXIT_FAIL)
|
|
268
273
|
return T_EXIT_FAIL;
|
|
269
274
|
|
|
275
|
+
if (!no_sq_poll) {
|
|
276
|
+
ret = test_already(&ring3);
|
|
277
|
+
if (ret == T_EXIT_FAIL)
|
|
278
|
+
return T_EXIT_FAIL;
|
|
279
|
+
}
|
|
280
|
+
|
|
270
281
|
ret = test_some(&ring1);
|
|
271
282
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
272
283
|
return ret;
|
|
@@ -275,6 +286,12 @@ int main(int argc, char *argv[])
|
|
|
275
286
|
if (ret == T_EXIT_FAIL)
|
|
276
287
|
return T_EXIT_FAIL;
|
|
277
288
|
|
|
289
|
+
if (!no_sq_poll) {
|
|
290
|
+
ret = test_some(&ring3);
|
|
291
|
+
if (ret == T_EXIT_FAIL)
|
|
292
|
+
return T_EXIT_FAIL;
|
|
293
|
+
}
|
|
294
|
+
|
|
278
295
|
ret = test_late(&ring1);
|
|
279
296
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
280
297
|
return ret;
|
|
@@ -283,6 +300,12 @@ int main(int argc, char *argv[])
|
|
|
283
300
|
if (ret == T_EXIT_FAIL)
|
|
284
301
|
return T_EXIT_FAIL;
|
|
285
302
|
|
|
303
|
+
if (!no_sq_poll) {
|
|
304
|
+
ret = test_late(&ring3);
|
|
305
|
+
if (ret == T_EXIT_FAIL)
|
|
306
|
+
return T_EXIT_FAIL;
|
|
307
|
+
}
|
|
308
|
+
|
|
286
309
|
ret = test_post_wait(&ring1);
|
|
287
310
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
288
311
|
return ret;
|
|
@@ -291,6 +314,12 @@ int main(int argc, char *argv[])
|
|
|
291
314
|
if (ret == T_EXIT_FAIL)
|
|
292
315
|
return T_EXIT_FAIL;
|
|
293
316
|
|
|
317
|
+
if (!no_sq_poll) {
|
|
318
|
+
ret = test_post_wait(&ring3);
|
|
319
|
+
if (ret == T_EXIT_FAIL)
|
|
320
|
+
return T_EXIT_FAIL;
|
|
321
|
+
}
|
|
322
|
+
|
|
294
323
|
ret = test_some_wait(&ring1);
|
|
295
324
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
296
325
|
return ret;
|
|
@@ -299,6 +328,12 @@ int main(int argc, char *argv[])
|
|
|
299
328
|
if (ret == T_EXIT_FAIL)
|
|
300
329
|
return T_EXIT_FAIL;
|
|
301
330
|
|
|
331
|
+
if (!no_sq_poll) {
|
|
332
|
+
ret = test_some_wait(&ring3);
|
|
333
|
+
if (ret == T_EXIT_FAIL)
|
|
334
|
+
return T_EXIT_FAIL;
|
|
335
|
+
}
|
|
336
|
+
|
|
302
337
|
ret = test_nothing(&ring1);
|
|
303
338
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
304
339
|
return ret;
|
|
@@ -307,6 +342,12 @@ int main(int argc, char *argv[])
|
|
|
307
342
|
if (ret == T_EXIT_FAIL)
|
|
308
343
|
return T_EXIT_FAIL;
|
|
309
344
|
|
|
345
|
+
if (!no_sq_poll) {
|
|
346
|
+
ret = test_nothing(&ring3);
|
|
347
|
+
if (ret == T_EXIT_FAIL)
|
|
348
|
+
return T_EXIT_FAIL;
|
|
349
|
+
}
|
|
350
|
+
|
|
310
351
|
ret = test_min_wait_biggest(&ring1);
|
|
311
352
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
312
353
|
return ret;
|
|
@@ -315,6 +356,12 @@ int main(int argc, char *argv[])
|
|
|
315
356
|
if (ret == T_EXIT_FAIL)
|
|
316
357
|
return T_EXIT_FAIL;
|
|
317
358
|
|
|
359
|
+
if (!no_sq_poll) {
|
|
360
|
+
ret = test_min_wait_biggest(&ring3);
|
|
361
|
+
if (ret == T_EXIT_FAIL)
|
|
362
|
+
return T_EXIT_FAIL;
|
|
363
|
+
}
|
|
364
|
+
|
|
318
365
|
ret = test_min_wait_equal(&ring1);
|
|
319
366
|
if (ret == T_EXIT_FAIL || ret == T_EXIT_SKIP)
|
|
320
367
|
return ret;
|
|
@@ -323,7 +370,15 @@ int main(int argc, char *argv[])
|
|
|
323
370
|
if (ret == T_EXIT_FAIL)
|
|
324
371
|
return T_EXIT_FAIL;
|
|
325
372
|
|
|
373
|
+
if (!no_sq_poll) {
|
|
374
|
+
ret = test_min_wait_equal(&ring3);
|
|
375
|
+
if (ret == T_EXIT_FAIL)
|
|
376
|
+
return T_EXIT_FAIL;
|
|
377
|
+
}
|
|
378
|
+
|
|
326
379
|
io_uring_queue_exit(&ring1);
|
|
327
380
|
io_uring_queue_exit(&ring2);
|
|
381
|
+
if (!no_sq_poll)
|
|
382
|
+
io_uring_queue_exit(&ring3);
|
|
328
383
|
return T_EXIT_PASS;
|
|
329
384
|
}
|
|
@@ -204,5 +204,27 @@ int main(int argc, char *argv[])
|
|
|
204
204
|
if (ret == T_EXIT_FAIL)
|
|
205
205
|
return T_EXIT_FAIL;
|
|
206
206
|
|
|
207
|
+
ret = test(IORING_SETUP_SQPOLL, 1, 0, 2000, NWRITES, WAIT_USEC / 1000);
|
|
208
|
+
if (ret == T_EXIT_FAIL)
|
|
209
|
+
return T_EXIT_FAIL;
|
|
210
|
+
|
|
211
|
+
ret = test(IORING_SETUP_SQPOLL, 1, 50000, 2000, NWRITES, 50);
|
|
212
|
+
if (ret == T_EXIT_FAIL)
|
|
213
|
+
return T_EXIT_FAIL;
|
|
214
|
+
|
|
215
|
+
ret = test(IORING_SETUP_SQPOLL, 1, 500000, 2000, NWRITES, 500);
|
|
216
|
+
if (ret == T_EXIT_FAIL)
|
|
217
|
+
return T_EXIT_FAIL;
|
|
218
|
+
|
|
219
|
+
/* no writes within min timeout, but it's given. expect 1 cqe */
|
|
220
|
+
ret = test(IORING_SETUP_SQPOLL, 1, 10000, 20000, 1, 20);
|
|
221
|
+
if (ret == T_EXIT_FAIL)
|
|
222
|
+
return T_EXIT_FAIL;
|
|
223
|
+
|
|
224
|
+
/* same as above, but no min timeout. should time out and we get 6 */
|
|
225
|
+
ret = test(IORING_SETUP_SQPOLL, 1, 0, 20000, NWRITES, WAIT_USEC / 1000);
|
|
226
|
+
if (ret == T_EXIT_FAIL)
|
|
227
|
+
return T_EXIT_FAIL;
|
|
228
|
+
|
|
207
229
|
return ret;
|
|
208
230
|
}
|