uringmachine 0.4 → 0.5

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -1
  3. data/CHANGELOG.md +14 -0
  4. data/README.md +44 -1
  5. data/TODO.md +12 -3
  6. data/examples/bm_snooze.rb +89 -0
  7. data/examples/bm_write.rb +56 -0
  8. data/examples/dns_client.rb +12 -0
  9. data/examples/http_server.rb +42 -43
  10. data/examples/server_client.rb +64 -0
  11. data/examples/snooze.rb +44 -0
  12. data/examples/write_dev_null.rb +16 -0
  13. data/ext/um/extconf.rb +24 -14
  14. data/ext/um/um.c +468 -414
  15. data/ext/um/um.h +129 -39
  16. data/ext/um/um_buffer.c +49 -0
  17. data/ext/um/um_class.c +148 -24
  18. data/ext/um/um_const.c +30 -1
  19. data/ext/um/um_ext.c +4 -0
  20. data/ext/um/um_mutex_class.c +47 -0
  21. data/ext/um/um_op.c +86 -111
  22. data/ext/um/um_queue_class.c +58 -0
  23. data/ext/um/um_sync.c +273 -0
  24. data/ext/um/um_utils.c +1 -1
  25. data/lib/uringmachine/dns_resolver.rb +84 -0
  26. data/lib/uringmachine/version.rb +1 -1
  27. data/lib/uringmachine.rb +19 -3
  28. data/supressions/ruby.supp +71 -0
  29. data/test/test_um.rb +466 -47
  30. data/vendor/liburing/.gitignore +5 -0
  31. data/vendor/liburing/CHANGELOG +1 -0
  32. data/vendor/liburing/configure +32 -0
  33. data/vendor/liburing/examples/Makefile +1 -0
  34. data/vendor/liburing/examples/reg-wait.c +159 -0
  35. data/vendor/liburing/liburing.spec +1 -1
  36. data/vendor/liburing/src/include/liburing/io_uring.h +48 -2
  37. data/vendor/liburing/src/include/liburing.h +28 -2
  38. data/vendor/liburing/src/int_flags.h +10 -3
  39. data/vendor/liburing/src/liburing-ffi.map +13 -2
  40. data/vendor/liburing/src/liburing.map +9 -0
  41. data/vendor/liburing/src/queue.c +25 -16
  42. data/vendor/liburing/src/register.c +73 -4
  43. data/vendor/liburing/src/setup.c +46 -18
  44. data/vendor/liburing/src/setup.h +6 -0
  45. data/vendor/liburing/test/Makefile +7 -0
  46. data/vendor/liburing/test/cmd-discard.c +427 -0
  47. data/vendor/liburing/test/fifo-nonblock-read.c +69 -0
  48. data/vendor/liburing/test/file-exit-unreg.c +48 -0
  49. data/vendor/liburing/test/io_uring_passthrough.c +2 -0
  50. data/vendor/liburing/test/io_uring_register.c +13 -2
  51. data/vendor/liburing/test/napi-test.c +1 -1
  52. data/vendor/liburing/test/no-mmap-inval.c +1 -1
  53. data/vendor/liburing/test/read-mshot-empty.c +2 -0
  54. data/vendor/liburing/test/read-mshot-stdin.c +121 -0
  55. data/vendor/liburing/test/read-mshot.c +6 -0
  56. data/vendor/liburing/test/recvsend_bundle.c +2 -2
  57. data/vendor/liburing/test/reg-fd-only.c +1 -1
  58. data/vendor/liburing/test/reg-wait.c +251 -0
  59. data/vendor/liburing/test/regbuf-clone.c +458 -0
  60. data/vendor/liburing/test/resize-rings.c +643 -0
  61. data/vendor/liburing/test/rsrc_tags.c +1 -1
  62. data/vendor/liburing/test/sqpoll-sleep.c +39 -8
  63. data/vendor/liburing/test/sqwait.c +136 -0
  64. data/vendor/liburing/test/sync-cancel.c +8 -1
  65. data/vendor/liburing/test/timeout.c +13 -8
  66. metadata +22 -4
  67. data/examples/http_server_multishot.rb +0 -57
  68. 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
- raise RuntimeError, "Unhandled fiber exception: #{e.inspect}"
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
- end.tap { |f| schedule(f, value) }
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
+ }