polyphony 0.49.1 → 0.49.2
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 +5 -0
- data/Gemfile.lock +1 -1
- data/examples/performance/thread-vs-fiber/polyphony_server.rb +2 -4
- data/ext/polyphony/backend_io_uring.c +0 -2
- data/lib/polyphony/extensions/fiber.rb +9 -8
- data/lib/polyphony/extensions/thread.rb +1 -2
- data/lib/polyphony/version.rb +1 -1
- data/test/helper.rb +1 -2
- data/test/test_backend.rb +25 -0
- data/test/test_fiber.rb +15 -0
- data/test/test_signal.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18278f9c013191fd5a96520a07e3b6e5c4bc088665a1b1a769b02552bd0e5448
|
4
|
+
data.tar.gz: 4e1e42fa5e2a6ddc6dcff7982415dd16246a0d75212aa2eb9ae7a97e030a2bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483158709045a9dc59fa75c912067c4fafbb02885e15f3fa57f482b97903a0c919abbb5ad19bea85837222a44d5ec2778f1e1421839c2e6a595a64e84f2d707d
|
7
|
+
data.tar.gz: c1162de70de5aa2d92804e7c4ccb3a372c5839d5600a7f68ae6f84363677a52f23923dbe8e407a84607ac4f0145736c7a5b9ada8b4956fd9c742cec182ed3a70
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -26,15 +26,13 @@ def write_response(socket)
|
|
26
26
|
socket.write "HTTP/1.1 #{status_code}\r\n#{headers}\r\n#{data}"
|
27
27
|
end
|
28
28
|
|
29
|
-
server = TCPServer.open('0.0.0.0',
|
30
|
-
puts "pid #{Process.pid} Polyphony (#{Thread.current.backend.kind}) listening on port
|
29
|
+
server = TCPServer.open('0.0.0.0', 4411)
|
30
|
+
puts "pid #{Process.pid} Polyphony (#{Thread.current.backend.kind}) listening on port 4411"
|
31
31
|
|
32
32
|
spin_loop(interval: 10) do
|
33
33
|
p Thread.current.fiber_scheduling_stats
|
34
34
|
end
|
35
35
|
|
36
|
-
GC.disable
|
37
|
-
|
38
36
|
server.accept_loop do |c|
|
39
37
|
spin { handle_client(c) }
|
40
38
|
end
|
@@ -263,9 +263,7 @@ int io_uring_backend_defer_submit_and_await(
|
|
263
263
|
// io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
|
264
264
|
io_uring_backend_defer_submit(backend);
|
265
265
|
|
266
|
-
backend->pending_count++;
|
267
266
|
switchpoint_result = backend_await(backend);
|
268
|
-
backend->pending_count--;
|
269
267
|
|
270
268
|
if (!ctx->completed) {
|
271
269
|
ctx->result = -ECANCELED;
|
@@ -245,8 +245,12 @@ module Polyphony
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def shutdown_all_children(graceful = false)
|
248
|
-
|
249
|
-
|
248
|
+
return unless @children
|
249
|
+
|
250
|
+
@children.keys.each do |c|
|
251
|
+
c.terminate(graceful)
|
252
|
+
c.await
|
253
|
+
end
|
250
254
|
end
|
251
255
|
end
|
252
256
|
|
@@ -319,13 +323,10 @@ module Polyphony
|
|
319
323
|
# the children are shut down, it is returned along with the uncaught_exception
|
320
324
|
# flag set. Otherwise, it returns the given arguments.
|
321
325
|
def finalize_children(result, uncaught_exception)
|
322
|
-
|
323
|
-
shutdown_all_children
|
324
|
-
rescue Exception => e
|
325
|
-
result = e
|
326
|
-
uncaught_exception = true
|
327
|
-
end
|
326
|
+
shutdown_all_children
|
328
327
|
[result, uncaught_exception]
|
328
|
+
rescue Exception => e
|
329
|
+
[e, true]
|
329
330
|
end
|
330
331
|
|
331
332
|
def inform_dependants(result, uncaught_exception)
|
@@ -41,8 +41,7 @@ class ::Thread
|
|
41
41
|
|
42
42
|
def finalize(result)
|
43
43
|
unless Fiber.current.children.empty?
|
44
|
-
Fiber.current.
|
45
|
-
Fiber.current.await_all_children
|
44
|
+
Fiber.current.shutdown_all_children
|
46
45
|
end
|
47
46
|
@finalization_mutex.synchronize do
|
48
47
|
@terminated = true
|
data/lib/polyphony/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -57,8 +57,7 @@ class MiniTest::Test
|
|
57
57
|
|
58
58
|
def teardown
|
59
59
|
# trace "* teardown #{self.name}"
|
60
|
-
Fiber.current.
|
61
|
-
Fiber.current.await_all_children
|
60
|
+
Fiber.current.shutdown_all_children
|
62
61
|
Fiber.current.instance_variable_set(:@auto_watcher, nil)
|
63
62
|
rescue => e
|
64
63
|
puts e
|
data/test/test_backend.rb
CHANGED
@@ -100,6 +100,31 @@ class BackendTest < MiniTest::Test
|
|
100
100
|
assert_equal [:ready, 'foo', 'bar', :done], buf
|
101
101
|
end
|
102
102
|
|
103
|
+
def test_read_loop_terminate
|
104
|
+
i, o = IO.pipe
|
105
|
+
|
106
|
+
buf = []
|
107
|
+
parent = spin do
|
108
|
+
f = spin do
|
109
|
+
buf << :ready
|
110
|
+
@backend.read_loop(i) { |d| buf << d }
|
111
|
+
buf << :done
|
112
|
+
end
|
113
|
+
suspend
|
114
|
+
end
|
115
|
+
|
116
|
+
# writing always causes snoozing
|
117
|
+
o << 'foo'
|
118
|
+
sleep 0.01
|
119
|
+
o << 'bar'
|
120
|
+
sleep 0.01
|
121
|
+
|
122
|
+
parent.stop
|
123
|
+
|
124
|
+
parent.await
|
125
|
+
assert_equal [:ready, 'foo', 'bar'], buf
|
126
|
+
end
|
127
|
+
|
103
128
|
def test_accept_loop
|
104
129
|
server = TCPServer.new('127.0.0.1', 1234)
|
105
130
|
|
data/test/test_fiber.rb
CHANGED
@@ -1038,6 +1038,21 @@ class RestartTest < MiniTest::Test
|
|
1038
1038
|
end
|
1039
1039
|
end
|
1040
1040
|
|
1041
|
+
class ChildrenTerminationTest < MiniTest::Test
|
1042
|
+
def test_shutdown_all_children
|
1043
|
+
f = spin do
|
1044
|
+
1000.times { spin { suspend } }
|
1045
|
+
suspend
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
snooze
|
1049
|
+
assert_equal 1000, f.children.size
|
1050
|
+
|
1051
|
+
f.shutdown_all_children
|
1052
|
+
assert_equal 0, f.children.size
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
|
1041
1056
|
class GracefulTerminationTest < MiniTest::Test
|
1042
1057
|
def test_graceful_termination
|
1043
1058
|
buffer = []
|
data/test/test_signal.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyphony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.49.
|
4
|
+
version: 0.49.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|