polyphony 0.42 → 0.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/TODO.md +1 -2
- data/docs/_config.yml +2 -2
- data/docs/getting-started/overview.md +1 -22
- data/examples/performance/thread-vs-fiber/polyphony_server_read_loop.rb +1 -1
- data/lib/polyphony/extensions/io.rb +4 -0
- data/lib/polyphony/extensions/openssl.rb +34 -10
- data/lib/polyphony/version.rb +1 -1
- data/test/test_socket.rb +5 -4
- 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: 4eb88a97bf07f85f50aa46923883fce2fe1bbd253407021a6f5bb246e0fdcfdc
|
4
|
+
data.tar.gz: c707861eb93f709661aa90abb33519004df5ff5db16f2d3da00387b292234027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b554716ed26188fec86606198cdca669253d921017748ef0d9231db9f01e08e046b62fc38c0c6c3595a42f1976771db8b42c352c0431cc73f4b1ed64f7edf3c9
|
7
|
+
data.tar.gz: 3ba74e7427fab47a65cd466e9bbe14e48176f737f6fd7fca21b3143d75d1dd9fa2ddef24b723d83f26f321949171359d946cfd4281b3b96c33bf43593199adce
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.43
|
2
2
|
|
3
3
|
- Reimplement ResourcePool, Channel, Mutex using LibevQueue
|
4
4
|
-- Add `Fiber#schedule_with_priority` method, aliased by `Fiber#wakeup`
|
5
5
|
- Implement agent interface is virtual function table
|
6
6
|
- Implement proxy agent for plugging in a user-provided agent class
|
7
7
|
|
8
|
-
## 0.43
|
9
8
|
- Debugging
|
10
9
|
- Eat your own dogfood: need a good tool to check what's going on when some
|
11
10
|
test fails
|
data/docs/_config.yml
CHANGED
@@ -46,13 +46,13 @@ heading_anchors: true
|
|
46
46
|
back_to_top: true
|
47
47
|
back_to_top_text: "Back to top"
|
48
48
|
|
49
|
-
footer_content: "Copyright ©
|
49
|
+
footer_content: "Copyright © 2020 Sharon Rosner. Distributed by an <a href=\"https://github.com/digital-fabric/polyphony/tree/master/LICENSE\">MIT license.</a>"
|
50
50
|
|
51
51
|
# Footer "Edit this page on GitHub" link text
|
52
52
|
gh_edit_link: true # show or hide edit this page link
|
53
53
|
gh_edit_link_text: "Edit this page on GitHub"
|
54
54
|
gh_edit_repository: "https://github.com/digital-fabric/polyphony" # the github URL for your repo
|
55
|
-
gh_edit_branch: "master" # the branch that your docs is served from
|
55
|
+
gh_edit_branch: "master/docs" # the branch that your docs is served from
|
56
56
|
gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
|
57
57
|
|
58
58
|
compress_html:
|
@@ -416,28 +416,7 @@ request handler after all request headers have been received. This allows the
|
|
416
416
|
application to better deal with slow client attacks, big file uploads, and also
|
417
417
|
to minimize costly memory allocation and GC'ing.
|
418
418
|
|
419
|
-
|
420
|
-
Puma and 20X as fast as Unicorn. With SSL termination and using HTTP 2, the
|
421
|
-
Polyphony web server is about 2X as fast as Falcon.
|
422
|
-
|
423
|
-
### HTTP/1
|
424
|
-
|
425
|
-
|Server|requests/sec|average latency|max latency|
|
426
|
-
|------|-----------:|--------------:|----------:|
|
427
|
-
|Puma|
|
428
|
-
|Unicorn|
|
429
|
-
|Agoo|
|
430
|
-
|Polyphony|
|
431
|
-
|
432
|
-
### HTTP/2 with SSL Termination
|
433
|
-
|
434
|
-
|Server|requests/sec|average latency|max latency|
|
435
|
-
|------|-----------:|--------------:|----------:|
|
436
|
-
|Falcon|
|
437
|
-
|Polyphony|
|
438
|
-
|
439
|
-
(*Non-official benchmark with a basic "Hello world" Rack application. The usual
|
440
|
-
caveats regarding benchmarks should be applied here.*)
|
419
|
+
Benchmarks will be included here at a later time.
|
441
420
|
|
442
421
|
## Integrating Polyphony with other Gems
|
443
422
|
|
@@ -13,7 +13,7 @@ def handle_client(socket)
|
|
13
13
|
parser.on_message_complete = proc do |env|
|
14
14
|
reqs << Object.new # parser
|
15
15
|
end
|
16
|
-
|
16
|
+
socket.read_loop do |data|
|
17
17
|
parser << data
|
18
18
|
while (req = reqs.shift)
|
19
19
|
handle_request(socket, req)
|
@@ -201,6 +201,10 @@ class ::IO
|
|
201
201
|
buf ? readpartial(maxlen, buf) : readpartial(maxlen)
|
202
202
|
end
|
203
203
|
|
204
|
+
def read_loop(&block)
|
205
|
+
Thread.current.agent.read_loop(self, &block)
|
206
|
+
end
|
207
|
+
|
204
208
|
# alias_method :orig_read, :read
|
205
209
|
# def read(length = nil, outbuf = nil)
|
206
210
|
# if length
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'openssl'
|
4
|
-
|
5
4
|
require_relative './socket'
|
6
5
|
|
7
6
|
# Open ssl socket helper methods (to make it compatible with Socket API)
|
@@ -18,12 +17,36 @@ class ::OpenSSL::SSL::SSLSocket
|
|
18
17
|
io.reuse_addr
|
19
18
|
end
|
20
19
|
|
21
|
-
|
20
|
+
alias_method :orig_accept, :accept
|
21
|
+
def accept
|
22
|
+
loop do
|
23
|
+
result = accept_nonblock(exception: false)
|
24
|
+
case result
|
25
|
+
when :wait_readable then Thread.current.agent.wait_io(io, false)
|
26
|
+
when :wait_writable then Thread.current.agent.wait_io(io, true)
|
27
|
+
else
|
28
|
+
return result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_method :orig_sysread, :sysread
|
34
|
+
def sysread(maxlen, buf = +'')
|
22
35
|
loop do
|
23
36
|
case (result = read_nonblock(maxlen, buf, exception: false))
|
24
37
|
when :wait_readable then Thread.current.agent.wait_io(io, false)
|
38
|
+
else return result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
alias_method :orig_syswrite, :syswrite
|
44
|
+
def syswrite(buf)
|
45
|
+
loop do
|
46
|
+
case (result = write_nonblock(buf, exception: false))
|
25
47
|
when :wait_writable then Thread.current.agent.wait_io(io, true)
|
26
|
-
else
|
48
|
+
else
|
49
|
+
return result
|
27
50
|
end
|
28
51
|
end
|
29
52
|
end
|
@@ -37,13 +60,14 @@ class ::OpenSSL::SSL::SSLSocket
|
|
37
60
|
# @sync = osync
|
38
61
|
end
|
39
62
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
63
|
+
def readpartial(maxlen, buf = +'')
|
64
|
+
result = sysread(maxlen, buf)
|
65
|
+
result || (raise EOFError)
|
66
|
+
end
|
67
|
+
|
68
|
+
def read_loop
|
69
|
+
while (data = sysread(8192))
|
70
|
+
yield data
|
47
71
|
end
|
48
72
|
end
|
49
73
|
end
|
data/lib/polyphony/version.rb
CHANGED
data/test/test_socket.rb
CHANGED
@@ -8,7 +8,8 @@ class SocketTest < MiniTest::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_tcp
|
11
|
-
|
11
|
+
port = rand(1234..5678)
|
12
|
+
server = TCPServer.new('127.0.0.1', port)
|
12
13
|
|
13
14
|
server_fiber = spin do
|
14
15
|
while (socket = server.accept)
|
@@ -21,13 +22,13 @@ class SocketTest < MiniTest::Test
|
|
21
22
|
end
|
22
23
|
|
23
24
|
snooze
|
24
|
-
client = TCPSocket.new('127.0.0.1',
|
25
|
+
client = TCPSocket.new('127.0.0.1', port)
|
25
26
|
client.write("1234\n")
|
26
27
|
assert_equal "1234\n", client.readpartial(8192)
|
27
28
|
client.close
|
28
29
|
ensure
|
29
|
-
server_fiber
|
30
|
-
|
30
|
+
server_fiber&.stop
|
31
|
+
server_fiber&.await
|
31
32
|
server&.close
|
32
33
|
end
|
33
34
|
end
|
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.43'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|