raptor 0.8.0 → 0.10.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 +22 -0
- data/Dockerfile +28 -0
- data/README.md +17 -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_http/raptor_http.c +87 -6
- data/ext/raptor_native/extconf.rb +7 -0
- data/ext/raptor_native/raptor_native.c +99 -0
- data/lib/raptor/binder.rb +19 -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 +115 -56
- data/lib/raptor/reuseport_bpf.rb +109 -0
- data/lib/raptor/server.rb +40 -12
- 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 +42 -13
- 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: 1b7d4b6790a256864f0c2b4e8d061231c372a110493ef2846f547f4566232d5d
|
|
4
|
+
data.tar.gz: dc6454ad796395d9eb7ab81327410ddd2004f0e1dd0bb03857636c508e84f7bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c0198c8697a569b7caf4492cf80c64edfbe7e6d0c1b4d7be7880175655bfa36b89040d3ab5b9597db995ac469eed26a1c74b7bb7c0c3206c9c47193b3930a48
|
|
7
|
+
data.tar.gz: 6a73d6a927a118dea756b8012108dbdaf1f2462ea9ea5a6fbd4dabd56cfffa51a23f059f2c51c39cd5a4f41a3fc0e752022cd1963115edacecb3cd53e56b83fe
|
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,27 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.10.0] - 2026-07-07
|
|
4
|
+
|
|
5
|
+
- Memoize the server port string for the Rack env
|
|
6
|
+
- Parse the Host header without regex
|
|
7
|
+
- Apply `TCP_NODELAY` on the listener rather than each accepted socket
|
|
8
|
+
- Buffer chunked body writes up to 512KB before flushing
|
|
9
|
+
- Add `QUERY_STRING` to the Rack env template
|
|
10
|
+
- Skip intermediate array allocations when formatting response headers
|
|
11
|
+
- Intern common HTTP header keys in the parser
|
|
12
|
+
- Reuse a Rack env template across HTTP/1.1 requests
|
|
13
|
+
|
|
14
|
+
## [0.9.0] - 2026-07-07
|
|
15
|
+
|
|
16
|
+
- Reuse a per-thread response buffer for status lines and headers
|
|
17
|
+
- Pin each worker to a distinct CPU when workers fit 1:1
|
|
18
|
+
- Batch response header and body writes into a single `writev(2)` syscall
|
|
19
|
+
- Close the binder as the last step of graceful shutdown
|
|
20
|
+
- Lower the backpressure floor for tighter load balancing on small pools
|
|
21
|
+
- Add load-aware `SO_REUSEPORT` routing on Linux via an attached BPF program
|
|
22
|
+
- Reuse per-thread read buffers across HTTP/1.1 requests
|
|
23
|
+
- Preserve the first `--bind` when it equals the default
|
|
24
|
+
|
|
3
25
|
## [0.8.0] - 2026-07-02
|
|
4
26
|
|
|
5
27
|
- 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,20 @@ 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.10.0 vs Puma 8.0.2, median of 3 runs across two workload profiles: IO-bound (sleep for a random 5-50ms then
|
|
191
|
+
return small JSON) and CPU-bound (serialise a JSON array of 20-200 items).
|
|
191
192
|
|
|
192
|
-
| Protocol | Raptor
|
|
193
|
-
| --------------------- |
|
|
194
|
-
| HTTP/1.1 |
|
|
195
|
-
| HTTP/1.1
|
|
196
|
-
| HTTP/
|
|
193
|
+
| Protocol | Workload | Raptor | Puma | +/- vs Puma |
|
|
194
|
+
| --------------------- | -------- | ------------ | ------------ | ----------- |
|
|
195
|
+
| HTTP/1.1 | IO | 0.43k req/s | 0.41k req/s | +4.0% |
|
|
196
|
+
| HTTP/1.1 | CPU | 10.99k req/s | 9.22k req/s | +19.1% |
|
|
197
|
+
| HTTP/1.1 (keep-alive) | IO | 0.41k req/s | 0.40k req/s | +2.6% |
|
|
198
|
+
| HTTP/1.1 (keep-alive) | CPU | 27.42k req/s | 25.75k req/s | +6.5% |
|
|
199
|
+
| HTTP/2 | IO | 0.31k req/s | N/A | - |
|
|
200
|
+
| HTTP/2 | CPU | 26.28k req/s | N/A | - |
|
|
197
201
|
|
|
198
|
-
> ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +YJIT +PRISM [
|
|
199
|
-
> 4 workers, 3 threads,
|
|
202
|
+
> ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +YJIT +PRISM [aarch64-linux]
|
|
203
|
+
> 4 workers, 3 threads, 24 concurrent connections
|
|
200
204
|
|
|
201
205
|
See [bin/benchmark](bin/benchmark) for more details.
|
|
202
206
|
|
|
@@ -206,6 +210,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
206
210
|
extensions and run the tests. You can also run `bin/console` for an interactive prompt that will allow you to
|
|
207
211
|
experiment.
|
|
208
212
|
|
|
213
|
+
On macOS (or any non-Linux host), `bin/dev` builds and drops you into a Docker image with Ruby and the required Linux
|
|
214
|
+
toolchain preinstalled, mounting the repo at `/workspace`. Run `bin/dev` for an interactive shell, or
|
|
215
|
+
`bin/dev <command>` for one-off commands like `bin/dev bundle exec rake` or `bin/dev bin/benchmark`.
|
|
216
|
+
|
|
209
217
|
## Contributing
|
|
210
218
|
|
|
211
219
|
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]
|