duel 0.1.6 → 0.1.7
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 +4 -4
- data/CHANGELOG.md +26 -1
- data/docs/ci.md +25 -17
- data/docs/how-it-works.md +14 -0
- data/docs/json.md +2 -2
- data/lib/duel/cli.rb +9 -2
- data/lib/duel/memory.rb +54 -0
- data/lib/duel/runner.rb +48 -2
- data/lib/duel/templates/perf.yml.erb +14 -9
- data/lib/duel/version.rb +1 -1
- data/sig/duel/memory.rbs +30 -0
- data/sig/duel/runner.rbs +19 -2
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c2e7b0e6e07fe45ff7a77955035a06be6850e761c9ff2f0b10c0ab4b5130eed
|
|
4
|
+
data.tar.gz: fe086be96d5238e8befcffd0bc7adfb8ef94d0a83790f1ab74a82f881cc3786e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 731c24cb25017b1f1fba0546523c8c895400eb2750d260e58072c9537afc952fdf2b29bbc90d6242ef5b9463004203782c637cb21c5ea4bf075291866a44a939
|
|
7
|
+
data.tar.gz: 6b98fb68a77b594457ea5b0f9b3bb88fab03c55a606ce7741ae7c970a4cab829000521d62effce598ed64ca362fca1e0b7e1ee50b209fa9b800fb4e6e16e2839
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.7] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Duel measures fewer benchmarks at once, and where even one
|
|
15
|
+
benchmark's workers wouldn't fit, starts fewer workers, so that they
|
|
16
|
+
fit in the memory available. Since 0.1.6 starts twelve workers of
|
|
17
|
+
each version for each benchmark it measures at once, a plugin whose
|
|
18
|
+
workers each start a server could run a machine out of memory: on a
|
|
19
|
+
GitHub runner, duel-mysql's 48 MySQL servers took more than its
|
|
20
|
+
16 GB, and the runner stopped answering until its job was lost. Duel
|
|
21
|
+
starts one worker of each version first to find what a pair takes
|
|
22
|
+
(with its resources), and allows each pair a quarter more, and 1 GB
|
|
23
|
+
for everything else. It reads what's available from Linux's
|
|
24
|
+
MemAvailable (or a container's cgroup limit, if lower) or macOS's
|
|
25
|
+
`vm_stat`, and its first line says when it lowered either. A
|
|
26
|
+
`--jobs` or `--processes` you give is kept as it is.
|
|
27
|
+
- The badge (in the workflow that `duel init --badge` writes) says
|
|
28
|
+
"not measured", in grey, where the Duel job failed
|
|
29
|
+
before Duel judged the push (its runner lost, say, or a step before
|
|
30
|
+
Duel's failed), instead of "perf regressed". It's red only where
|
|
31
|
+
Duel failed the push or found a regression, and a job that fails
|
|
32
|
+
after Duel passed the push leaves it green.
|
|
33
|
+
|
|
10
34
|
## [0.1.6] - 2026-11-10
|
|
11
35
|
|
|
12
36
|
### Added
|
|
@@ -682,7 +706,8 @@ needs Ruby 3.4 or later (or JRuby 10, or TruffleRuby 40).
|
|
|
682
706
|
Anything marked `@api private`, in lib/ and sig/, may change in any
|
|
683
707
|
release.
|
|
684
708
|
|
|
685
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/v0.1.
|
|
709
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/v0.1.7...HEAD
|
|
710
|
+
[0.1.7]: https://github.com/sferik/duel-ruby/compare/v0.1.6...v0.1.7
|
|
686
711
|
[0.1.6]: https://github.com/sferik/duel-ruby/compare/v0.1.5...v0.1.6
|
|
687
712
|
[0.1.5]: https://github.com/sferik/duel-ruby/compare/v0.1.4...v0.1.5
|
|
688
713
|
[0.1.4]: https://github.com/sferik/duel-ruby/compare/v0.1.3...v0.1.4
|
data/docs/ci.md
CHANGED
|
@@ -584,16 +584,19 @@ your README can show it:
|
|
|
584
584
|
```
|
|
585
585
|
|
|
586
586
|
The badge says "perf guarded", in green, when Duel passed the push. It
|
|
587
|
-
says "perf regressed", in red, when
|
|
587
|
+
says "perf regressed", in red, when Duel failed the push or found a
|
|
588
588
|
regression, even one that passed, with
|
|
589
589
|
[`c.fail_on = :pull_requests`](#comment-on-a-pushed-commit), or that a
|
|
590
|
-
label accepted.
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
590
|
+
label accepted. It says "not measured", in grey, when the Duel job
|
|
591
|
+
failed before Duel could judge the push, as when its runner ran out of
|
|
592
|
+
memory or a step before Duel's failed. A job that fails after Duel
|
|
593
|
+
passed the push leaves it green. A push with nothing to compare leaves
|
|
594
|
+
the badge as it was, and so does a run that finishes after a newer
|
|
595
|
+
push's, so the badge is always the newest push's that Duel compared.
|
|
596
|
+
The branch holds one commit, with the badge alone, whose message names
|
|
597
|
+
that push. The job checks nothing out, and it gets the `contents: write`
|
|
598
|
+
permission that moving a branch takes. For a project in a subdirectory
|
|
599
|
+
of its repository, the branch names the directory, such as
|
|
597
600
|
`duel/badge-gems-parser`.
|
|
598
601
|
|
|
599
602
|
Until the first push to your default branch after you add the job, the
|
|
@@ -607,13 +610,15 @@ keeps `.duel.rb`), or add the job yourself:
|
|
|
607
610
|
|
|
608
611
|
```yaml
|
|
609
612
|
# .github/workflows/perf.yml, in jobs: (with duel init --badge)
|
|
610
|
-
# Duel's badge, for the README: green (perf guarded)
|
|
611
|
-
# regressed), as the last push to the default
|
|
612
|
-
# left it. It's red where
|
|
613
|
-
# even one that passed (with
|
|
614
|
-
#
|
|
615
|
-
#
|
|
616
|
-
# to
|
|
613
|
+
# Duel's badge, for the README: green (perf guarded), red (perf
|
|
614
|
+
# regressed) or grey (not measured), as the last push to the default
|
|
615
|
+
# branch that Duel compared left it. It's red where Duel failed the push
|
|
616
|
+
# or found a regression, even one that passed (with
|
|
617
|
+
# c.fail_on = :pull_requests in .duel.rb), and grey where the Duel job
|
|
618
|
+
# failed before Duel could judge the push (its runner ran out of memory,
|
|
619
|
+
# say). A push with nothing to compare leaves it as it was, and so does
|
|
620
|
+
# a run for an older push than the badge's. This job writes the badge,
|
|
621
|
+
# alone, to a branch of its own, which the README shows:
|
|
617
622
|
#
|
|
618
623
|
# [](https://github.com/sferik/duel-ruby)
|
|
619
624
|
#
|
|
@@ -659,10 +664,13 @@ keeps `.duel.rb`), or add the job yourself:
|
|
|
659
664
|
last=$(gh api "repos/$GITHUB_REPOSITORY/commits/$BRANCH" --jq .commit.message 2>/dev/null | sed -n 's/^Duel.s badge, for \([0-9a-f]*\)$/\1/p') || true
|
|
660
665
|
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
661
666
|
# (Its image, written here rather than fetched from anywhere: green,
|
|
662
|
-
#
|
|
667
|
+
# red where Duel failed the push or found a regression, or grey
|
|
668
|
+
# where the Duel job failed before Duel said either.)
|
|
663
669
|
state="perf guarded" width=133 top="#34D058" bottom="#28A745" right="76.939C78.629 0 80 1.343 80"
|
|
664
|
-
if [ "$
|
|
670
|
+
if [ "$STATUS" = failed ]; then
|
|
665
671
|
state="perf regressed" width=142 top="#EA4A5A" bottom="#D73A49" right="85.939C87.629 0 89 1.343 89"
|
|
672
|
+
elif [ "$RESULT" = failure ] && [ "$STATUS" != passed ]; then
|
|
673
|
+
state="not measured" width=138 top="#959DA5" bottom="#6A737D" right="81.939C83.629 0 85 1.343 85"
|
|
666
674
|
fi
|
|
667
675
|
cat > "$RUNNER_TEMP/badge.svg" <<SVG
|
|
668
676
|
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="20">
|
data/docs/how-it-works.md
CHANGED
|
@@ -51,6 +51,20 @@ never on noise, so that it can gate every pull request:
|
|
|
51
51
|
independent already. It can also stop after any pair once the
|
|
52
52
|
interval shows that it isn't slower, which only ever ends a
|
|
53
53
|
measurement before it could find a slowdown.
|
|
54
|
+
|
|
55
|
+
Duel measures one benchmark at a time for every two CPUs
|
|
56
|
+
(`--jobs`), each with workers of its own, so a run can start many
|
|
57
|
+
workers, and each one's resources (a database server, say) with it.
|
|
58
|
+
Where they wouldn't fit in the memory available (Linux's
|
|
59
|
+
MemAvailable, or a container's cgroup limit, or macOS's free and
|
|
60
|
+
inactive pages), Duel measures fewer benchmarks at once, and where
|
|
61
|
+
even one benchmark's workers wouldn't fit, it starts fewer workers.
|
|
62
|
+
Running out would make the machine swap, or stop a CI runner from
|
|
63
|
+
answering, so its job is lost. To find what they take, Duel starts
|
|
64
|
+
one worker of each version first, and allows each pair a quarter
|
|
65
|
+
more than that, and 1 GB for everything else. Its first line says
|
|
66
|
+
when it lowered either. A `--jobs` or `--processes` you give is
|
|
67
|
+
kept as it is.
|
|
54
68
|
- **Measured again before failing.** Duel measures whatever looks
|
|
55
69
|
slower again from scratch, up to three times, in fresh processes. It
|
|
56
70
|
fails only if every measurement finds the same metric worse. A
|
data/docs/json.md
CHANGED
|
@@ -243,8 +243,8 @@ was slower across the board and confirmed (`"confirmed": true`).
|
|
|
243
243
|
| `confidence` | The confidence of each interval, such as `0.99`. |
|
|
244
244
|
| `limit` | The ratio above which a timing is slower (`--limit`). A metric can have its own limit, which its timings show. |
|
|
245
245
|
| `filter` | The regular expression that picked the benchmarks (`--filter`), as source. `""` matches every one. |
|
|
246
|
-
| `jobs` | Benchmarks measured at once (`--jobs`). |
|
|
247
|
-
| `processes` | Worker processes for each version (`--processes`). |
|
|
246
|
+
| `jobs` | Benchmarks measured at once (`--jobs`), or fewer, where that many wouldn't fit in the memory available. |
|
|
247
|
+
| `processes` | Worker processes for each version (`--processes`), or fewer, where even one benchmark's wouldn't fit in the memory available. |
|
|
248
248
|
| `timeout` | The seconds that a worker may take to load or to answer (`--timeout`). |
|
|
249
249
|
| `time_limit` | The seconds that a run measures for, at most (`--time-limit`). |
|
|
250
250
|
| `warm` | The seconds of warm-up for each benchmark (`--warm`), or `null` for the default: until steady, for up to as long as the Ruby takes. |
|
data/lib/duel/cli.rb
CHANGED
|
@@ -124,6 +124,7 @@ module Duel
|
|
|
124
124
|
def parse
|
|
125
125
|
settings = Settings.defaults
|
|
126
126
|
settings.jobs = [Etc.nprocessors / CPUS_PER_LANE, 1].max
|
|
127
|
+
settings.fit = %i[jobs processes]
|
|
127
128
|
parser(settings).parse!(env_options + @argv)
|
|
128
129
|
branch = variable("GITHUB_REF_NAME", "CI_COMMIT_BRANCH")
|
|
129
130
|
base = variable("DUEL_BASE")
|
|
@@ -459,8 +460,14 @@ module Duel
|
|
|
459
460
|
end
|
|
460
461
|
o.on("--candidate-dir DIR", "Candidate tree (default: this one)") { |v| settings.candidate_dir = v }
|
|
461
462
|
o.on("--filter REGEXP", "Only benchmarks whose names match") { |v| settings.filter = CLI.regexp(v) }
|
|
462
|
-
o.on("--jobs N", Integer, "Benchmarks measured at once (default: one for every #{CPUS_PER_LANE} CPUs)")
|
|
463
|
-
|
|
463
|
+
o.on("--jobs N", Integer, "Benchmarks measured at once (default: one for every #{CPUS_PER_LANE} CPUs, as many as fit in memory)") do |v|
|
|
464
|
+
settings.jobs = v
|
|
465
|
+
settings.fit -= [:jobs]
|
|
466
|
+
end
|
|
467
|
+
o.on("--processes N", Integer, "Worker processes per version (default: #{PROCESSES}, as many as fit in memory)") do |v|
|
|
468
|
+
settings.processes = v
|
|
469
|
+
settings.fit -= [:processes]
|
|
470
|
+
end
|
|
464
471
|
o.on("--timeout SECONDS", Float, "Most a worker may take to load or answer (default: #{TIMEOUT.round})") { |v| settings.timeout = v }
|
|
465
472
|
o.on("--time-limit SECONDS", Float, "Most a run measures for, then fails what's unmeasured or looks worse (default: 7200)") do |v|
|
|
466
473
|
settings.time_limit = v
|
data/lib/duel/memory.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Duel
|
|
4
|
+
# The memory a run's workers can take (see Runner#fit): what the
|
|
5
|
+
# machine has available, or what its cgroup's limit leaves, if that's
|
|
6
|
+
# less (a container's, say).
|
|
7
|
+
# @api private
|
|
8
|
+
module Memory
|
|
9
|
+
# The kinds of pages macOS's vm_stat counts that a process can have
|
|
10
|
+
# without the system swapping: free, and cached but unused.
|
|
11
|
+
MAC_PAGES = %w[free inactive speculative].freeze
|
|
12
|
+
|
|
13
|
+
# Where Linux's proc and sys are.
|
|
14
|
+
ROOT = "/"
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
# The bytes available, or nil where Duel can't tell: Linux's
|
|
18
|
+
# MemAvailable (in +root+'s proc/meminfo), at most what the cgroup
|
|
19
|
+
# mounted at sys/fs/cgroup leaves, or else macOS's free and
|
|
20
|
+
# inactive pages (in what +vm_stat+ prints).
|
|
21
|
+
def available(root: ROOT, vm_stat: -> { command("vm_stat") }) = linux(root) || mac(vm_stat.call)
|
|
22
|
+
|
|
23
|
+
# MemAvailable, at most what the cgroup leaves, or nil.
|
|
24
|
+
def linux(root)
|
|
25
|
+
kb = read(File.join(root, "proc", "meminfo"))&.[](/^MemAvailable:\s+(\d+) kB$/, 1) or return
|
|
26
|
+
[Integer(kb) * 1024, cgroup(File.join(root, "sys", "fs", "cgroup"))].compact.min
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# What a cgroup (v2) at +dir+ leaves of its limit, or nil where it
|
|
30
|
+
# has none ("max").
|
|
31
|
+
def cgroup(dir)
|
|
32
|
+
max, current = %w[memory.max memory.current].map { |file| Integer(read(File.join(dir, file)), exception: false) }
|
|
33
|
+
max - current if max && current
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The bytes in the pages of MAC_PAGES that vm_stat's +output+
|
|
37
|
+
# counts, or nil.
|
|
38
|
+
def mac(output)
|
|
39
|
+
page = output&.[](/page size of (\d+) bytes/, 1) or return
|
|
40
|
+
MAC_PAGES.sum { |kind| Integer(output[/^Pages #{kind}:\s+(\d+)\./, 1] || 0) } * Integer(page)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# A file's contents, or nil where there's none.
|
|
44
|
+
def read(path) = (File.read(path) if File.file?(path))
|
|
45
|
+
|
|
46
|
+
# What a command prints, or nil where there's no such command.
|
|
47
|
+
def command(*args)
|
|
48
|
+
IO.popen(args, err: File::NULL, &:read)
|
|
49
|
+
rescue SystemCallError
|
|
50
|
+
nil
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/duel/runner.rb
CHANGED
|
@@ -12,6 +12,7 @@ require_relative "message"
|
|
|
12
12
|
require_relative "resource"
|
|
13
13
|
require_relative "rubies"
|
|
14
14
|
require_relative "process_sample"
|
|
15
|
+
require_relative "memory"
|
|
15
16
|
|
|
16
17
|
module Duel
|
|
17
18
|
# The most seconds each benchmark runs before it's measured, unless
|
|
@@ -59,11 +60,14 @@ module Duel
|
|
|
59
60
|
|
|
60
61
|
# How a run is set up (see Duel::CLI for where each comes from).
|
|
61
62
|
# @api private
|
|
63
|
+
# Of +jobs+ and +processes+, +fit+ names those Duel may lower to fit
|
|
64
|
+
# the memory available (see Runner#fit): the defaults, but not what
|
|
65
|
+
# an option set.
|
|
62
66
|
Settings = Struct.new(:base, :base_dir, :candidate_dir, :filter, :jobs, :processes, :limit, :confidence, :warm, :force,
|
|
63
|
-
:config_path, :timeout, :ruby, :comment, :fail_on, :pushed, :target, :time_limit, :accepted) do
|
|
67
|
+
:config_path, :timeout, :ruby, :comment, :fail_on, :pushed, :target, :time_limit, :accepted, :fit) do
|
|
64
68
|
# @type self: singleton(Settings)
|
|
65
69
|
def self.defaults = new(filter: //, jobs: 1, processes: PROCESSES, limit: 1.02, confidence: 0.99, warm: nil, force: false,
|
|
66
|
-
timeout: TIMEOUT, time_limit: TIME_LIMIT)
|
|
70
|
+
timeout: TIMEOUT, time_limit: TIME_LIMIT, fit: [])
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
# One version as a run has it (see Runner#prepare), +name+d "baseline"
|
|
@@ -1222,6 +1226,7 @@ module Duel
|
|
|
1222
1226
|
# What #run does, with its versions prepared in its directory.
|
|
1223
1227
|
def compare_all(started)
|
|
1224
1228
|
@sides = prepare
|
|
1229
|
+
fit
|
|
1225
1230
|
names, results = with_lanes do |lanes|
|
|
1226
1231
|
found = lanes.first.benchmarks.keys.grep(@settings.filter)
|
|
1227
1232
|
@benchmarks = lanes.first.benchmarks
|
|
@@ -1277,6 +1282,47 @@ module Duel
|
|
|
1277
1282
|
end
|
|
1278
1283
|
end
|
|
1279
1284
|
|
|
1285
|
+
# The memory Runner#fit leaves for everything but the workers and
|
|
1286
|
+
# their resources: the runner, the system, and other processes.
|
|
1287
|
+
RESERVE = 1 << 30
|
|
1288
|
+
|
|
1289
|
+
# How much more than what it took to start a pair of workers takes
|
|
1290
|
+
# while it measures (its heap grows, and so do its resources'), by
|
|
1291
|
+
# Runner#fit's reckoning.
|
|
1292
|
+
HEADROOM = 1.25
|
|
1293
|
+
|
|
1294
|
+
# Lowers Settings#jobs, and then Settings#processes, as far as
|
|
1295
|
+
# Settings#fit lets it, where their workers (and each one's
|
|
1296
|
+
# resources, a database server, say) wouldn't fit in the memory
|
|
1297
|
+
# available: more than that and the machine swaps, or a CI runner
|
|
1298
|
+
# stops answering and its job is lost. What one worker of each
|
|
1299
|
+
# version takes is found by starting them (a lane of them), and every
|
|
1300
|
+
# pair is taken to need that, HEADROOM over.
|
|
1301
|
+
def fit
|
|
1302
|
+
return if @settings.fit.empty?
|
|
1303
|
+
|
|
1304
|
+
available = Memory.available or return
|
|
1305
|
+
taken = Lane.open(@config, @settings, @sides, processes: 1) { available - (Memory.available || available) }
|
|
1306
|
+
return unless taken.positive?
|
|
1307
|
+
|
|
1308
|
+
pair = (taken * HEADROOM).ceil
|
|
1309
|
+
pairs = [(available - RESERVE) / pair, 1].max
|
|
1310
|
+
processes = @settings.fit.include?(:processes) ? [@settings.processes, pairs].min : @settings.processes
|
|
1311
|
+
# (More jobs than the settings' are never taken: only fewer are.)
|
|
1312
|
+
jobs = @settings.fit.include?(:jobs) ? [pairs / processes, 1].max : @settings.jobs
|
|
1313
|
+
fewer = [("#{Runner.count(jobs, "benchmark")} at a time (not #{@settings.jobs})" if jobs < @settings.jobs),
|
|
1314
|
+
("#{Runner.count(processes, "worker")} of each version (not #{@settings.processes})" if processes < @settings.processes)].compact
|
|
1315
|
+
return if fewer.empty?
|
|
1316
|
+
|
|
1317
|
+
@out.puts "A worker of each version takes #{gigabytes(taken)} GB, with its resources, of #{gigabytes(available)} GB available, " \
|
|
1318
|
+
"so to fit: #{fewer.join(", and ")}"
|
|
1319
|
+
@settings.jobs = jobs
|
|
1320
|
+
@settings.processes = processes
|
|
1321
|
+
end
|
|
1322
|
+
|
|
1323
|
+
# +bytes+ in gigabytes, to a tenth.
|
|
1324
|
+
def gigabytes(bytes) = format("%.1f", bytes.fdiv(1 << 30))
|
|
1325
|
+
|
|
1280
1326
|
def with_lanes
|
|
1281
1327
|
# @type var lanes: Array[Lane]
|
|
1282
1328
|
lanes = []
|
|
@@ -306,13 +306,15 @@ jobs:
|
|
|
306
306
|
<% end -%>
|
|
307
307
|
<% if badge? -%>
|
|
308
308
|
|
|
309
|
-
# Duel's badge, for the README: green (perf guarded)
|
|
310
|
-
# regressed), as the last push to the default
|
|
311
|
-
# left it. It's red where
|
|
312
|
-
# even one that passed (with
|
|
313
|
-
#
|
|
314
|
-
#
|
|
315
|
-
# to
|
|
309
|
+
# Duel's badge, for the README: green (perf guarded), red (perf
|
|
310
|
+
# regressed) or grey (not measured), as the last push to the default
|
|
311
|
+
# branch that Duel compared left it. It's red where Duel failed the push
|
|
312
|
+
# or found a regression, even one that passed (with
|
|
313
|
+
# c.fail_on = :pull_requests in .duel.rb), and grey where the Duel job
|
|
314
|
+
# failed before Duel could judge the push (its runner ran out of memory,
|
|
315
|
+
# say). A push with nothing to compare leaves it as it was, and so does
|
|
316
|
+
# a run for an older push than the badge's. This job writes the badge,
|
|
317
|
+
# alone, to a branch of its own, which the README shows:
|
|
316
318
|
#
|
|
317
319
|
# [](https://github.com/sferik/duel-ruby)
|
|
318
320
|
#
|
|
@@ -358,10 +360,13 @@ jobs:
|
|
|
358
360
|
last=$(gh api "repos/$GITHUB_REPOSITORY/commits/$BRANCH" --jq .commit.message 2>/dev/null | sed -n 's/^Duel.s badge, for \([0-9a-f]*\)$/\1/p') || true
|
|
359
361
|
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
360
362
|
# (Its image, written here rather than fetched from anywhere: green,
|
|
361
|
-
#
|
|
363
|
+
# red where Duel failed the push or found a regression, or grey
|
|
364
|
+
# where the Duel job failed before Duel said either.)
|
|
362
365
|
state="perf guarded" width=133 top="#34D058" bottom="#28A745" right="76.939C78.629 0 80 1.343 80"
|
|
363
|
-
if [ "$
|
|
366
|
+
if [ "$STATUS" = failed ]; then
|
|
364
367
|
state="perf regressed" width=142 top="#EA4A5A" bottom="#D73A49" right="85.939C87.629 0 89 1.343 89"
|
|
368
|
+
elif [ "$RESULT" = failure ] && [ "$STATUS" != passed ]; then
|
|
369
|
+
state="not measured" width=138 top="#959DA5" bottom="#6A737D" right="81.939C83.629 0 85 1.343 85"
|
|
365
370
|
fi
|
|
366
371
|
cat > "$RUNNER_TEMP/badge.svg" <<SVG
|
|
367
372
|
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="20">
|
data/lib/duel/version.rb
CHANGED
data/sig/duel/memory.rbs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Duel
|
|
2
|
+
# The memory a run's workers can take: what the machine has available,
|
|
3
|
+
# or what its cgroup's limit leaves.
|
|
4
|
+
# @api private
|
|
5
|
+
module Memory
|
|
6
|
+
# The kinds of pages macOS's vm_stat counts as available.
|
|
7
|
+
MAC_PAGES: Array[String]
|
|
8
|
+
|
|
9
|
+
# Where Linux's proc and sys are.
|
|
10
|
+
ROOT: String
|
|
11
|
+
|
|
12
|
+
# The bytes available, or nil where Duel can't tell.
|
|
13
|
+
def self.available: (?root: String, ?vm_stat: ^() -> String?) -> Integer?
|
|
14
|
+
|
|
15
|
+
# MemAvailable, at most what the cgroup leaves, or nil.
|
|
16
|
+
def self.linux: (String root) -> Integer?
|
|
17
|
+
|
|
18
|
+
# What a cgroup (v2) at +dir+ leaves of its limit, or nil.
|
|
19
|
+
def self.cgroup: (String dir) -> Integer?
|
|
20
|
+
|
|
21
|
+
# The bytes in vm_stat's available pages, or nil.
|
|
22
|
+
def self.mac: (String? output) -> Integer?
|
|
23
|
+
|
|
24
|
+
# A file's contents, or nil.
|
|
25
|
+
def self.read: (String path) -> String?
|
|
26
|
+
|
|
27
|
+
# What a command prints, or nil.
|
|
28
|
+
def self.command: (*String args) -> String?
|
|
29
|
+
end
|
|
30
|
+
end
|
data/sig/duel/runner.rbs
CHANGED
|
@@ -66,17 +66,20 @@ module Duel
|
|
|
66
66
|
# a pull request with Config#accept_label (DUEL_ACCEPTED): see
|
|
67
67
|
# Baseline#last_release.
|
|
68
68
|
attr_accessor accepted: String?
|
|
69
|
+
# Of jobs and processes, those Duel may lower to fit the memory
|
|
70
|
+
# available (see Runner#fit).
|
|
71
|
+
attr_accessor fit: Array[:jobs | :processes]
|
|
69
72
|
|
|
70
73
|
def self.new: (?String? base, ?String? base_dir, ?String? candidate_dir, ?Regexp filter, ?Integer jobs,
|
|
71
74
|
?Integer processes, ?Float limit, ?Float confidence, ?Float? warm, ?bool force, ?String? config_path,
|
|
72
75
|
?Float timeout, ?Config::ruby ruby, ?Config::comment? comment,
|
|
73
76
|
?Config::fail_on? fail_on, ?String? pushed,
|
|
74
|
-
?String? target, ?Float time_limit, ?String? accepted) -> instance
|
|
77
|
+
?String? target, ?Float time_limit, ?String? accepted, ?Array[:jobs | :processes] fit) -> instance
|
|
75
78
|
| (?base: String?, ?base_dir: String?, ?candidate_dir: String?, ?filter: Regexp, ?jobs: Integer,
|
|
76
79
|
?processes: Integer, ?limit: Float, ?confidence: Float, ?warm: Float?, ?force: bool,
|
|
77
80
|
?config_path: String?, ?timeout: Float, ?ruby: Config::ruby, ?comment: Config::comment?,
|
|
78
81
|
?fail_on: Config::fail_on?, ?pushed: String?,
|
|
79
|
-
?target: String?, ?time_limit: Float, ?accepted: String?) -> instance
|
|
82
|
+
?target: String?, ?time_limit: Float, ?accepted: String?, ?fit: Array[:jobs | :processes]) -> instance
|
|
80
83
|
|
|
81
84
|
def self.defaults: () -> Settings
|
|
82
85
|
end
|
|
@@ -647,6 +650,20 @@ module Duel
|
|
|
647
650
|
# The most workers of each version #interval_over looks at.
|
|
648
651
|
PROCESSES_CHECKED: Integer
|
|
649
652
|
|
|
653
|
+
# The memory #fit leaves for everything but the workers.
|
|
654
|
+
RESERVE: Integer
|
|
655
|
+
|
|
656
|
+
# How much more than starting them a pair of workers takes, by #fit's
|
|
657
|
+
# reckoning.
|
|
658
|
+
HEADROOM: Float
|
|
659
|
+
|
|
660
|
+
# Lowers the jobs, then the processes, that Settings#fit lets it, to
|
|
661
|
+
# fit the memory available.
|
|
662
|
+
def fit: () -> void
|
|
663
|
+
|
|
664
|
+
# +bytes+ in gigabytes, to a tenth.
|
|
665
|
+
def gigabytes: (Integer bytes) -> String
|
|
666
|
+
|
|
650
667
|
def with_lanes: [T] () { (Array[Lane] lanes) -> T } -> T
|
|
651
668
|
|
|
652
669
|
def judge_across: (Array[Result] results, Array[String] names) -> Hash[String, Across::verdict]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
@@ -57,6 +57,7 @@ files:
|
|
|
57
57
|
- lib/duel/init.rb
|
|
58
58
|
- lib/duel/json_report.rb
|
|
59
59
|
- lib/duel/lock.rb
|
|
60
|
+
- lib/duel/memory.rb
|
|
60
61
|
- lib/duel/message.rb
|
|
61
62
|
- lib/duel/metric.rb
|
|
62
63
|
- lib/duel/native.rb
|
|
@@ -85,6 +86,7 @@ files:
|
|
|
85
86
|
- sig/duel/init.rbs
|
|
86
87
|
- sig/duel/json_report.rbs
|
|
87
88
|
- sig/duel/lock.rbs
|
|
89
|
+
- sig/duel/memory.rbs
|
|
88
90
|
- sig/duel/message.rbs
|
|
89
91
|
- sig/duel/metric.rbs
|
|
90
92
|
- sig/duel/native.rbs
|