• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 33379390620
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: router-compile-registered-methods
DEFAULT BRANCH: master
Ran 31 Aug 2026 09:47AM UTC
Jobs 32
Files 169
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

31 Aug 2026 09:47AM UTC coverage: 97.002% (+0.02%) from 96.978%
33379390620

Pull #2872

github

ericproulx
Include endpoint helpers once instead of on every request

Helpers are instance methods on the endpoint, because the route block is bound
to the endpoint and runs against it. They are also per-endpoint — including
them into Grape::Endpoint itself would leak one API's helpers into every
endpoint in the process — so they went onto the per-request copy:

    def call(env)
      dup.call!(env)
    end

    def call!(env)
      ...
      singleton_class.include(@helpers) if @helpers

That had to happen per request rather than once: Object#dup deliberately does
not carry a singleton class over, so including the helpers on the shared
endpoint would never reach the copies that actually serve requests.

The cost is not the include. `dup` plus `include` measures ~510 ns against
~110 ns for `dup` alone, which would be under 2% of a request. The expense is
that `singleton_class` on a fresh copy *creates a class*, and a class nothing
has called through yet has no method cache. Counting allocations: the dup, its
singleton class and the iclasses are 4 objects, and the first call to each
distinct method through that class costs 3 more — paid again on the next
request, for every helper, for the route block, and for every DSL method the
endpoint answers.

Include them once, at compile! time, into a subclass owned by this endpoint,
and copy the endpoint's state onto an instance of it. Each request then copies
an object whose class has been warm since boot, and request handling no longer
mutates a class at all.

On a small API with helpers, params and validations (median of 9 runs, Ruby
4.0.5, single-threaded Benchmark.ips):

                          YJIT                   no-YJIT          objects/req
    GET    40,853 -> 51,605  (+26%)   19,574 -> 21,368  (+9%)      154 -> 121
    POST   40,045 -> 51,009  (+27%)   19,657 -> 21,711  (+10%)     157 -> 123

An endpoint that declares no helpers is its own prototype: throughput and
allocation counts there are unchanged.

On... (continued)
Pull Request #2872: Include endpoint helpers once instead of on every request

1239 of 1330 branches covered (93.16%)

Branch coverage included in aggregate %.

10 of 10 new or added lines in 1 file covered. (100.0%)

3905 of 3973 relevant lines covered (98.29%)

27143.07 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33379390620.1 31 Aug 2026 09:47AM UTC 168
46.8
GitHub Action Run
2 run-4.0-gemfiles/hashie.gemfile - 33379390620.2 31 Aug 2026 09:47AM UTC 168
61.58
GitHub Action Run
3 run-3.3-Gemfile - 33379390620.3 31 Aug 2026 09:47AM UTC 168
95.75
GitHub Action Run
4 run-3.3-gemfiles/rails_8_0.gemfile - 33379390620.4 31 Aug 2026 09:47AM UTC 169
95.75
GitHub Action Run
5 run-4.0-gemfiles/rack_3_1.gemfile - 33379390620.5 31 Aug 2026 09:47AM UTC 168
95.75
GitHub Action Run
6 run-4.0-gemfiles/multi_xml.gemfile - 33379390620.6 31 Aug 2026 09:47AM UTC 168
46.76
GitHub Action Run
7 run-3.4-gemfiles/rack_2_2.gemfile - 33379390620.7 31 Aug 2026 09:47AM UTC 168
95.71
GitHub Action Run
8 run-3.3-gemfiles/rack_3_2.gemfile - 33379390620.8 31 Aug 2026 09:47AM UTC 168
95.75
GitHub Action Run
9 run-4.0-gemfiles/rack_2_2.gemfile - 33379390620.9 31 Aug 2026 09:48AM UTC 168
95.71
GitHub Action Run
10 run-4.0-gemfiles/grape_entity.gemfile - 33379390620.10 31 Aug 2026 09:47AM UTC 168
50.07
GitHub Action Run
11 run-4.0-gemfiles/rails_7_2.gemfile - 33379390620.11 31 Aug 2026 09:47AM UTC 169
95.76
GitHub Action Run
12 run-4.0-gemfiles/rails_8_0.gemfile - 33379390620.12 31 Aug 2026 09:47AM UTC 169
95.76
GitHub Action Run
13 run-3.3-gemfiles/rails_8_1.gemfile - 33379390620.13 31 Aug 2026 09:47AM UTC 169
95.75
GitHub Action Run
14 run-3.4-gemfiles/rails_7_2.gemfile - 33379390620.14 31 Aug 2026 09:47AM UTC 169
95.76
GitHub Action Run
15 run-4.0-gemfiles/dry_validation.gemfile - 33379390620.15 31 Aug 2026 09:47AM UTC 168
57.75
GitHub Action Run
16 run-4.0-gemfiles/grape_swagger.gemfile - 33379390620.16 31 Aug 2026 09:47AM UTC 168
55.14
GitHub Action Run
17 run-4.0-Gemfile - 33379390620.17 31 Aug 2026 09:47AM UTC 168
95.75
GitHub Action Run
18 run-4.0-gemfiles/rack_3_0.gemfile - 33379390620.18 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
19 run-4.0-gemfiles/rails_8_1.gemfile - 33379390620.19 31 Aug 2026 09:51AM UTC 169
95.76
GitHub Action Run
20 run-3.3-gemfiles/rack_3_1.gemfile - 33379390620.20 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
21 run-3.4-Gemfile - 33379390620.21 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
22 run-3.4-gemfiles/rails_8_0.gemfile - 33379390620.22 31 Aug 2026 09:47AM UTC 169
95.76
GitHub Action Run
23 run-4.0-gemfiles/rack_3_2.gemfile - 33379390620.23 31 Aug 2026 09:47AM UTC 168
95.75
GitHub Action Run
24 run-4.0-gemfiles/multi_json.gemfile - 33379390620.24 31 Aug 2026 09:47AM UTC 168
47.37
GitHub Action Run
25 run-3.3-gemfiles/rack_2_2.gemfile - 33379390620.25 31 Aug 2026 09:47AM UTC 168
95.71
GitHub Action Run
26 run-3.3-gemfiles/rails_7_2.gemfile - 33379390620.26 31 Aug 2026 09:47AM UTC 169
95.75
GitHub Action Run
27 run-3.4-gemfiles/rack_3_1.gemfile - 33379390620.27 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
28 run-3.4-gemfiles/rack_3_0.gemfile - 33379390620.28 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
29 run-3.4-gemfiles/rails_8_1.gemfile - 33379390620.29 31 Aug 2026 09:47AM UTC 169
95.76
GitHub Action Run
30 run-4.0-gemfiles/multi_json_1_20.gemfile - 33379390620.30 31 Aug 2026 09:47AM UTC 168
47.4
GitHub Action Run
31 run-3.3-gemfiles/rack_3_0.gemfile - 33379390620.31 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
32 run-3.4-gemfiles/rack_3_2.gemfile - 33379390620.32 31 Aug 2026 09:48AM UTC 168
95.75
GitHub Action Run
Source Files on build 33379390620
  • Tree
  • List 169
  • Changed 3
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33379390620
  • Pull Request #2872
  • PR Base - master (#33365105943)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc