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

ruby-grape / grape / 26339201491 / 18
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/recompile-settings-mutation-race
DEFAULT BRANCH: master
Ran 23 May 2026 05:41PM UTC
Files 164
Run time 8s
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

23 May 2026 05:36PM UTC coverage: 95.704% (+0.01%) from 95.691%
26339201491.18

Pull #2739

github

ericproulx
Lazy-allocate `@new_values` in `Grape::Util::BaseInheritable`

`BaseInheritable#initialize` used to eagerly allocate an empty
`@new_values = {}` per instance. Most settings layers in a typical API
only inherit from a parent and never write any *new* values of their
own, so the empty Hash was just retained dead weight.

Defer the allocation: `@new_values` starts nil, the `[]=` writers do
`(@new_values ||= {})[name] = ...`, and the read paths in
`InheritableValues#[]` / `StackableValues#[]` short-circuit on nil so
they skip the lookup entirely instead of touching an empty Hash.
`initialize_copy` skips the `.dup` when the source has no own values.

Measured on master with a small benchmark:

  Grape::Util::InheritableSetting.new ×100
    before: 1600 objects, 183.6 kB
    after:  1200 objects, 121.1 kB   (-34%)

  parent.point_in_time_copy ×100
    before: 2500 objects, 277.3 kB
    after:  1700 objects, 152.3 kB   (-45%)

The bigger win on `point_in_time_copy` matches the
`base_inheritable.rb:27` (`new_values.dup`) hot spot in the boot-time
memory profile: that line previously dup'd four empty Hashes per copy
and now skips them entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull Request #2739: Lazy-allocate @new_values in Grape::Util::BaseInheritable

1074 of 1183 branches covered (90.79%)

Branch coverage included in aggregate %.

3493 of 3589 relevant lines covered (97.33%)

979.46 hits per line

Source Files on job run-4.0-gemfiles/rails_8_1.gemfile - 26339201491.18
  • Tree
  • List 164
  • Changed 3
  • Source Changed 3
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 26339201491
  • faf5e4a6 on github
  • Prev Job for on perf/lazy-base-inheritable-new-values (#26292056269.36)
  • Next Job for on perf/lazy-base-inheritable-new-values (#26468374615.22)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc