evt 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/evt/backends/bundled.rb +22 -0
- data/lib/evt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40b96a960c2027db56a915a8c4d6e20f8d29fd9f195003ef1a93cf9fad13a151
|
4
|
+
data.tar.gz: d6f99c7c134954a47b68c56f9a68f1227ed9ac90cefedefbef33a9c8978730aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75dbf1e519db25b8a0f63958cb2578fe852f12374eaed0a5a3b9595b30315ad92971477db2b27ed1bd2db6bd051553fa93eaa41263ed45c08c57ace0b43117fd
|
7
|
+
data.tar.gz: 905988d2a76fed454cd42b3acc014d5ddce044ecdf918352d8a6ede58213b3006dda7588a7d5889c6a4b16b23cce0a14308d71e4ba02430efcfe0fcdfa8f38c6
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ The Event Library that designed for Ruby 3.0 Fiber Scheduler.
|
|
22
22
|
| Ruby (`IO.select`) | ✅ Fallback | ✅ (⚠️See 4) | ✅ Fallback | ✅ Fallback |
|
23
23
|
|
24
24
|
1. when liburing is installed
|
25
|
-
2. when kernel version >= 2.6.
|
25
|
+
2. when kernel version >= 2.6.9
|
26
26
|
3. WOULD NOT WORK until `FILE_FLAG_OVERLAPPED` is included in I/O initialization process.
|
27
27
|
4. Some I/Os are not able to be nonblock under Windows. See [Scheduler Docs](https://docs.ruby-lang.org/en/master/doc/scheduler_md.html#label-IO).
|
28
28
|
5. `kqueue` performance in Darwin is very poor. **MAY BE DISABLED IN THE FUTURE.**
|
@@ -43,6 +43,9 @@ All of the systems have set their file descriptor limit to maximum.
|
|
43
43
|
| macOS | i7-6820HQ | 16GB | kqueue | 37855.53 |
|
44
44
|
| macOS | i7-6820HQ | 16GB | IO.select (using poll) | 28293.36 |
|
45
45
|
|
46
|
+
The benchmark uses an invalid parser, and `wrk` is very error-sensitive. The benchmark can't close the connection properly.
|
47
|
+
Use a valid parser, recent updates to my [midori](https://github.com/midori-rb/midori.rb) is able to use Ruby scheduler, which could achives 247k+ req/s on single thread with `kqueue` and 647k+ req/s with `epoll`.
|
48
|
+
|
46
49
|
## Install
|
47
50
|
|
48
51
|
```bash
|
data/lib/evt/backends/bundled.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Evt::Bundled
|
4
4
|
MAXIMUM_TIMEOUT = 5
|
5
|
+
COLLECT_COUNTER_MAX = 16384
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@readable = {}
|
@@ -12,6 +13,7 @@ class Evt::Bundled
|
|
12
13
|
@lock = Mutex.new
|
13
14
|
@blocking = 0
|
14
15
|
@ready = []
|
16
|
+
@collect_counter = 0
|
15
17
|
|
16
18
|
init_selector
|
17
19
|
end
|
@@ -53,6 +55,8 @@ class Evt::Bundled
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
58
|
+
collect
|
59
|
+
|
56
60
|
if @waiting.any?
|
57
61
|
time = current_time
|
58
62
|
waiting, @waiting = @waiting, {}
|
@@ -145,6 +149,24 @@ class Evt::Bundled
|
|
145
149
|
self.run
|
146
150
|
end
|
147
151
|
|
152
|
+
# Collect closed streams in readables and writables
|
153
|
+
def collect
|
154
|
+
if @collect_counter < COLLECT_COUNTER_MAX
|
155
|
+
@collect_counter += 1
|
156
|
+
return
|
157
|
+
end
|
158
|
+
|
159
|
+
@collect_counter = 0
|
160
|
+
|
161
|
+
@readable.keys.each do |io|
|
162
|
+
@readable.delete(io) if io.closed?
|
163
|
+
end
|
164
|
+
|
165
|
+
@writable.keys.each do |io|
|
166
|
+
@writable.delete(io) if io.closed?
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
148
170
|
# Intercept the creation of a non-blocking fiber.
|
149
171
|
# @returns [Fiber]
|
150
172
|
def fiber(&block)
|
data/lib/evt/version.rb
CHANGED