raptor 0.8.0 → 0.9.0
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/.buildkite/pipeline.yml +90 -32
- data/.dockerignore +5 -0
- data/CHANGELOG.md +11 -0
- data/Dockerfile +28 -0
- data/README.md +16 -9
- data/Rakefile +19 -1
- data/docs/raptor-vs-puma.md +557 -0
- data/ext/raptor_bpf/reuseport_select.bpf.c +63 -0
- data/ext/raptor_http/extconf.rb +1 -1
- data/ext/raptor_native/extconf.rb +7 -0
- data/ext/raptor_native/raptor_native.c +99 -0
- data/lib/raptor/binder.rb +18 -4
- data/lib/raptor/cli.rb +1 -1
- data/lib/raptor/cluster.rb +27 -2
- data/lib/raptor/http.rb +41 -0
- data/lib/raptor/http1.rb +32 -24
- data/lib/raptor/reuseport_bpf.rb +108 -0
- data/lib/raptor/server.rb +40 -11
- data/lib/raptor/version.rb +1 -1
- data/sig/generated/raptor/binder.rbs +10 -0
- data/sig/generated/raptor/cluster.rbs +4 -2
- data/sig/generated/raptor/http.rbs +13 -0
- data/sig/generated/raptor/http1.rbs +16 -5
- data/sig/generated/raptor/reuseport_bpf.rbs +56 -0
- data/sig/generated/raptor/server.rbs +20 -6
- metadata +24 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6dcf0e8beb3e5b74822eff407c51fbb0e83445ab54f75c37dad2cab2f9113ec5
|
|
4
|
+
data.tar.gz: 9131a6153b10e93e2e0b717355645fe485a1db0af52c3472f07a35fa4f95d64f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a020f0e5c42eb4755a69c790f891aa334369d2ec58c063516893a53785574290feca84ebdd9d072b11601129f720eb2d82f52a7abbd7e0aa7bf79b17c57705c
|
|
7
|
+
data.tar.gz: 3b90235078097337dcade23681c4b3ae638d04094a40a5c21e81f8aac127bfa547dd8d07e7dac1adda539299ab62c3883d15d84a692942da2a1b69eed7946035
|
data/.buildkite/pipeline.yml
CHANGED
|
@@ -1,36 +1,94 @@
|
|
|
1
1
|
steps:
|
|
2
|
-
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- ruby
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
- group: ":linux: Linux"
|
|
3
|
+
key: linux
|
|
4
|
+
steps:
|
|
5
|
+
- label: ":ruby: Ruby 4.0"
|
|
6
|
+
image: "ruby:4.0"
|
|
7
|
+
commands:
|
|
8
|
+
- ruby -v
|
|
9
|
+
- bundle install
|
|
10
|
+
- bundle exec rake ci
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
- label: ":ruby: Ruby 4.0 +YJIT"
|
|
13
|
+
image: "ruby:4.0"
|
|
14
|
+
env:
|
|
15
|
+
RUBY_YJIT_ENABLE: "1"
|
|
16
|
+
commands:
|
|
17
|
+
- ruby -v
|
|
18
|
+
- bundle install
|
|
19
|
+
- bundle exec rake ci
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
- label: ":ruby: Ruby head"
|
|
22
|
+
soft_fail: true
|
|
23
|
+
image: "rubylang/ruby:master-dev"
|
|
24
|
+
commands:
|
|
25
|
+
- apt-get update && apt-get install -y libyaml-dev
|
|
26
|
+
- ruby -v
|
|
27
|
+
- bundle install
|
|
28
|
+
- bundle exec rake ci
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
- label: ":ruby: Ruby head +YJIT"
|
|
31
|
+
soft_fail: true
|
|
32
|
+
image: "rubylang/ruby:master-dev"
|
|
33
|
+
env:
|
|
34
|
+
RUBY_YJIT_ENABLE: "1"
|
|
35
|
+
commands:
|
|
36
|
+
- apt-get update && apt-get install -y libyaml-dev
|
|
37
|
+
- ruby -v
|
|
38
|
+
- bundle install
|
|
39
|
+
- bundle exec rake ci
|
|
40
|
+
|
|
41
|
+
- group: ":mac: macOS"
|
|
42
|
+
key: macos
|
|
43
|
+
steps:
|
|
44
|
+
- label: ":ruby: Ruby 4.0"
|
|
45
|
+
agents:
|
|
46
|
+
queue: macos
|
|
47
|
+
commands:
|
|
48
|
+
- brew install --quiet ruby@4.0
|
|
49
|
+
- export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
|
|
50
|
+
- bundle config set --local path .bundle
|
|
51
|
+
- ruby -v
|
|
52
|
+
- bundle install
|
|
53
|
+
- bundle exec rake ci
|
|
54
|
+
|
|
55
|
+
- label: ":ruby: Ruby 4.0 +YJIT"
|
|
56
|
+
agents:
|
|
57
|
+
queue: macos
|
|
58
|
+
env:
|
|
59
|
+
RUBY_YJIT_ENABLE: "1"
|
|
60
|
+
commands:
|
|
61
|
+
- brew install --quiet ruby@4.0
|
|
62
|
+
- export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
|
|
63
|
+
- bundle config set --local path .bundle
|
|
64
|
+
- ruby -v
|
|
65
|
+
- bundle install
|
|
66
|
+
- bundle exec rake ci
|
|
67
|
+
|
|
68
|
+
- label: ":ruby: Ruby head"
|
|
69
|
+
soft_fail: true
|
|
70
|
+
agents:
|
|
71
|
+
queue: macos
|
|
72
|
+
commands:
|
|
73
|
+
- brew unlink ruby
|
|
74
|
+
- brew install --HEAD --quiet ruby
|
|
75
|
+
- export PATH="$(brew --prefix ruby)/bin:$PATH"
|
|
76
|
+
- bundle config set --local path .bundle
|
|
77
|
+
- ruby -v
|
|
78
|
+
- bundle install
|
|
79
|
+
- bundle exec rake ci
|
|
80
|
+
|
|
81
|
+
- label: ":ruby: Ruby head +YJIT"
|
|
82
|
+
soft_fail: true
|
|
83
|
+
agents:
|
|
84
|
+
queue: macos
|
|
85
|
+
env:
|
|
86
|
+
RUBY_YJIT_ENABLE: "1"
|
|
87
|
+
commands:
|
|
88
|
+
- brew unlink ruby
|
|
89
|
+
- brew install --HEAD --quiet ruby
|
|
90
|
+
- export PATH="$(brew --prefix ruby)/bin:$PATH"
|
|
91
|
+
- bundle config set --local path .bundle
|
|
92
|
+
- ruby -v
|
|
93
|
+
- bundle install
|
|
94
|
+
- bundle exec rake ci
|
data/.dockerignore
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.9.0] - 2026-07-07
|
|
4
|
+
|
|
5
|
+
- Reuse a per-thread response buffer for status lines and headers
|
|
6
|
+
- Pin each worker to a distinct CPU when workers fit 1:1
|
|
7
|
+
- Batch response header and body writes into a single `writev(2)` syscall
|
|
8
|
+
- Close the binder as the last step of graceful shutdown
|
|
9
|
+
- Lower the backpressure floor for tighter load balancing on small pools
|
|
10
|
+
- Add load-aware `SO_REUSEPORT` routing on Linux via an attached BPF program
|
|
11
|
+
- Reuse per-thread read buffers across HTTP/1.1 requests
|
|
12
|
+
- Preserve the first `--bind` when it equals the default
|
|
13
|
+
|
|
3
14
|
## [0.8.0] - 2026-07-02
|
|
4
15
|
|
|
5
16
|
- Add systemd `LISTEN_FDS` socket activation and `sd_notify` lifecycle messages
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM golang:bookworm AS hey-builder
|
|
2
|
+
RUN CGO_ENABLED=0 go install github.com/rakyll/hey@latest
|
|
3
|
+
|
|
4
|
+
FROM ruby:latest
|
|
5
|
+
|
|
6
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
7
|
+
ENV LANG=C.UTF-8
|
|
8
|
+
ENV LC_ALL=C.UTF-8
|
|
9
|
+
ENV RUBY_YJIT_ENABLE=1
|
|
10
|
+
|
|
11
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
12
|
+
clang \
|
|
13
|
+
libbpf-dev \
|
|
14
|
+
libelf-dev \
|
|
15
|
+
linux-libc-dev \
|
|
16
|
+
nghttp2 \
|
|
17
|
+
openssl \
|
|
18
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
19
|
+
|
|
20
|
+
COPY --from=hey-builder /go/bin/hey /usr/local/bin/hey
|
|
21
|
+
|
|
22
|
+
ENV BUNDLE_PATH=/workspace/.bundle
|
|
23
|
+
ENV BUNDLE_APP_CONFIG=/workspace/.bundle
|
|
24
|
+
ENV PATH=/workspace/bin:${PATH}
|
|
25
|
+
|
|
26
|
+
WORKDIR /workspace
|
|
27
|
+
|
|
28
|
+
CMD ["bash"]
|
data/README.md
CHANGED
|
@@ -37,7 +37,7 @@ run proc { |_env| [200, { "content-type" => "text/plain" }, ["Hello, World!"]] }
|
|
|
37
37
|
```
|
|
38
38
|
> bundle exec raptor -w 4 -t 3 hello_world.ru
|
|
39
39
|
[Raptor 76577|Main|Main] Cluster initializing:
|
|
40
|
-
[Raptor 76577|Main|Main] ├─ Version: 0.
|
|
40
|
+
[Raptor 76577|Main|Main] ├─ Version: 0.9.0
|
|
41
41
|
[Raptor 76577|Main|Main] ├─ Ruby Version: ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +YJIT +PRISM [arm64-darwin23]
|
|
42
42
|
[Raptor 76577|Main|Main] ├─ Environment: development
|
|
43
43
|
[Raptor 76577|Main|Main] ├─ Master PID: 76577
|
|
@@ -187,16 +187,19 @@ Worker 1 (phase 0): pid=91351, requests=1199, busy=1/3, backlog=0, booted, last_
|
|
|
187
187
|
|
|
188
188
|
## (Micro) Benchmarks
|
|
189
189
|
|
|
190
|
-
Raptor 0.
|
|
190
|
+
Raptor 0.9.0 vs Puma 8.0.2, median of 3 runs across two workload profiles: IO-bound (sleep for a random 5-50ms then return small JSON) and CPU-bound (serialise a JSON array of 20-200 items).
|
|
191
191
|
|
|
192
|
-
| Protocol | Raptor | Puma
|
|
193
|
-
| --------------------- | ----------- | ----------- |
|
|
194
|
-
| HTTP/1.1 |
|
|
195
|
-
| HTTP/1.1
|
|
196
|
-
| HTTP/
|
|
192
|
+
| Protocol | Workload | Raptor | Puma | +/- vs Puma |
|
|
193
|
+
| --------------------- | -------- | ----------- | ---------- | ----------- |
|
|
194
|
+
| HTTP/1.1 | IO | 0.4k req/s | 0.4k req/s | +3.4% |
|
|
195
|
+
| HTTP/1.1 | CPU | 11.5k req/s | 9k req/s | +27.6% |
|
|
196
|
+
| HTTP/1.1 (keep-alive) | IO | 0.4k req/s | 0.4k req/s | +1.5% |
|
|
197
|
+
| HTTP/1.1 (keep-alive) | CPU | 28.8k req/s | 26k req/s | +10.9% |
|
|
198
|
+
| HTTP/2 | IO | 0.3k req/s | N/A | - |
|
|
199
|
+
| HTTP/2 | CPU | 29.6k req/s | N/A | - |
|
|
197
200
|
|
|
198
|
-
> ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +YJIT +PRISM [
|
|
199
|
-
> 4 workers, 3 threads,
|
|
201
|
+
> ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +YJIT +PRISM [aarch64-linux]
|
|
202
|
+
> 4 workers, 3 threads, 24 concurrent connections
|
|
200
203
|
|
|
201
204
|
See [bin/benchmark](bin/benchmark) for more details.
|
|
202
205
|
|
|
@@ -206,6 +209,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
206
209
|
extensions and run the tests. You can also run `bin/console` for an interactive prompt that will allow you to
|
|
207
210
|
experiment.
|
|
208
211
|
|
|
212
|
+
On macOS (or any non-Linux host), `bin/dev` builds and drops you into a Docker image with Ruby and the required Linux
|
|
213
|
+
toolchain preinstalled, mounting the repo at `/workspace`. Run `bin/dev` for an interactive shell, or
|
|
214
|
+
`bin/dev <command>` for one-off commands like `bin/dev bundle exec rake` or `bin/dev bin/benchmark`.
|
|
215
|
+
|
|
209
216
|
## Contributing
|
|
210
217
|
|
|
211
218
|
Bug reports and pull requests are welcome on GitHub at https://github.com/joshuay03/raptor. This project is intended to
|
data/Rakefile
CHANGED
|
@@ -16,6 +16,24 @@ Rake::ExtensionTask.new("raptor_http2", GEMSPEC) do |ext|
|
|
|
16
16
|
ext.lib_dir = "lib/raptor"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
Rake::ExtensionTask.new("raptor_native", GEMSPEC) do |ext|
|
|
20
|
+
ext.lib_dir = "lib/raptor"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
namespace :bpf do
|
|
24
|
+
task :compile do
|
|
25
|
+
if RUBY_PLATFORM.include?("linux")
|
|
26
|
+
arch = `uname -m`.chomp
|
|
27
|
+
Dir["ext/raptor_bpf/*.bpf.c"].each do |source|
|
|
28
|
+
object = source.sub(/\.c\z/, ".o")
|
|
29
|
+
sh "clang -O2 -g -target bpf -I/usr/include/#{arch}-linux-gnu -c #{source} -o #{object}"
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
puts "Skipping bpf:compile on #{RUBY_PLATFORM}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
19
37
|
namespace :rbs do
|
|
20
38
|
task :generate do
|
|
21
39
|
puts
|
|
@@ -23,6 +41,6 @@ namespace :rbs do
|
|
|
23
41
|
end
|
|
24
42
|
end
|
|
25
43
|
|
|
26
|
-
task default: %i[clobber compile rbs:generate test]
|
|
44
|
+
task default: %i[clobber compile bpf:compile rbs:generate test]
|
|
27
45
|
task build: %i[clobber compile rbs:generate]
|
|
28
46
|
task ci: %i[clobber compile test]
|