Skip to content

Load the RSS measurement code prior to the first benchmark iteration - #577

Merged
nirvdrum merged 1 commit into
mainfrom
eager-load-rss-sampler
Nov 12, 2026
Merged

nirvdrum merged 1 commit into
mainfrom
eager-load-rss-sampler

Conversation

@nirvdrum

Copy link
Copy Markdown
Contributor

On macOS, RSS is measured via Fiddle and loading it the way ruby-bench does (force-activation) via Bundler, loads code that redefines methods like == and hash, leading to cache invalidation that adversely affects benchmark runs.

@XrXr XrXr left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.
If it has to be be in use_gemfile, fine, but is it possible to simplify the loading processing by lifting the

    @fn = begin
      load_fiddle
      Fiddle::Function.new(
        Fiddle.dlopen(nil)['proc_pid_rusage'],
        [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP],
        Fiddle::TYPE_INT,
      )
    rescue LoadError, Fiddle::DLError, NameError
      nil
    end

out into module ProcPidUsage scope? (Or call it if macos.) Generally memoization is not a great pattern for stability.

@tekknolagi tekknolagi changed the title Load the RSS measurement code prior to the first benchmark iteration. Load the RSS measurement code prior to the first benchmark iteration Nov 11, 2026
@tekknolagi

Copy link
Copy Markdown
Contributor

+1 just eager load it who cares

@tekknolagi

Copy link
Copy Markdown
Contributor

lgtm

@nirvdrum
nirvdrum force-pushed the eager-load-rss-sampler branch from 0aadf44 to 3aeaf36 Compare November 11, 2026 23:18
On macOS, RSS is measured via Fiddle and loading it the way ruby-bench does (force-activation) via Bundler, loads code that redefines methods like `==` and `hash`, leading to cache invalidation that adversely affects benchmark runs.
@nirvdrum
nirvdrum force-pushed the eager-load-rss-sampler branch from 3aeaf36 to 34d4d22 Compare November 11, 2026 23:36
@nirvdrum
nirvdrum merged commit ab81550 into main Nov 12, 2026
15 checks passed
@nirvdrum
nirvdrum deleted the eager-load-rss-sampler branch November 12, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants