From 5cc8af700970f3266876dc9c69f70514e6285492 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 19 Mar 2026 17:01:25 -0700 Subject: [PATCH] Precompile shipit assets before benchmark iterations The shipit-engine ships CoffeeScript assets that require a Node.js runtime to compile via Sprockets. Without precompilation, Sprockets shells out to Node.js on the first request during warmup/benchmark iterations, adding noise to timing measurements. Run assets:precompile once before any iterations, and skip it on subsequent runs by checking for the Sprockets manifest file. Fixes https://github.com/ruby/ruby-bench/issues/493 --- benchmarks/shipit/benchmark.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/benchmarks/shipit/benchmark.rb b/benchmarks/shipit/benchmark.rb index 54e51dfa..3787cc03 100644 --- a/benchmarks/shipit/benchmark.rb +++ b/benchmarks/shipit/benchmark.rb @@ -14,6 +14,15 @@ require_relative 'config/environment' require_relative "route_generator" +# Precompile assets once so that Sprockets never shells out to Node.js during +# warmup/benchmark iterations (shipit-engine ships CoffeeScript assets). +unless Dir.glob(File.join(__dir__, 'public/assets/.sprockets-manifest*.json')).any? + puts "Precompiling assets..." + Rails.application.load_tasks + Rake::Task['assets:precompile'].invoke + puts "Assets precompiled." +end + # For an in-mem DB, we need to load all data on every boot mem_db = ActiveRecord::Base.connection.raw_connection file_db = SQLite3::Database.new('db/production.committed.sqlite3')