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

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

Build:
Build:
LAST BUILD BRANCH: perf/default-status-single-read
DEFAULT BRANCH: master
Ran 01 Sep 2026 08:12PM 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

01 Sep 2026 08:11PM UTC coverage: 96.975% (+0.02%) from 96.951%
33553892511

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 1332 branches covered (93.02%)

Branch coverage included in aggregate %.

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

3922 of 3990 relevant lines covered (98.3%)

27238.73 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-3.3-gemfiles/rails_8_1.gemfile - 33553892511.1 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
2 run-4.0-gemfiles/hashie.gemfile - 33553892511.2 01 Sep 2026 08:12PM UTC 168
61.72
GitHub Action Run
3 run-4.0-gemfiles/rack_3_2.gemfile - 33553892511.3 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
4 run-4.0-gemfiles/rails_7_2.gemfile - 33553892511.4 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
5 run-4.0-gemfiles/multi_json_1_20.gemfile - 33553892511.5 01 Sep 2026 08:12PM UTC 168
47.39
GitHub Action Run
6 run-3.3-gemfiles/rails_7_2.gemfile - 33553892511.6 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
7 run-3.3-gemfiles/rack_3_2.gemfile - 33553892511.7 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
8 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33553892511.8 01 Sep 2026 08:12PM UTC 168
46.9
GitHub Action Run
9 run-3.3-Gemfile - 33553892511.9 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
10 run-4.0-gemfiles/grape_swagger.gemfile - 33553892511.10 01 Sep 2026 08:12PM UTC 168
55.15
GitHub Action Run
11 run-3.3-gemfiles/rails_8_0.gemfile - 33553892511.11 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
12 run-3.4-gemfiles/rails_7_2.gemfile - 33553892511.12 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
13 run-3.4-gemfiles/rack_3_0.gemfile - 33553892511.13 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
14 run-4.0-gemfiles/rails_8_0.gemfile - 33553892511.14 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
15 run-3.4-gemfiles/rails_8_1.gemfile - 33553892511.15 01 Sep 2026 08:13PM UTC 169
95.73
GitHub Action Run
16 run-4.0-gemfiles/rack_2_2.gemfile - 33553892511.16 01 Sep 2026 08:13PM UTC 168
95.69
GitHub Action Run
17 run-4.0-gemfiles/rack_3_0.gemfile - 33553892511.17 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
18 run-3.4-gemfiles/rack_2_2.gemfile - 33553892511.18 01 Sep 2026 08:12PM UTC 168
95.69
GitHub Action Run
19 run-3.3-gemfiles/rack_2_2.gemfile - 33553892511.19 01 Sep 2026 08:12PM UTC 168
95.69
GitHub Action Run
20 run-3.4-gemfiles/rack_3_2.gemfile - 33553892511.20 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
21 run-4.0-gemfiles/multi_json.gemfile - 33553892511.21 01 Sep 2026 08:12PM UTC 168
47.35
GitHub Action Run
22 run-4.0-Gemfile - 33553892511.22 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
23 run-4.0-gemfiles/grape_entity.gemfile - 33553892511.23 01 Sep 2026 08:12PM UTC 168
50.24
GitHub Action Run
24 run-3.3-gemfiles/rack_3_1.gemfile - 33553892511.24 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
25 run-3.4-gemfiles/rack_3_1.gemfile - 33553892511.25 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
26 run-4.0-gemfiles/multi_xml.gemfile - 33553892511.26 01 Sep 2026 08:12PM UTC 168
46.86
GitHub Action Run
27 run-3.4-Gemfile - 33553892511.27 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
28 run-4.0-gemfiles/rack_3_1.gemfile - 33553892511.28 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
29 run-3.4-gemfiles/rails_8_0.gemfile - 33553892511.29 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
30 run-3.3-gemfiles/rack_3_0.gemfile - 33553892511.30 01 Sep 2026 08:12PM UTC 168
95.73
GitHub Action Run
31 run-4.0-gemfiles/dry_validation.gemfile - 33553892511.31 01 Sep 2026 08:12PM UTC 168
57.83
GitHub Action Run
32 run-4.0-gemfiles/rails_8_1.gemfile - 33553892511.32 01 Sep 2026 08:12PM UTC 169
95.73
GitHub Action Run
Source Files on build 33553892511
  • Tree
  • List 169
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33553892511
  • Pull Request #2872
  • PR Base - master (#33553778244)
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