evt 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f49f37d3240b1878b00acaeea453e00c9dae2a96c8c7f12889836d653d6b1835
4
- data.tar.gz: 2af4b0238768dcb2b4112eaff379cad3899633eab69017517f36d5d51ba1fae7
3
+ metadata.gz: 40b96a960c2027db56a915a8c4d6e20f8d29fd9f195003ef1a93cf9fad13a151
4
+ data.tar.gz: d6f99c7c134954a47b68c56f9a68f1227ed9ac90cefedefbef33a9c8978730aa
5
5
  SHA512:
6
- metadata.gz: 58222d04ff91f47667697fd63d6d235d85c8204e09a82ac18dbd05b27d37eb79d6bcda034117684e2d49cd0cd67d2818df5264a4f73751851f1ebefdbe3a9de2
7
- data.tar.gz: 17c54e28beb805e30a3883446a807c5114287ba3c37b402a85dcba013f2910e8aca7d29c17efe527dd050a971f224ff0e8f4f2aacd36ef8cbe7970ff8aa06d56
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.8
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
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evt
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delton Ding