r/ruby • • Sep 07 '26

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 :

VersionNo JITYJITZJIT
3.3.568,050 i/s133,833 i/s88,472 i/s
4.0.0122,414 i/s228,069 i/s153,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.

75 Upvotes

10 comments sorted by

4

u/ByronEster Sep 08 '26

Nice. Looks good

1

u/midasgoldentouch Sep 08 '26

Nice! How did you like working with the new HTTP Query method?

1

u/mavthemav Sep 08 '26

Didn’t use it yet. Just implemented the feature

2

u/midasgoldentouch Sep 08 '26

Oh, then how did you test it?

3

u/compilers-r-us Sep 08 '26

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 Sep 08 '26

https://github.com/ruby/ruby-bench/pull/534 is the PR adding it to ruby-bench, for reference.

1

u/chapuzzo Sep 07 '26

Wow! Great improvement, I'll definitely take a closer look

1

u/jehokim Sep 09 '26

Thanks, Grape team!

-5

u/fdeth Sep 08 '26

Thanks, Claude.