evt 0.2.1 → 0.2.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/.github/workflows/test.yml +10 -7
- data/README.md +18 -3
- data/evt.gemspec +2 -2
- data/ext/evt/epoll.h +1 -3
- data/ext/evt/evt.c +2 -0
- data/ext/evt/extconf.rb +16 -5
- data/ext/evt/kqueue.h +3 -12
- data/ext/evt/uring.h +1 -0
- data/lib/evt/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a40fa492b119e2e67823ab476e39454de3027efbfab820c5d38a4562314f43a
|
4
|
+
data.tar.gz: 357b5b8d9c00ca7ed7df013aa6826e5ec85e72f329009272eaf985d7db519abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09cf37c36d93a8fa0144a324934055ede6063203f506af41fcd6a2dd8ebeb0509ff5996726ab92badac63e020b1b56301d18eed967c7fa830286aafde1b38001'
|
7
|
+
data.tar.gz: 869b7f1d95960362d2049ebfddb3a18fdad4a2558f64d27f7e5306f57025592a2402086f2ded46291a95f0fd4fe200f9040e83a449e29a61e0245e25e8f8d1ad
|
data/.github/workflows/test.yml
CHANGED
@@ -12,13 +12,13 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
include:
|
15
|
-
- { os: ubuntu-20.04, ruby: '3.0' }
|
16
|
-
- { os: ubuntu-20.04, ruby: ruby-
|
17
|
-
- { os: macos-11.0, ruby: '3.0' }
|
18
|
-
- { os: macos-11.0, ruby: ruby-
|
19
|
-
- { os: windows-2019, ruby: mingw }
|
20
|
-
- { os: windows-2019, ruby: mswin }
|
21
|
-
name: ${{ matrix.os }} ${{ matrix.ruby }}
|
15
|
+
- { os: ubuntu-20.04, ruby: '3.0', backend: epoll }
|
16
|
+
- { os: ubuntu-20.04, ruby: '3.0', backend: ruby, disable-epoll: 1 }
|
17
|
+
- { os: macos-11.0, ruby: '3.0', backend: kqueue }
|
18
|
+
- { os: macos-11.0, ruby: '3.0', backend: ruby, disable-kqueue: 1 }
|
19
|
+
- { os: windows-2019, ruby: mingw, backend: ruby }
|
20
|
+
- { os: windows-2019, ruby: mswin, backend: ruby }
|
21
|
+
name: test ${{ matrix.os }} ${{ matrix.ruby }} ${{ matrix.backend }}
|
22
22
|
runs-on: ${{ matrix.os }}
|
23
23
|
timeout-minutes: 5
|
24
24
|
steps:
|
@@ -32,6 +32,9 @@ jobs:
|
|
32
32
|
gem install bundler
|
33
33
|
bundle install --jobs 4 --retry 3
|
34
34
|
- name: Compile
|
35
|
+
env:
|
36
|
+
DISABLE_EPOLL: ${{ matrix.disable-epoll }}
|
37
|
+
DISABLE_KQUEUE: ${{ matrix.disable-kqueue }}
|
35
38
|
run: rake compile
|
36
39
|
- name: Test
|
37
40
|
run: rake
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Evt
|
2
2
|
|
3
|
-
The Event Library that designed for Ruby 3.0.
|
3
|
+
The Event Library that designed for Ruby 3.0 Fiber Scheduler.
|
4
4
|
|
5
5
|
**This gem is still under development, APIs and features are not stable. Advices and PRs are highly welcome.**
|
6
6
|
|
@@ -10,8 +10,6 @@ The Event Library that designed for Ruby 3.0.
|
|
10
10
|
|
11
11
|
## Features
|
12
12
|
|
13
|
-
|
14
|
-
|
15
13
|
### IO Backend Support
|
16
14
|
|
17
15
|
| | Linux | Windows | macOS | FreeBSD |
|
@@ -28,6 +26,22 @@ The Event Library that designed for Ruby 3.0.
|
|
28
26
|
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).
|
29
27
|
5. `kqueue` performance in Darwin is very poor. **MAY BE DISABLED IN THE FUTURE.**
|
30
28
|
|
29
|
+
### Benchmark
|
30
|
+
|
31
|
+
The benchmark is running under `v0.2.2` version. See [evt-server-benchmark](https://github.com/dsh0416/evt-server-benchmark) for test code, the test is running under a single-thread server.
|
32
|
+
|
33
|
+
The test command is `wrk -t4 -c8192 -d30s http://localhost:3001`.
|
34
|
+
|
35
|
+
All of the systems have set their file descriptor limit to maximum.
|
36
|
+
|
37
|
+
| OS | CPU | Memory | Backend | req/s |
|
38
|
+
| ----- | ----------- | ------ | ---------------------- | -------- |
|
39
|
+
| Linux | Ryzen 2700x | 64GB | epoll | 54680.08 |
|
40
|
+
| Linux | Ryzen 2700x | 64GB | io_uring | 50245.53 |
|
41
|
+
| Linux | Ryzen 2700x | 64GB | IO.select (using poll) | 44159.23 |
|
42
|
+
| macOS | i7-6820HQ | 16GB | kqueue | 37855.53 |
|
43
|
+
| macOS | i7-6820HQ | 16GB | IO.select (using poll) | 28293.36 |
|
44
|
+
|
31
45
|
## Install
|
32
46
|
|
33
47
|
```bash
|
@@ -68,6 +82,7 @@ scheduler.run
|
|
68
82
|
- [x] Support iov features of io_uring
|
69
83
|
- [x] Support IOCP (**NOT ENABLED YET**)
|
70
84
|
- [x] Setup tests with Ruby 3
|
85
|
+
- [x] Selectable backend compilation by environment variable
|
71
86
|
- [ ] Support IOCP with iov features
|
72
87
|
- [ ] Setup more tests for production purpose
|
73
88
|
- [ ] Documentation for usages
|
data/evt.gemspec
CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Delton Ding"]
|
7
7
|
spec.email = ["dsh0416@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = "
|
9
|
+
spec.summary = "The Event Library that designed for Ruby 3.0 Fiber Scheluer."
|
10
10
|
spec.description = "A low-level Event Handler designed for Ruby 3 Scheduler for better performance"
|
11
11
|
spec.homepage = "https://github.com/dsh0416/evt"
|
12
12
|
spec.license = 'BSD-3-Clause'
|
13
|
-
spec.required_ruby_version = '>=
|
13
|
+
spec.required_ruby_version = '>= 3.0.0.rc1'
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/dsh0416/evt"
|
data/ext/evt/epoll.h
CHANGED
@@ -56,7 +56,7 @@ VALUE method_scheduler_wait(VALUE self) {
|
|
56
56
|
timeout = NUM2INT(next_timeout);
|
57
57
|
}
|
58
58
|
|
59
|
-
struct epoll_event
|
59
|
+
struct epoll_event events[EPOLL_MAX_EVENTS];
|
60
60
|
|
61
61
|
n = epoll_wait(epfd, events, EPOLL_MAX_EVENTS, timeout);
|
62
62
|
if (n < 0) {
|
@@ -79,8 +79,6 @@ VALUE method_scheduler_wait(VALUE self) {
|
|
79
79
|
result = rb_ary_new2(2);
|
80
80
|
rb_ary_store(result, 0, readables);
|
81
81
|
rb_ary_store(result, 1, writables);
|
82
|
-
|
83
|
-
xfree(events);
|
84
82
|
return result;
|
85
83
|
}
|
86
84
|
|
data/ext/evt/evt.c
CHANGED
data/ext/evt/extconf.rb
CHANGED
@@ -2,11 +2,22 @@ require 'mkmf'
|
|
2
2
|
extension_name = 'evt_ext'
|
3
3
|
dir_config(extension_name)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def env_defined?(v)
|
6
|
+
return false if ENV[v].nil?
|
7
|
+
return false if ENV[v].empty?
|
8
|
+
return false if ENV[v].upcase == 'FALSE'
|
9
|
+
return false if ENV[v] == '0'
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
unless env_defined?('DISABLE_URING')
|
14
|
+
have_library('uring')
|
15
|
+
have_header('liburing.h')
|
16
|
+
end
|
17
|
+
|
18
|
+
have_header('sys/epoll.h') unless env_defined?('DISABLE_EPOLL')
|
19
|
+
have_header('sys/event.h') unless env_defined?('DISABLE_KQUEUE')
|
20
|
+
have_header('Windows.h') unless env_defined?('DISABLE_IOCP')
|
10
21
|
|
11
22
|
create_header
|
12
23
|
create_makefile(extension_name)
|
data/ext/evt/kqueue.h
CHANGED
@@ -27,26 +27,20 @@ VALUE method_scheduler_register(VALUE self, VALUE io, VALUE interest) {
|
|
27
27
|
event_flags |= EVFILT_WRITE;
|
28
28
|
}
|
29
29
|
|
30
|
-
EV_SET(&event, fd, event_flags, EV_ADD|EV_ENABLE, 0, 0, (void*) io);
|
30
|
+
EV_SET(&event, fd, event_flags, EV_ADD|EV_ENABLE|EV_ONESHOT, 0, 0, (void*) io);
|
31
31
|
kevent(kq, &event, 1, NULL, 0, NULL); // TODO: Check the return value
|
32
32
|
return Qnil;
|
33
33
|
}
|
34
34
|
|
35
35
|
VALUE method_scheduler_deregister(VALUE self, VALUE io) {
|
36
|
-
|
37
|
-
ID id_fileno = rb_intern("fileno");
|
38
|
-
int kq = NUM2INT(rb_iv_get(self, "@kq"));
|
39
|
-
int fd = NUM2INT(rb_funcall(io, id_fileno, 0));
|
40
|
-
EV_SET(&event, fd, 0, EV_DELETE, 0, 0, (void*) io);
|
41
|
-
kevent(kq, &event, 1, NULL, 0, (void*) io); // TODO: Check the return value
|
36
|
+
// One-shot mode
|
42
37
|
return Qnil;
|
43
38
|
}
|
44
39
|
|
45
40
|
VALUE method_scheduler_wait(VALUE self) {
|
46
41
|
int n, kq, i;
|
47
42
|
u_short event_flags = 0;
|
48
|
-
|
49
|
-
struct kevent* events; // Event Triggered
|
43
|
+
struct kevent events[KQUEUE_MAX_EVENTS];
|
50
44
|
struct timespec timeout;
|
51
45
|
VALUE next_timeout, obj_io, readables, writables, result;
|
52
46
|
ID id_next_timeout = rb_intern("next_timeout");
|
@@ -57,8 +51,6 @@ VALUE method_scheduler_wait(VALUE self) {
|
|
57
51
|
readables = rb_ary_new();
|
58
52
|
writables = rb_ary_new();
|
59
53
|
|
60
|
-
events = (struct kevent*) xmalloc(sizeof(struct kevent) * KQUEUE_MAX_EVENTS);
|
61
|
-
|
62
54
|
if (next_timeout == Qnil || NUM2INT(next_timeout) == -1) {
|
63
55
|
n = kevent(kq, NULL, 0, events, KQUEUE_MAX_EVENTS, NULL);
|
64
56
|
} else {
|
@@ -85,7 +77,6 @@ VALUE method_scheduler_wait(VALUE self) {
|
|
85
77
|
rb_ary_store(result, 0, readables);
|
86
78
|
rb_ary_store(result, 1, writables);
|
87
79
|
|
88
|
-
xfree(events);
|
89
80
|
return result;
|
90
81
|
}
|
91
82
|
|
data/ext/evt/uring.h
CHANGED
data/lib/evt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delton Ding
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -65,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.0.rc1
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
@@ -75,5 +75,5 @@ requirements: []
|
|
75
75
|
rubygems_version: 3.2.2
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
|
-
summary:
|
78
|
+
summary: The Event Library that designed for Ruby 3.0 Fiber Scheluer.
|
79
79
|
test_files: []
|