binpacker 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae35133b41b6a8423c8caa45b91a4153498099d2f04c790aeada3fb1e4e0d52a
4
- data.tar.gz: 5e537cf525779a2783db551b1bf86f7525ce34558f16ce8c2eab253712454b8e
3
+ metadata.gz: 7a54ccc149cfd16f8e0b0d5e77bd91aaa9cbd3b521aa1522eb53b1489c419c80
4
+ data.tar.gz: f4f764a98514a624239cf719926f71c9b3ef86657a5fb2554671089b17dce661
5
5
  SHA512:
6
- metadata.gz: ab3dd9a1c6993908e7e646c697d649745d029f15c6a77981ec8b2dd3735afebf92f6194a97e60e2923acc5500fa475e2f7118673cc6c18e2c49ba0a4aa7a7dc1
7
- data.tar.gz: ad30734e5dbadb596dd753f90ff1163bbc0a12fa60f8d080baad357f9ed2be3ac8a9667d2ed8a52dab2ced6e3e76d2931a1368613976f0a4e2a5af3fd1c4a8da
6
+ metadata.gz: 6a5af54cb448cbea6b2817357598f10b62c8f5e8194027b66ff9b0edbf0181301264e5d0c80ef2aec0ec216061bbf5ded54fbfcc2995aab0f9b27f5513de0ff0
7
+ data.tar.gz: b14adfb8f4d565b5fcc8ef3907d90fbae23a72517c3495b6f2a347a13eb2b5ae7e2c0ae76622e43cfd58e2e3e63fe07b74c448a8558d16254ce064827b8bdb9a
data/lib/binpacker/cli.rb CHANGED
@@ -17,6 +17,8 @@ module Binpacker
17
17
  @quiet = false
18
18
  @incremental = false
19
19
  @report_path = nil
20
+ @base_path = nil
21
+ @output_path = nil
20
22
  @skill_list = false
21
23
  @skill_path = false
22
24
  @skill_describe = false
@@ -35,6 +37,8 @@ module Binpacker
35
37
  cmd_run
36
38
  when 'shards-check'
37
39
  cmd_shards_check
40
+ when 'shards-merge'
41
+ cmd_shards_merge
38
42
  when 'init'
39
43
  cmd_init
40
44
  when 'skill'
@@ -86,6 +90,14 @@ module Binpacker
86
90
  @shard_spec = v
87
91
  end
88
92
 
93
+ opts.on('--base PATH', '(shards-merge) The timing file every shard started from') do |v|
94
+ @base_path = v
95
+ end
96
+
97
+ opts.on('--output PATH', '(shards-merge) Where to write the merged timing file') do |v|
98
+ @output_path = v
99
+ end
100
+
89
101
  opts.on('--list', '(skill) List bundled skills') do
90
102
  @skill_list = true
91
103
  end
@@ -110,7 +122,7 @@ module Binpacker
110
122
  # (e.g. --version), so `binpacker --version` isn't clobbered to nil.
111
123
  @command = remaining.shift || @command
112
124
  @skill_name = remaining.first
113
- # `shards-check` takes a list of run-report paths, so the positionals stay available in full rather
125
+ # `shards-check` and `shards-merge` take a list of paths, so the positionals stay available in full rather
114
126
  # than being consumed into the single-name slot `skill` uses.
115
127
  @shard_reports = remaining
116
128
  end
@@ -289,6 +301,32 @@ module Binpacker
289
301
  exit 1
290
302
  end
291
303
 
304
+ # Run after a sharded matrix, over the timing file each shard wrote back. Each shard measured only its
305
+ # own slice, so keeping any one of their files throws the other slices' measurements away.
306
+ def cmd_shards_merge
307
+ problems = []
308
+ problems << '--output PATH is required' unless @output_path
309
+ problems << 'no shard timing files given' if @shard_reports.empty?
310
+ missing = @shard_reports.reject { |path| File.exist?(path) }
311
+ problems.concat(missing.map { |path| "shard timing file not found: #{path}" })
312
+ if @base_path && !File.exist?(@base_path)
313
+ problems << "base timing file not found: #{@base_path} (omit --base on a cold start)"
314
+ end
315
+ unless problems.empty?
316
+ problems.each { |problem| warn problem }
317
+ exit 1
318
+ end
319
+
320
+ result = ShardMerge.call(base: @base_path, shards: @shard_reports, output: @output_path)
321
+ puts "Merged #{@shard_reports.size} shard timing #{pluralize(@shard_reports.size, 'file')} into " \
322
+ "#{@output_path}: #{result.updated} of #{result.tests} #{pluralize(result.tests, 'test')} re-measured."
323
+ return if result.conflicts.zero?
324
+
325
+ warn "#{result.conflicts} #{pluralize(result.conflicts, 'test')} re-measured by more than one shard " \
326
+ '(the later file won): an overlapping split, which `binpacker shards-check` reports, or a shared ' \
327
+ 'example group run by several shards.'
328
+ end
329
+
292
330
  def test_unit_label(config)
293
331
  config.test_runner == 'rspec' ? 'example' : 'test'
294
332
  end
@@ -304,6 +342,7 @@ module Binpacker
304
342
  Commands:
305
343
  run Execute tests across worker processes
306
344
  shards-check Verify a sharded matrix's run reports cover the whole suite
345
+ shards-merge Fold the timing files a sharded matrix wrote into one
307
346
  calibrate Run tests serially to generate timing data
308
347
  init Create binpacker.yml with auto-detected settings
309
348
  describe Report project state and recommend the next skill
@@ -314,6 +353,8 @@ module Binpacker
314
353
  --incremental (calibrate) Measure only tests without timing data
315
354
  --report PATH (run) Write a JSON run report to PATH
316
355
  --shard K/N (run) Run only shard K of N (1-based; env: BINPACKER_SHARD)
356
+ --base PATH (shards-merge) The timing file every shard started from
357
+ --output PATH (shards-merge) Where to write the merged timing file
317
358
  --list (skill) List bundled skills
318
359
  --path (skill) Print the SKILL.md path for <name>
319
360
  --describe (skill) Report project state and next skill
@@ -325,6 +366,7 @@ module Binpacker
325
366
  binpacker run -- --tag ~slow
326
367
  binpacker run --shard 2/3 --report shard-2.json
327
368
  binpacker shards-check shard-*.json
369
+ binpacker shards-merge --base base.timings --output merged.timings shard-*.timings
328
370
  binpacker calibrate --incremental
329
371
  binpacker describe
330
372
  binpacker skill binpacker-setup
@@ -15,6 +15,7 @@ module Binpacker
15
15
  "test_pattern" => "spec/**/*_spec.rb",
16
16
  "test_exclude" => [],
17
17
  "report_file" => nil,
18
+ "normalize_speed" => false,
18
19
  "scheduler" => {
19
20
  "strategy" => "static",
20
21
  "steal_enabled" => false,
@@ -44,6 +44,7 @@ module Binpacker
44
44
  @discovered_count = tests.size
45
45
  tests = @shard.select(tests: tests, timings: timings, scheduler: scheduler) if @shard
46
46
  @selected_count = tests.size
47
+ @selected_keys = tests.map(&:key)
47
48
 
48
49
  queues = scheduler.partition(
49
50
  tests: tests,
@@ -128,6 +129,7 @@ module Binpacker
128
129
  }
129
130
  end
130
131
  progress.summary(worker_stats)
132
+ @speed_factor = timing.speed_factor(all_timings)
131
133
  write_report(worker_stats, all_timings)
132
134
 
133
135
  finalize(timing, all_timings, all_passed, total_examples, passed_examples, tests)
@@ -236,6 +238,7 @@ module Binpacker
236
238
  }
237
239
  end
238
240
  progress.summary(worker_stats)
241
+ @speed_factor = timing.speed_factor(all_timings)
239
242
  write_report(worker_stats, all_timings)
240
243
 
241
244
  workers.each(&:cleanup)
@@ -251,7 +254,11 @@ module Binpacker
251
254
  predicted_loads: @predicted_loads,
252
255
  worker_stats: worker_stats,
253
256
  all_timings: all_timings,
254
- timings: @timings,
257
+ # Only this run's own tests: the weights cover the whole suite (a shard cuts from all of them), and
258
+ # comparing them with a slice's measurements lists every other shard's files as "actual 0.0".
259
+ timings: @timings.slice(*@selected_keys),
260
+ speed_factor: @speed_factor,
261
+ normalized: normalize?,
255
262
  shard: @shard,
256
263
  discovered: @discovered_count,
257
264
  selected: @selected_count
@@ -292,7 +299,7 @@ module Binpacker
292
299
 
293
300
  def finalize(timing, all_timings, all_passed, total_examples, passed_examples, tests)
294
301
  unless all_timings.empty?
295
- timing.append_all(all_timings)
302
+ timing.append_all(normalize? ? normalized(all_timings) : all_timings)
296
303
  timing.compact!
297
304
  end
298
305
  empty_filter = minitest_empty_filter?(tests, total_examples)
@@ -307,6 +314,17 @@ module Binpacker
307
314
  }
308
315
  end
309
316
 
317
+ # `normalize_speed: true` records each sample divided by the run's speed factor (Timing#speed_factor),
318
+ # so a history fed by runners of different speeds stays on one scale. Off by default: on one machine
319
+ # the factor is noise around 1.0, and the recorded seconds stop being wall-clock seconds.
320
+ def normalize?
321
+ @config.normalize_speed && !@speed_factor.nil?
322
+ end
323
+
324
+ def normalized(entries)
325
+ entries.map { |e| e.merge(time: e[:time] / @speed_factor) }
326
+ end
327
+
310
328
  def minitest_empty_filter?(tests, total_examples)
311
329
  return false unless @config.test_runner == 'minitest'
312
330
  return false unless tests.any?
@@ -10,13 +10,15 @@ module Binpacker
10
10
  DRIFT_LIMIT = 10
11
11
 
12
12
  def initialize(profile:, algorithm:, predicted_loads:, worker_stats:, all_timings:, timings:,
13
- shard: nil, discovered: nil, selected: nil)
13
+ speed_factor: nil, normalized: false, shard: nil, discovered: nil, selected: nil)
14
14
  @profile = profile
15
15
  @algorithm = algorithm
16
16
  @predicted_loads = predicted_loads
17
17
  @worker_stats = worker_stats
18
18
  @all_timings = all_timings
19
19
  @timings = timings
20
+ @speed_factor = speed_factor
21
+ @normalized = normalized
20
22
  @shard = shard
21
23
  @discovered = discovered
22
24
  @selected = selected
@@ -39,6 +41,10 @@ module Binpacker
39
41
  predicted_deviation_pct: deviation_pct(predicted),
40
42
  actual_deviation_pct: deviation_pct(actual)
41
43
  },
44
+ speed: {
45
+ factor: @speed_factor&.round(3),
46
+ normalized: @normalized
47
+ },
42
48
  drift: drift
43
49
  }
44
50
  end
@@ -88,7 +94,11 @@ module Binpacker
88
94
  # are compared at the same granularity even when timings are recorded
89
95
  # per example. Both sides are aggregated to normalized file paths.
90
96
  def drift
91
- actual = aggregate_by_file(@all_timings.map { |e| [e[:file], e[:time]] })
97
+ # A normalized run's history is on the normalized scale, so its measurements are put on that scale too:
98
+ # otherwise a slow runner drifts every file by its factor and the heaviest files crowd out the ones
99
+ # whose cost really changed.
100
+ scale = @normalized && @speed_factor ? @speed_factor : 1.0
101
+ actual = aggregate_by_file(@all_timings.map { |e| [e[:file], e[:time] / scale] })
92
102
  predicted = aggregate_by_file(@timings.map { |(file, _name), weight| [file, weight] })
93
103
 
94
104
  (actual.keys | predicted.keys)
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binpacker
4
+ # Folds the timing files a sharded matrix wrote back into one.
5
+ #
6
+ # Every shard starts from the same timing file (it must, to cut the same partition), measures only its own
7
+ # slice, and writes the whole file back: its slice's tests with a fresh sample, everyone else's exactly as
8
+ # restored. A CI cache can keep one of those files, not all of them, so without a merge each run's history
9
+ # gains one shard's measurements and loses the rest — the other slices' weights age until a run happens to
10
+ # put their files in the shard whose file was kept.
11
+ #
12
+ # The merge needs no record of which shard ran what: a test a shard did not run is byte-for-byte what the
13
+ # base held, so per test, the shard whose samples differ from the base is the one that measured it. In a
14
+ # coherent split that is at most one shard. Should two disagree anyway — an overlapping partition, or rspec
15
+ # filing a shared example group's timings under the group's own file, which two shards can both run — the
16
+ # later file on the command line wins, and the test is counted in Result#conflicts rather than dropped.
17
+ class ShardMerge
18
+ Result = Struct.new(:tests, :updated, :conflicts, keyword_init: true)
19
+
20
+ def self.call(base:, shards:, output:)
21
+ new(base: base, shards: shards, output: output).call
22
+ end
23
+
24
+ def initialize(base:, shards:, output:)
25
+ @base = base
26
+ @shards = shards
27
+ @output = output
28
+ end
29
+
30
+ def call
31
+ # Compared as the shards will have written it back: compaction trims every test to its most recent
32
+ # samples, so against an uncompacted base every test would look re-measured by every shard.
33
+ base = (@base ? Timing.new(@base).samples : {}).transform_values { |t| t.last(Timing::MAX_SAMPLES_PER_TEST) }
34
+ merged = base.dup
35
+ writers = Hash.new(0)
36
+
37
+ @shards.each do |path|
38
+ Timing.new(path).samples.each do |key, times|
39
+ next if base[key] == times
40
+
41
+ writers[key] += 1
42
+ merged[key] = times
43
+ end
44
+ end
45
+
46
+ Timing.new(@output).write_samples(merged)
47
+ Result.new(tests: merged.size, updated: writers.size, conflicts: writers.count { |_key, n| n > 1 })
48
+ end
49
+ end
50
+ end
@@ -13,6 +13,23 @@ module Binpacker
13
13
  # run (GC pause, noisy CI neighbour) unable to move the weight.
14
14
  MAX_SAMPLES_PER_TEST = 3
15
15
 
16
+ # A run's speed factor is the median, over the files it measured that
17
+ # already carry history, of measured / predicted seconds. Files lighter
18
+ # than this are left out: their few-millisecond weights swing on noise
19
+ # that says nothing about the machine.
20
+ SPEED_FACTOR_MIN_FILE_WEIGHT = 1.0
21
+
22
+ # Fewer qualifying files than this and the run's factor is not
23
+ # estimated at all: a median over a handful of files mostly measures
24
+ # those files' own changes.
25
+ SPEED_FACTOR_MIN_FILES = 5
26
+
27
+ # A factor this close to 1.0 is recorded as 1.0. Each run's factor is an
28
+ # estimate, and dividing by it every run would compound that estimate's
29
+ # noise into a slow drift of the whole history's scale; inside the band
30
+ # the run's samples are kept as measured seconds.
31
+ SPEED_FACTOR_DEADBAND = 0.05
32
+
16
33
  def initialize(path)
17
34
  @path = Pathname(path)
18
35
  end
@@ -57,6 +74,49 @@ module Binpacker
57
74
  samples = samples_by_test
58
75
  return if samples.empty?
59
76
 
77
+ write_samples(samples)
78
+ end
79
+
80
+ # How fast the machine that produced +entries+ (one run's measured
81
+ # timings) ran against the history in this file: the median, over the
82
+ # files both sides know, of measured / predicted seconds. 2.0 means the
83
+ # run took twice as long as its history predicts; nil when too few
84
+ # files qualify to say (see SPEED_FACTOR_MIN_FILES).
85
+ #
86
+ # CI runners are not one machine. The same slice of a suite has run in
87
+ # 664s on one runner and 1208s on another, and a sample recorded on the
88
+ # slow one inflates its files' weights against every other file's, so
89
+ # the next partition is cut on a skewed scale. Dividing a run's samples
90
+ # by its factor before recording them keeps the history on one scale.
91
+ # The median is over files, not a ratio of sums, so one file that
92
+ # genuinely got slower in this run cannot move the factor much.
93
+ def speed_factor(entries)
94
+ predicted = load_per_file
95
+ actual = entries.each_with_object(Hash.new(0.0)) do |e, acc|
96
+ acc[normalize_path(e[:file])] += e[:time].to_f
97
+ end
98
+
99
+ ratios = actual.filter_map do |file, seconds|
100
+ weight = predicted[file]
101
+ next if weight.nil? || weight < SPEED_FACTOR_MIN_FILE_WEIGHT || !seconds.positive?
102
+
103
+ seconds / weight
104
+ end
105
+ return nil if ratios.size < SPEED_FACTOR_MIN_FILES
106
+
107
+ factor = median(ratios)
108
+ (factor - 1.0).abs < SPEED_FACTOR_DEADBAND ? 1.0 : factor
109
+ end
110
+
111
+ # [normalized file, name] => [sample, ...] in append (= run) order.
112
+ def samples
113
+ samples_by_test.transform_values(&:dup)
114
+ end
115
+
116
+ # Replaces the file's contents with +samples+ (the shape #samples
117
+ # returns), keeping the most recent MAX_SAMPLES_PER_TEST per test.
118
+ def write_samples(samples)
119
+ @path.dirname.mkpath unless @path.dirname.directory?
60
120
  tmp = Pathname("#{@path}.tmp")
61
121
  tmp.open('w', encoding: 'UTF-8') do |io|
62
122
  samples.each do |(file, name), times|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Binpacker
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
data/lib/binpacker.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'binpacker/worker_queue'
8
8
  require_relative 'binpacker/scheduler'
9
9
  require_relative 'binpacker/shard'
10
10
  require_relative 'binpacker/shard_check'
11
+ require_relative 'binpacker/shard_merge'
11
12
  require_relative 'binpacker/worker'
12
13
  require_relative 'binpacker/test_runner'
13
14
  require_relative 'binpacker/calibration'
@@ -8,6 +8,7 @@ module Binpacker
8
8
  def test_exclude: () -> Array[String]
9
9
  def test_granularity: () -> String
10
10
  def report_file: () -> String?
11
+ def normalize_speed: () -> bool
11
12
  def profile: () -> String
12
13
  end
13
14
  end
@@ -12,6 +12,8 @@ module Binpacker
12
12
  @selected_count: Integer
13
13
  @timings: Hash[untyped, Float]
14
14
  @predicted_loads: Array[Float]
15
+ @selected_keys: Array[untyped]
16
+ @speed_factor: Float?
15
17
 
16
18
  def initialize: (untyped, ?passthrough: untyped, ?quiet: untyped, ?report_path: untyped, ?shard: Binpacker::Shard?) -> void
17
19
  def run: () -> { passed: untyped, total: untyped, passed_count: untyped, timings: Array[untyped], empty_filter: untyped }
@@ -25,6 +27,8 @@ module Binpacker
25
27
  def min_batch_weight: (Binpacker::Timing, Hash[untyped, Float]) -> Float
26
28
  def drain_batch: (Binpacker::WorkerQueue?, Float) -> Array[untyped]
27
29
  def finalize: (Binpacker::Timing, Array[untyped], untyped, untyped, untyped, untyped) -> { passed: untyped, total: untyped, passed_count: untyped, timings: Array[untyped], empty_filter: untyped }
30
+ def normalize?: () -> bool
31
+ def normalized: (Array[Hash[Symbol, untyped]]) -> Array[Hash[Symbol, untyped]]
28
32
  def minitest_empty_filter?: (untyped, untyped) -> bool
29
33
  def minitest_include_filter?: () -> bool
30
34
  end
@@ -3,7 +3,7 @@ module Binpacker
3
3
  SCHEMA: Integer
4
4
  DRIFT_LIMIT: Integer
5
5
 
6
- def initialize: (profile: untyped, algorithm: untyped, predicted_loads: untyped, worker_stats: untyped, all_timings: untyped, timings: untyped, ?shard: Binpacker::Shard?, ?discovered: Integer?, ?selected: Integer?) -> void
6
+ def initialize: (profile: untyped, algorithm: untyped, predicted_loads: untyped, worker_stats: untyped, all_timings: untyped, timings: untyped, ?speed_factor: Float?, ?normalized: bool, ?shard: Binpacker::Shard?, ?discovered: Integer?, ?selected: Integer?) -> void
7
7
  def shard_section: () -> Hash[Symbol, untyped]?
8
8
  def to_h: () -> Hash[Symbol, untyped]
9
9
  def write: (untyped) -> untyped
@@ -0,0 +1,18 @@
1
+ module Binpacker
2
+ class ShardMerge
3
+ class Result
4
+ attr_accessor tests: Integer
5
+ attr_accessor updated: Integer
6
+ attr_accessor conflicts: Integer
7
+ end
8
+
9
+ @base: String?
10
+ @shards: Array[String]
11
+ @output: String
12
+
13
+ def self.call: (base: String?, shards: Array[String], output: String) -> Binpacker::ShardMerge::Result
14
+
15
+ def initialize: (base: String?, shards: Array[String], output: String) -> void
16
+ def call: () -> Binpacker::ShardMerge::Result
17
+ end
18
+ end
@@ -3,13 +3,19 @@ module Binpacker
3
3
  def initialize: (untyped) -> void
4
4
  DEFAULT_WEIGHT: Float
5
5
  MAX_SAMPLES_PER_TEST: Integer
6
+ SPEED_FACTOR_MIN_FILE_WEIGHT: Float
7
+ SPEED_FACTOR_MIN_FILES: Integer
8
+ SPEED_FACTOR_DEADBAND: Float
6
9
  def calibrated?: () -> bool
7
10
  def load_with_fallback: (untyped) -> Hash[untyped, Float]
8
11
  def load_raw: () -> (Hash[[String, untyped], untyped] | {})
9
12
  def load_per_file: () -> (Hash[String, untyped] | {})
10
13
  def normalize_path: (untyped) -> String
11
14
  def measured?: (file: untyped, name: untyped) -> bool
12
- def compact!: () -> nil
15
+ def compact!: () -> void
16
+ def speed_factor: (Array[Hash[Symbol, untyped]]) -> Float?
17
+ def samples: () -> Hash[[String, untyped], Array[Float]]
18
+ def write_samples: (Hash[[String, untyped], Array[Float]]) -> void
13
19
  def append_all: (untyped) -> nil
14
20
  class Entry
15
21
  end
@@ -22,8 +22,11 @@ Collect several recent reports so you can see trends, not just one run. Each rep
22
22
 
23
23
  ## 2. Analyze
24
24
 
25
+ **On a sharded matrix, first rule out causes that are not binpacker's.** Compare each shard's `predicted_makespan`: when they agree, the partition is already equal and the jobs' wall-clock difference came from somewhere else — most often steps pinned to one matrix arm (`if: matrix.shard == 1`) that the matrix runs once and parked arbitrarily. No config lever fixes that; the step needs its own job. Say so plainly rather than proposing a scheduler change that cannot help.
26
+
25
27
  Look for patterns across the reports:
26
28
 
29
+ - **One file over the per-worker budget** — divide total predicted weight by shards × workers to get the floor every shard should reach, then look for a single `predicted` above it. That file occupies a whole worker and sets its shard's makespan alone, and no partition or shard count can beat it. Attribute it per-example from the timing file (see the README's sharding section) before proposing a split — the cost is usually concentrated in one block, which makes the seam obvious.
27
30
  - **Persistent worker skew** — the same worker is consistently slowest → the partition or worker count is off.
28
31
  - **Predicted vs actual gap** — `actual_makespan` far above `predicted_makespan` → timing data is stale; the scheduler is planning against wrong Weights.
29
32
  - **Recurring high-drift files** — the same files top the `drift` list every run → their timing data is stale or they are outliers.
