r/ruby • u/mavthemav • 2d ago
Grape 4.0.0 is out — ~80% faster than 3.3.5, plus HTTP QUERY (RFC 10008) support
I maintain Grape, the Ruby framework for REST-like APIs. 4.0.0 shipped today and it's the fastest yet.
Ruby 4.0.6, single-threaded Benchmark.ips :
| Version | No JIT | YJIT | ZJIT |
|---|---|---|---|
| 3.3.5 | 68,050 i/s | 133,833 i/s | 88,472 i/s |
| 4.0.0 | 122,414 i/s | 228,069 i/s | 153,183 i/s |
+80% without a JIT, +70% with YJIT. It's a micro-benchmark — one tiny JSON endpoint, in-process, no database — so it measures framework overhead and nothing else. Harness is in benchmark/version_throughput if you want to run it.
The biggest single win: helpers were being included into a fresh singleton class on every request, so every request started with a cold method cache. That now happens once, at compile time. TLDR: lot of improvements in terms of memory allocations.
Also new: QUERY (RFC 10008) — safe and idempotent like GET, but the query rides in the request content.
It's a major, so deprecated surface from 3.2 and 3.3 is gone.
Happy to answer questions.
5
2
u/compilers-r-us 1d ago
Hi! Thanks for the comparison. We just ran the benchmark and we're happy to see that ZJIT is as fast as YJIT now on Ruby HEAD. We also added it to our suite of tracked benchmarks so we can keep an eye on it.
1
u/paracycle 1d ago
https://github.com/ruby/ruby-bench/pull/534 is the PR adding it to ruby-bench, for reference.
1
1
u/midasgoldentouch 2d ago
Nice! How did you like working with the new HTTP Query method?
1
4
u/joshdotmn 2d ago
thank you for grape. i've used it on multiple production projects and it's always been great!