polyphony 0.67 → 0.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -1
- data/Gemfile.lock +2 -2
- data/TODO.md +0 -23
- data/bin/pdbg +91 -9
- data/ext/polyphony/backend_common.c +18 -0
- data/ext/polyphony/backend_common.h +1 -0
- data/ext/polyphony/backend_io_uring.c +2 -8
- data/ext/polyphony/backend_libev.c +2 -0
- data/lib/polyphony.rb +2 -2
- data/lib/polyphony/debugger.rb +225 -0
- data/lib/polyphony/extensions/fiber.rb +33 -43
- data/lib/polyphony/extensions/io.rb +1 -3
- data/lib/polyphony/extensions/openssl.rb +63 -1
- data/lib/polyphony/extensions/socket.rb +3 -3
- data/lib/polyphony/version.rb +1 -1
- data/test/helper.rb +0 -1
- data/test/stress.rb +1 -1
- data/test/test_fiber.rb +23 -7
- data/test/test_global_api.rb +0 -1
- data/test/test_process_supervision.rb +38 -9
- data/test/test_supervise.rb +183 -100
- metadata +4 -4
- data/lib/polyphony/debugger/server.rb +0 -137
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.
|
4
|
+
version: '0.71'
|
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-08-
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -357,7 +357,7 @@ files:
|
|
357
357
|
- lib/polyphony/core/thread_pool.rb
|
358
358
|
- lib/polyphony/core/throttler.rb
|
359
359
|
- lib/polyphony/core/timer.rb
|
360
|
-
- lib/polyphony/debugger
|
360
|
+
- lib/polyphony/debugger.rb
|
361
361
|
- lib/polyphony/extensions/core.rb
|
362
362
|
- lib/polyphony/extensions/debug.rb
|
363
363
|
- lib/polyphony/extensions/fiber.rb
|
@@ -421,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
421
421
|
- !ruby/object:Gem::Version
|
422
422
|
version: '0'
|
423
423
|
requirements: []
|
424
|
-
rubygems_version: 3.1.
|
424
|
+
rubygems_version: 3.1.4
|
425
425
|
signing_key:
|
426
426
|
specification_version: 4
|
427
427
|
summary: Fine grained concurrency for Ruby
|
@@ -1,137 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'polyphony/extensions/debug'
|
4
|
-
|
5
|
-
module Polyphony
|
6
|
-
class DebugServer
|
7
|
-
TP_EVENTS = [
|
8
|
-
:line,
|
9
|
-
:call,
|
10
|
-
:return,
|
11
|
-
:b_call,
|
12
|
-
:b_return
|
13
|
-
]
|
14
|
-
|
15
|
-
|
16
|
-
def self.start(socket_path)
|
17
|
-
server = self.new(socket_path)
|
18
|
-
server.start
|
19
|
-
|
20
|
-
trace = TracePoint.new(*TP_EVENTS) { |tp| server.handle_tp(trace, tp) }
|
21
|
-
trace.enable
|
22
|
-
|
23
|
-
at_exit do
|
24
|
-
puts "program terminated"
|
25
|
-
trace.disable
|
26
|
-
server.stop
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize(socket_path)
|
31
|
-
@socket_path = socket_path
|
32
|
-
@fiber = Fiber.current
|
33
|
-
@controller = spin { control_loop }
|
34
|
-
puts "@fiber: #{@fiber.inspect}"
|
35
|
-
end
|
36
|
-
|
37
|
-
def start
|
38
|
-
fiber = Fiber.current
|
39
|
-
@server = spin(:pdbg_server) do
|
40
|
-
puts("Listening on #{@socket_path}")
|
41
|
-
FileUtils.rm(@socket_path) if File.exists?(@socket_path)
|
42
|
-
socket = UNIXServer.new(@socket_path)
|
43
|
-
fiber << :ready
|
44
|
-
id = 0
|
45
|
-
socket.accept_loop do |client|
|
46
|
-
puts "accepted connection"
|
47
|
-
handle_client(client)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
receive
|
51
|
-
end
|
52
|
-
|
53
|
-
def stop
|
54
|
-
@server.terminate
|
55
|
-
@controller.terminate
|
56
|
-
end
|
57
|
-
|
58
|
-
POLYPHONY_LIB_DIR = File.expand_path('../..', __dir__)
|
59
|
-
def handle_client(client)
|
60
|
-
@client = client
|
61
|
-
puts "trace enabled"
|
62
|
-
end
|
63
|
-
|
64
|
-
def control_loop
|
65
|
-
@cmd = :step
|
66
|
-
loop do
|
67
|
-
case @cmd
|
68
|
-
when :step
|
69
|
-
step
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def step
|
75
|
-
tp = nil
|
76
|
-
fiber = nil
|
77
|
-
while true
|
78
|
-
event = receive
|
79
|
-
fiber = event[:fiber]
|
80
|
-
if fiber == @fiber && event[:kind] == :line && event[:path] !~ /#{POLYPHONY_LIB_DIR}/
|
81
|
-
interact_with_client(event)
|
82
|
-
fiber << :ok
|
83
|
-
fiber.__unpark__
|
84
|
-
return
|
85
|
-
end
|
86
|
-
|
87
|
-
fiber << :ok
|
88
|
-
fiber.__unpark__
|
89
|
-
end
|
90
|
-
rescue => e
|
91
|
-
puts "Uncaught error: #{e.inspect}"
|
92
|
-
@trace&.disable
|
93
|
-
@client = nil
|
94
|
-
end
|
95
|
-
|
96
|
-
def interact_with_client(event)
|
97
|
-
@client.puts event.inspect
|
98
|
-
result = @client.gets&.chomp
|
99
|
-
end
|
100
|
-
|
101
|
-
def handle_tp(trace, tp)
|
102
|
-
return if @in_handle_tp
|
103
|
-
|
104
|
-
process_tp(trace, tp)
|
105
|
-
end
|
106
|
-
|
107
|
-
def process_tp(trace, tp)
|
108
|
-
@in_handle_tp = true
|
109
|
-
if !@client
|
110
|
-
wait_for_client
|
111
|
-
end
|
112
|
-
|
113
|
-
puts "- #{tp.event} #{tp.path}:#{tp.lineno}"
|
114
|
-
|
115
|
-
fiber = Fiber.current
|
116
|
-
fiber.__park__
|
117
|
-
|
118
|
-
@controller << {
|
119
|
-
fiber: fiber,
|
120
|
-
kind: tp.event,
|
121
|
-
path: tp.path,
|
122
|
-
lineno: tp.lineno
|
123
|
-
}
|
124
|
-
receive
|
125
|
-
ensure
|
126
|
-
@in_handle_tp = nil
|
127
|
-
end
|
128
|
-
|
129
|
-
def wait_for_client
|
130
|
-
puts "wait_for_client"
|
131
|
-
sleep 0.1 until @client
|
132
|
-
puts " got client!"
|
133
|
-
msg = @client.gets
|
134
|
-
@client.puts msg
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|