@@ -38,6 +41,9 @@ Present a concrete `binpacker.yml` diff and/or commands, with the evidence behin
38
41
  - **`scheduler.steal_enabled`** — enable when static balance is poor but runtime stealing would recover it.
39
42
  - **Re-calibrate** — when drift is high or timing is stale, recommend `binpacker calibrate --incremental` to refresh the drifting Tests.
40
43
  - **Commit a baseline** — when the cache misses often (dependency-bump churn) or timings have stabilised, recommend committing `binpacker.timings` as a durable baseline (cold-start floor). See `docs/adr/0005-two-tier-timing-persistence.md`.
44
+ - **Discard the history** — after any test file was split, renamed or deleted. binpacker never drops entries for tests that no longer exist, so the old path stays charged for them while the new one falls back to filesize. A high-drift file whose `predicted` far exceeds its `actual` is the signature; check whether it was recently split before recalibrating. See the README's "Timing data after a file moves".
45
+
46
+ Read `predicted` against `actual` before trusting any of the above: a report whose CI job logged a timing-cache miss was partitioned on filesize weighting, and its balance says nothing about the config.
41
47
 
42
48
  ## 4. Confirm and apply
43
49
 
@@ -54,10 +54,15 @@ Check the summary's `Balance: max deviation`. A large deviation on the first run
54
54
  Add (or extend) a CI workflow so the suite runs under binpacker. The workflow should:
55
55
 
56
56
  - Install binpacker (via the project's dependency manager or `gem install binpacker`).
57
- - Restore and save `binpacker.timings` with `actions/cache` (key includes OS + a hash of the test files). This is the runtime timing layer.
57
+ - Restore and save `binpacker.timings` with `actions/cache` (key includes OS + a hash of the test files). This is the runtime timing layer. Put a **generation token** in the key (`binpacker-timings-v1-…`) so the history can be discarded later — it has to be, whenever a test file is split, renamed or deleted.
58
58
  - Run `binpacker run --profile ci` (which emits the run report via `report_file`).
59
59
  - Upload the run report with `actions/upload-artifact` so `binpacker-improve` can read it later.
60
60
 
61
+ Two things that only fail on a cache miss, so verify them rather than assuming the first green run proved them:
62
+
63
+ - **The `--report` directory must already exist.** binpacker creates the timing file's directory but not the report's, so `--report tmp/report.json` raises `ENOENT` unless something made `tmp/` first. A restored timing cache creates it as a side effect, which hides the problem until the first genuine miss — and then the whole matrix fails with every test passing. Add an explicit `mkdir -p`.
64
+ - **A cache-key bump costs two cold runs.** Caches saved on a feature branch are invisible to the default branch, so the first run after the merge is cold too.
65
+
61
66
  Propose the workflow YAML and let the user review it before writing.
62
67
 
63
68
  ## 6. Handoff
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - megurine
@@ -31,6 +31,7 @@ files:
31
31
  - lib/binpacker/scheduler.rb
32
32
  - lib/binpacker/shard.rb
33
33
  - lib/binpacker/shard_check.rb
34
+ - lib/binpacker/shard_merge.rb
34
35
  - lib/binpacker/skills.rb
35
36
  - lib/binpacker/test_discovery.rb
36
37
  - lib/binpacker/test_runner.rb
@@ -48,6 +49,7 @@ files:
48
49
  - sig/binpacker/scheduler.rbs
49
50
  - sig/binpacker/shard.rbs
50
51
  - sig/binpacker/shard_check.rbs
52
+ - sig/binpacker/shard_merge.rbs
51
53
  - sig/binpacker/skills.rbs
52
54
  - sig/binpacker/test_discovery.rbs
53
55
  - sig/binpacker/test_runner.rbs
@@ -76,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
78
  - !ruby/object:Gem::Version
77
79
  version: '0'
78
80
  requirements: []
79
- rubygems_version: 4.0.10
81
+ rubygems_version: 4.0.16
80
82
  specification_version: 4
81
83
  summary: Reduce CI test-suite makespan via identical-machines scheduling
82
84
  test_files: []