uringmachine 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -1
- data/CHANGELOG.md +14 -0
- data/README.md +44 -1
- data/TODO.md +12 -3
- data/examples/bm_snooze.rb +89 -0
- data/examples/bm_write.rb +56 -0
- data/examples/dns_client.rb +12 -0
- data/examples/http_server.rb +42 -43
- data/examples/server_client.rb +64 -0
- data/examples/snooze.rb +44 -0
- data/examples/write_dev_null.rb +16 -0
- data/ext/um/extconf.rb +24 -14
- data/ext/um/um.c +468 -414
- data/ext/um/um.h +129 -39
- data/ext/um/um_buffer.c +49 -0
- data/ext/um/um_class.c +148 -24
- data/ext/um/um_const.c +30 -1
- data/ext/um/um_ext.c +4 -0
- data/ext/um/um_mutex_class.c +47 -0
- data/ext/um/um_op.c +86 -111
- data/ext/um/um_queue_class.c +58 -0
- data/ext/um/um_sync.c +273 -0
- data/ext/um/um_utils.c +1 -1
- data/lib/uringmachine/dns_resolver.rb +84 -0
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +19 -3
- data/supressions/ruby.supp +71 -0
- data/test/test_um.rb +466 -47
- data/vendor/liburing/.gitignore +5 -0
- data/vendor/liburing/CHANGELOG +1 -0
- data/vendor/liburing/configure +32 -0
- data/vendor/liburing/examples/Makefile +1 -0
- data/vendor/liburing/examples/reg-wait.c +159 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/src/include/liburing/io_uring.h +48 -2
- data/vendor/liburing/src/include/liburing.h +28 -2
- data/vendor/liburing/src/int_flags.h +10 -3
- data/vendor/liburing/src/liburing-ffi.map +13 -2
- data/vendor/liburing/src/liburing.map +9 -0
- data/vendor/liburing/src/queue.c +25 -16
- data/vendor/liburing/src/register.c +73 -4
- data/vendor/liburing/src/setup.c +46 -18
- data/vendor/liburing/src/setup.h +6 -0
- data/vendor/liburing/test/Makefile +7 -0
- data/vendor/liburing/test/cmd-discard.c +427 -0
- data/vendor/liburing/test/fifo-nonblock-read.c +69 -0
- data/vendor/liburing/test/file-exit-unreg.c +48 -0
- data/vendor/liburing/test/io_uring_passthrough.c +2 -0
- data/vendor/liburing/test/io_uring_register.c +13 -2
- data/vendor/liburing/test/napi-test.c +1 -1
- data/vendor/liburing/test/no-mmap-inval.c +1 -1
- data/vendor/liburing/test/read-mshot-empty.c +2 -0
- data/vendor/liburing/test/read-mshot-stdin.c +121 -0
- data/vendor/liburing/test/read-mshot.c +6 -0
- data/vendor/liburing/test/recvsend_bundle.c +2 -2
- data/vendor/liburing/test/reg-fd-only.c +1 -1
- data/vendor/liburing/test/reg-wait.c +251 -0
- data/vendor/liburing/test/regbuf-clone.c +458 -0
- data/vendor/liburing/test/resize-rings.c +643 -0
- data/vendor/liburing/test/rsrc_tags.c +1 -1
- data/vendor/liburing/test/sqpoll-sleep.c +39 -8
- data/vendor/liburing/test/sqwait.c +136 -0
- data/vendor/liburing/test/sync-cancel.c +8 -1
- data/vendor/liburing/test/timeout.c +13 -8
- metadata +22 -4
- data/examples/http_server_multishot.rb +0 -57
- data/examples/http_server_simpler.rb +0 -34
data/lib/uringmachine.rb
CHANGED
@@ -1,17 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative './um_ext'
|
4
|
+
require_relative 'uringmachine/dns_resolver'
|
4
5
|
|
5
6
|
UM = UringMachine
|
6
7
|
|
7
8
|
class UringMachine
|
9
|
+
@@fiber_map = {}
|
10
|
+
|
8
11
|
def spin(value = nil, &block)
|
9
|
-
Fiber.new do |resume_value|
|
12
|
+
f = Fiber.new do |resume_value|
|
10
13
|
block.(resume_value)
|
11
14
|
rescue Exception => e
|
12
|
-
|
15
|
+
STDERR.puts "Unhandled fiber exception: #{e.inspect}"
|
16
|
+
STDERR.puts e.backtrace.join("\n")
|
17
|
+
exit
|
13
18
|
ensure
|
19
|
+
@@fiber_map.delete(f)
|
20
|
+
# yield control
|
14
21
|
self.yield
|
15
|
-
|
22
|
+
p :bad_bad_bad
|
23
|
+
end
|
24
|
+
schedule(f, value)
|
25
|
+
@@fiber_map[f] = true
|
26
|
+
f
|
27
|
+
end
|
28
|
+
|
29
|
+
def resolve(hostname, type = :A)
|
30
|
+
@resolver ||= DNSResolver.new(self)
|
31
|
+
@resolver.resolve(hostname, type)
|
16
32
|
end
|
17
33
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
{
|
2
|
+
On platforms where memcpy is safe for overlapped memory, the compiler will sometimes replace memmove with memcpy. Valgrind may report a false positive.
|
3
|
+
Memcheck:Overlap
|
4
|
+
fun:__memcpy_chk
|
5
|
+
fun:memmove
|
6
|
+
...
|
7
|
+
}
|
8
|
+
{
|
9
|
+
Requiring a file will add it to the loaded features, which may be reported as a leak.
|
10
|
+
Memcheck:Leak
|
11
|
+
...
|
12
|
+
fun:require_internal
|
13
|
+
...
|
14
|
+
}
|
15
|
+
{
|
16
|
+
recursive_list_access creates a hash called `list` that is stored on the threadptr_recursive_hash. This is reported as a memory leak.
|
17
|
+
Memcheck:Leak
|
18
|
+
...
|
19
|
+
fun:rb_ident_hash_new
|
20
|
+
fun:recursive_list_access
|
21
|
+
fun:exec_recursive
|
22
|
+
...
|
23
|
+
}
|
24
|
+
{
|
25
|
+
"Invalid read of size 8" when marking the stack of fibers
|
26
|
+
Memcheck:Addr8
|
27
|
+
fun:each_location*
|
28
|
+
...
|
29
|
+
}
|
30
|
+
{
|
31
|
+
Rust probes for statx(buf), will be fixed in Valgrind >= 3.1.6.0
|
32
|
+
Memcheck:Param
|
33
|
+
statx(buf)
|
34
|
+
...
|
35
|
+
fun:*try_statx*
|
36
|
+
...
|
37
|
+
}
|
38
|
+
{
|
39
|
+
Rust probes for statx(file_name), will be fixed in Valgrind >= 3.1.6.0
|
40
|
+
Memcheck:Param
|
41
|
+
statx(file_name)
|
42
|
+
...
|
43
|
+
fun:*try_statx*
|
44
|
+
...
|
45
|
+
}
|
46
|
+
{
|
47
|
+
strscan_do_scan in strscan.c will sometimes replace the ptr of the regex, which can be reported as a memory leak if the regex is stored in an iseq. https://github.com/ruby/ruby/pull/8136
|
48
|
+
Memcheck:Leak
|
49
|
+
...
|
50
|
+
fun:rb_reg_prepare_re
|
51
|
+
fun:strscan_do_scan
|
52
|
+
...
|
53
|
+
}
|
54
|
+
{
|
55
|
+
The callcache table (RCLASS_CC_TBL) is lazily created, so it is allocated when the first method that gets cached. If this happens in a native extension, it may be reported as a memory leak.
|
56
|
+
Memcheck:Leak
|
57
|
+
...
|
58
|
+
fun:rb_id_table_create
|
59
|
+
...
|
60
|
+
fun:rb_callable_method_entry
|
61
|
+
...
|
62
|
+
}
|
63
|
+
{
|
64
|
+
The date library lazily initializes Regexps using static local variables through the function `regcomp`. The Regexp will end up being reported as a memory leak.
|
65
|
+
Memcheck:Leak
|
66
|
+
...
|
67
|
+
fun:rb_enc_reg_new
|
68
|
+
...
|
69
|
+
fun:date__parse
|
70
|
+
...
|
71
|
+
}
|