duel 0.1.2 → 0.1.4
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 +108 -1
- data/README.md +22 -5
- data/docs/benchmarks.md +2 -1
- data/docs/ci.md +150 -12
- data/docs/configuration.md +11 -4
- data/docs/how-it-works.md +32 -4
- data/docs/json.md +2 -0
- data/docs/plugins.md +2 -2
- data/docs/troubleshooting.md +28 -0
- data/lib/duel/baseline.rb +4 -4
- data/lib/duel/cli.rb +4 -1
- data/lib/duel/config.rb +13 -6
- data/lib/duel/context.rb +7 -6
- data/lib/duel/init.rb +4 -0
- data/lib/duel/json_report.rb +4 -3
- data/lib/duel/lock.rb +52 -8
- data/lib/duel/message.rb +25 -0
- data/lib/duel/native.rb +57 -10
- data/lib/duel/resource.rb +37 -2
- data/lib/duel/runner.rb +115 -17
- data/lib/duel/summary.rb +4 -1
- data/lib/duel/templates/duel.gitlab-ci.yml.erb +23 -4
- data/lib/duel/templates/perf.yml.erb +86 -3
- data/lib/duel/testing.rb +2 -2
- data/lib/duel/version.rb +1 -1
- data/lib/duel/worker.rb +34 -14
- data/sig/duel/config.rbs +3 -0
- data/sig/duel/init.rbs +3 -0
- data/sig/duel/lock.rbs +11 -0
- data/sig/duel/message.rbs +11 -0
- data/sig/duel/native.rbs +13 -3
- data/sig/duel/resource.rbs +10 -1
- data/sig/duel/runner.rbs +41 -2
- data/sig/duel/summary.rbs +3 -0
- data/sig/duel/worker.rbs +11 -3
- metadata +4 -2
data/lib/duel/summary.rb
CHANGED
|
@@ -116,7 +116,7 @@ module Duel
|
|
|
116
116
|
|
|
117
117
|
# The Markdown, with the first +explained+ regressions explained.
|
|
118
118
|
def render(explained)
|
|
119
|
-
[heading, @note, compared, failures, across(confirmed: true), details(explained)].compact.join("\n\n") + "\n"
|
|
119
|
+
[heading, @note, compared, cut_short, failures, across(confirmed: true), details(explained)].compact.join("\n\n") + "\n"
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# The verdict: what failed (benchmarks, or a metric across the board),
|
|
@@ -143,6 +143,9 @@ module Duel
|
|
|
143
143
|
"Compared #{@candidate} with #{@baseline}.#{why}"
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
+
# What the run left undone at its time limit, if it reached it.
|
|
147
|
+
def cut_short = @runner.cut_short_note&.then { |note| "Time limit: #{note}." }
|
|
148
|
+
|
|
146
149
|
# The benchmarks that failed: what got worse and by how much, or the
|
|
147
150
|
# error, and where the most extra CPU went, if a profile says.
|
|
148
151
|
def failures
|
|
@@ -126,8 +126,9 @@
|
|
|
126
126
|
# With c.push_base = :last_passed in .duel.rb, a push is compared with the
|
|
127
127
|
# last commit Duel passed, which a branch marks (<%= passed_branch %>/main for
|
|
128
128
|
# main), so slowdowns too small for any one push to fail add up until they
|
|
129
|
-
# fail one. This job moves the branch to a push that passed (or makes it)
|
|
130
|
-
#
|
|
129
|
+
# fail one. This job moves the branch to a push that passed (or makes it),
|
|
130
|
+
# but never back: where a newer push's job moved it first, it stays. To
|
|
131
|
+
# accept a regression, move the branch yourself (for main, git push
|
|
131
132
|
# origin main:<%= passed_branch %>/main).
|
|
132
133
|
<%= gitlab_job %>:passed:
|
|
133
134
|
image: alpine:3
|
|
@@ -138,11 +139,29 @@
|
|
|
138
139
|
variables:
|
|
139
140
|
GIT_STRATEGY: none # it runs none of the code
|
|
140
141
|
script:
|
|
141
|
-
- apk add --no-cache --quiet curl
|
|
142
|
+
- apk add --no-cache --quiet curl jq
|
|
142
143
|
- |
|
|
143
144
|
[ "$DUEL_PASSED" = true ] || exit 0
|
|
144
145
|
api="$CI_API_V4_URL/projects/$CI_PROJECT_ID"
|
|
145
146
|
token="PRIVATE-TOKEN: $DUEL_TOKEN"
|
|
146
147
|
branch="<%= passed_branch %>/$CI_COMMIT_BRANCH"
|
|
148
|
+
at=$(curl -sf -H "$token" "$api/repository/branches/$(echo "$branch" | sed 's|/|%2F|g')" | jq -r '.commit.id // empty') || at=
|
|
149
|
+
if [ -n "$at" ]; then
|
|
150
|
+
base=$(curl -sf -H "$token" "$api/repository/merge_base?refs%5B%5D=$CI_COMMIT_SHA&refs%5B%5D=$at" | jq -r '.id // empty') || base=
|
|
151
|
+
[ -n "$base" ] || { echo "Couldn't compare $branch with this push" && exit 1; }
|
|
152
|
+
# (A newer push's job moved it, or this one's did, run again.)
|
|
153
|
+
[ "$base" = "$CI_COMMIT_SHA" ] && exit 0
|
|
154
|
+
fi
|
|
147
155
|
curl -s -o /dev/null -H "$token" -X DELETE "$api/repository/branches/$(echo "$branch" | sed 's|/|%2F|g')"
|
|
148
|
-
curl -sf -o /dev/null -H "$token" --data-urlencode "branch=$branch" --data-urlencode "ref=$CI_COMMIT_SHA" "$api/repository/branches"
|
|
156
|
+
curl -sf -o /dev/null -H "$token" --data-urlencode "branch=$branch" --data-urlencode "ref=$CI_COMMIT_SHA" "$api/repository/branches" && exit 0
|
|
157
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
158
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
159
|
+
# this names it.)
|
|
160
|
+
prefix=$branch
|
|
161
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
162
|
+
prefix=${prefix%/*}
|
|
163
|
+
if curl -sf -o /dev/null -H "$token" "$api/repository/branches/$(echo "$prefix" | sed 's|/|%2F|g')"; then
|
|
164
|
+
echo "The branch $prefix keeps Duel from making $branch, as Git can't have both. Delete it (git push origin --delete $prefix), or rename it."
|
|
165
|
+
fi
|
|
166
|
+
done
|
|
167
|
+
exit 1
|
|
@@ -214,7 +214,8 @@ jobs:
|
|
|
214
214
|
# the last commit Duel passed, which a branch marks (each branch pushed
|
|
215
215
|
# has its own), so slowdowns too small for any one push to fail add up
|
|
216
216
|
# until they fail one. This job moves the branch to a push that passed
|
|
217
|
-
# (or makes it)
|
|
217
|
+
# (or makes it), but never back: where a newer push's run moved it
|
|
218
|
+
# first, it stays. It checks nothing out and runs none of the code. To
|
|
218
219
|
# accept a regression, move the branch yourself (for main, git push
|
|
219
220
|
# origin main:<%= passed_branch %>/main).
|
|
220
221
|
passed:
|
|
@@ -230,5 +231,87 @@ jobs:
|
|
|
230
231
|
GH_TOKEN: ${{ github.token }}
|
|
231
232
|
BRANCH: <%= passed_branch %>/${{ github.ref_name }}
|
|
232
233
|
run: |
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
235
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
236
|
+
# this names it.)
|
|
237
|
+
blocked() {
|
|
238
|
+
prefix=$BRANCH
|
|
239
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
240
|
+
prefix=${prefix%/*}
|
|
241
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
242
|
+
echo "::error::The branch $prefix keeps Duel from making $BRANCH, as Git can't have both. Delete it (git push origin --delete $prefix), or rename it."
|
|
243
|
+
fi
|
|
244
|
+
done
|
|
245
|
+
exit 1
|
|
246
|
+
}
|
|
247
|
+
# (Forward: GitHub moves it only where it's behind the push.)
|
|
248
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
|
|
249
|
+
at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
|
|
250
|
+
if [ -z "$at" ]; then
|
|
251
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null || blocked
|
|
252
|
+
exit 0
|
|
253
|
+
fi
|
|
254
|
+
compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status 2>&1) || case "$compared" in
|
|
255
|
+
# (GitHub can't compare commits with no history in common.)
|
|
256
|
+
*"No common ancestor"*) compared=unrelated ;;
|
|
257
|
+
esac
|
|
258
|
+
case "$compared" in
|
|
259
|
+
# (A newer push's run moved it, or this one's did, run again.)
|
|
260
|
+
ahead | identical) ;;
|
|
261
|
+
# (History rewritten, a force push's, say, or replaced: moved anyway.)
|
|
262
|
+
diverged | behind | unrelated) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
|
|
263
|
+
*) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
|
|
264
|
+
esac
|
|
265
|
+
|
|
266
|
+
# Duel's badge, for the README: green (perf guarded) or red (perf
|
|
267
|
+
# regressed), as the last push to the default branch that Duel compared
|
|
268
|
+
# left it. It's red where the Duel job failed or found a regression,
|
|
269
|
+
# even one that passed (with c.fail_on = :pull_requests in .duel.rb). A
|
|
270
|
+
# push with nothing to compare leaves it as it was, and so does a run
|
|
271
|
+
# for an older push than the badge's. This job writes the badge, alone,
|
|
272
|
+
# to a branch of its own, which the README shows:
|
|
273
|
+
#
|
|
274
|
+
# [](https://github.com/sferik/duel-ruby)
|
|
275
|
+
#
|
|
276
|
+
# It checks nothing out and runs none of the code.
|
|
277
|
+
badge:
|
|
278
|
+
name: Update the badge
|
|
279
|
+
needs: duel
|
|
280
|
+
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == github.event.repository.default_branch && (needs.duel.result == 'failure' || needs.duel.outputs.status == 'passed' || needs.duel.outputs.status == 'failed') }}
|
|
281
|
+
runs-on: ubuntu-latest
|
|
282
|
+
permissions:
|
|
283
|
+
contents: write # to move the badge's branch
|
|
284
|
+
steps:
|
|
285
|
+
- name: Update the badge
|
|
286
|
+
env:
|
|
287
|
+
GH_TOKEN: ${{ github.token }}
|
|
288
|
+
BRANCH: <%= badge_branch %>
|
|
289
|
+
RESULT: ${{ needs.duel.result }}
|
|
290
|
+
STATUS: ${{ needs.duel.outputs.status }}
|
|
291
|
+
BADGES: https://raw.githubusercontent.com/sferik/duel-ruby/main/assets
|
|
292
|
+
run: |
|
|
293
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
294
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
295
|
+
# this names it.)
|
|
296
|
+
blocked() {
|
|
297
|
+
prefix=$BRANCH
|
|
298
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
299
|
+
prefix=${prefix%/*}
|
|
300
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
301
|
+
echo "::error::The branch $prefix keeps Duel from making $BRANCH, as Git can't have both. Delete it (git push origin --delete $prefix), or rename it."
|
|
302
|
+
fi
|
|
303
|
+
done
|
|
304
|
+
exit 1
|
|
305
|
+
}
|
|
306
|
+
# (Where the badge is a newer push's, that push's run has the say.
|
|
307
|
+
# Its commit names the push.)
|
|
308
|
+
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
|
|
309
|
+
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
310
|
+
badge="badge.svg"
|
|
311
|
+
if [ "$RESULT" = failure ] || [ "$STATUS" = failed ]; then badge="badge-regressed.svg"; fi
|
|
312
|
+
curl -fsSL "$BADGES/$badge" -o "$RUNNER_TEMP/badge.svg"
|
|
313
|
+
tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
|
|
314
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
|
|
315
|
+
commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
|
|
316
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
|
|
317
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
|
data/lib/duel/testing.rb
CHANGED
|
@@ -49,11 +49,11 @@ module Duel
|
|
|
49
49
|
|
|
50
50
|
# Runs +config+'s prepare blocks as they'd prepare a worker (+name+,
|
|
51
51
|
# running the version at +root+): its version's (Config#prepare
|
|
52
|
-
# (:version), named for the version: "
|
|
52
|
+
# (:version), named for the version: "head"), then the worker's,
|
|
53
53
|
# with their builds (Resource#cached) in +cache+ (by default, one for
|
|
54
54
|
# every test of this process). Sets the environment they give while
|
|
55
55
|
# the block runs, yields it, and stops what they started after.
|
|
56
|
-
def prepare(config, name: "
|
|
56
|
+
def prepare(config, name: "head-1", root: config.root, cache: CACHE)
|
|
57
57
|
dir = Lane.tmpdir
|
|
58
58
|
started = [] #: Array[Resource]
|
|
59
59
|
begin
|
data/lib/duel/version.rb
CHANGED
data/lib/duel/worker.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "json"
|
|
4
3
|
require "rbconfig"
|
|
5
4
|
require "socket"
|
|
6
5
|
require_relative "../duel"
|
|
7
6
|
require_relative "context"
|
|
7
|
+
require_relative "message"
|
|
8
8
|
require_relative "profile"
|
|
9
9
|
|
|
10
10
|
module Duel
|
|
@@ -13,8 +13,8 @@ module Duel
|
|
|
13
13
|
# WorkerProcess) with Worker.main(VERSION_ROOT, CANDIDATE_ROOT, CONTROL
|
|
14
14
|
# [, CONFIG]), it gives its main object the DSL, loads the benchmarks,
|
|
15
15
|
# connects to the runner's Unix socket at CONTROL, sends what it has
|
|
16
|
-
# (see #hello), and answers
|
|
17
|
-
#
|
|
16
|
+
# (see #hello), and answers each request with a reply (see Message).
|
|
17
|
+
# (Not over stdin: a JRuby started by JRuby sees its stdin pipe
|
|
18
18
|
# closed.)
|
|
19
19
|
# @api private
|
|
20
20
|
class Worker
|
|
@@ -25,6 +25,9 @@ module Duel
|
|
|
25
25
|
|
|
26
26
|
def self.main(version_root, candidate_root, control, config_path = nil)
|
|
27
27
|
config = config_path ? Duel.load_config(config_path) : (Duel.config = Config.new(candidate_root))
|
|
28
|
+
# (What was loaded before the version, which loading it may take off
|
|
29
|
+
# $LOADED_FEATURES, to load its own over: see Worker.twice.)
|
|
30
|
+
before = $LOADED_FEATURES.dup
|
|
28
31
|
config.load_into(File.expand_path(version_root))
|
|
29
32
|
TOPLEVEL_BINDING.receiver.extend(DSL)
|
|
30
33
|
config.benchmark_files.each { |file| load file }
|
|
@@ -34,11 +37,13 @@ module Duel
|
|
|
34
37
|
begin
|
|
35
38
|
# The benchmarks are the only work in this process: it starts tidy.
|
|
36
39
|
GC.start
|
|
37
|
-
worker = new(config.metrics, config.measures, hooks: config.hooks)
|
|
40
|
+
worker = new(config.metrics, config.measures, hooks: config.hooks, before: before)
|
|
38
41
|
begin
|
|
39
42
|
socket = UNIXSocket.new(control)
|
|
40
|
-
socket
|
|
41
|
-
|
|
43
|
+
Message.write(socket, worker.hello)
|
|
44
|
+
while (request = Message.read(socket))
|
|
45
|
+
Message.write(socket, worker.handle(request))
|
|
46
|
+
end
|
|
42
47
|
ensure
|
|
43
48
|
worker.close
|
|
44
49
|
end
|
|
@@ -49,8 +54,10 @@ module Duel
|
|
|
49
54
|
|
|
50
55
|
# Its metric instances: the plugins' outermost, then the built-in
|
|
51
56
|
# ones, CPU innermost (see Worker.made). +hooks+: the configuration's
|
|
52
|
-
# (see Harness).
|
|
53
|
-
|
|
57
|
+
# (see Harness). +before+: the features loaded before the version was
|
|
58
|
+
# (see Worker.main).
|
|
59
|
+
def initialize(plugin_metrics = [], measures = {}, hooks: NO_HOOKS, before: [])
|
|
60
|
+
@before = before
|
|
54
61
|
@metrics, @specs = Worker.made(plugin_metrics + BUILT_IN, measures)
|
|
55
62
|
@benchmarks = Duel.benchmarks
|
|
56
63
|
@hooks = hooks
|
|
@@ -87,8 +94,8 @@ module Duel
|
|
|
87
94
|
# peak memory and profiles can be measured here, and whether YJIT is on.
|
|
88
95
|
def hello
|
|
89
96
|
{"benchmarks" => @benchmarks.values.map(&:to_h), "metrics" => @specs, "ruby" => RUBY_DESCRIPTION,
|
|
90
|
-
"memory" => !Native::Memory.
|
|
91
|
-
"extensions" => Worker.extensions, "gem_dirs" => Worker.gem_dirs}
|
|
97
|
+
"memory" => !Native::Memory.used.nil?, "profiler" => Worker.profiler?, "yjit" => Worker.yjit?,
|
|
98
|
+
"extensions" => Worker.extensions, "twice" => Worker.twice(@before + $LOADED_FEATURES), "gem_dirs" => Worker.gem_dirs}
|
|
92
99
|
end
|
|
93
100
|
|
|
94
101
|
# The native extensions loaded (CRuby's and TruffleRuby's builds, and
|
|
@@ -96,13 +103,26 @@ module Duel
|
|
|
96
103
|
# from the directory on the load path it was found in (the deepest,
|
|
97
104
|
# of several), "my_gem/my_gem.bundle", say, or else its file's name.
|
|
98
105
|
# (For the runner to check each version loaded its own builds: see
|
|
106
|
+
# Lane#check_builds.) Of a feature loaded from more than one file, the
|
|
107
|
+
# last.
|
|
108
|
+
def self.extensions(features = $LOADED_FEATURES, load_path = $LOAD_PATH) = loaded(features, load_path).transform_values(&:last)
|
|
109
|
+
|
|
110
|
+
# The native extensions of +features+ loaded from more than one file,
|
|
111
|
+
# as {feature => real paths}, in the order they loaded. In a baseline
|
|
112
|
+
# worker, one of the candidate's that something required before the
|
|
113
|
+
# worker loaded the version (Duel's own json, in json's repository,
|
|
114
|
+
# say), and then the version's own: as an extension can't be
|
|
115
|
+
# unloaded, both stay loaded. (For the runner to fail: see
|
|
99
116
|
# Lane#check_builds.)
|
|
100
|
-
def self.
|
|
117
|
+
def self.twice(features, load_path = $LOAD_PATH) = loaded(features, load_path).select { |_, paths| paths.size > 1 }
|
|
118
|
+
|
|
119
|
+
# The native extensions loaded, as {feature => real paths}.
|
|
120
|
+
def self.loaded(features, load_path)
|
|
101
121
|
dirs = load_path.map { |dir| File.join(File.expand_path(dir), "") }
|
|
102
|
-
features.select { |feature| File.absolute_path?(feature) && feature.end_with?(".#{RbConfig::CONFIG.fetch("DLEXT")}") }.
|
|
122
|
+
features.select { |feature| File.absolute_path?(feature) && feature.end_with?(".#{RbConfig::CONFIG.fetch("DLEXT")}") }.group_by do |path|
|
|
103
123
|
dir = dirs.select { |prefix| path.start_with?(prefix) }.max_by(&:size)
|
|
104
|
-
|
|
105
|
-
end
|
|
124
|
+
dir ? path.delete_prefix(dir) : File.basename(path)
|
|
125
|
+
end.transform_values { |paths| paths.map { |path| File.realpath(path) }.uniq }
|
|
106
126
|
end
|
|
107
127
|
|
|
108
128
|
# The directories gems are installed in, Gem.path's that are there, as
|
data/sig/duel/config.rbs
CHANGED
|
@@ -42,6 +42,9 @@ module Duel
|
|
|
42
42
|
# Where the project is (and its config file).
|
|
43
43
|
attr_reader root: String
|
|
44
44
|
|
|
45
|
+
# Where Duel keeps what it keeps for the project: tmp/duel.
|
|
46
|
+
def state: () -> String
|
|
47
|
+
|
|
45
48
|
# A glob, from the root, of the files defining benchmarks.
|
|
46
49
|
attr_accessor benchmarks: String
|
|
47
50
|
|
data/sig/duel/init.rbs
CHANGED
|
@@ -104,6 +104,9 @@ module Duel
|
|
|
104
104
|
# The branch that marks the last commit Duel passed in a push.
|
|
105
105
|
def passed_branch: () -> String
|
|
106
106
|
|
|
107
|
+
# The branch that holds the workflow's badge.
|
|
108
|
+
def badge_branch: () -> String
|
|
109
|
+
|
|
107
110
|
# Where the GitLab CI jobs are, from the repository's root.
|
|
108
111
|
def gitlab_file: () -> String
|
|
109
112
|
|
data/sig/duel/lock.rbs
CHANGED
|
@@ -8,5 +8,16 @@ module Duel
|
|
|
8
8
|
# Runs the block holding +dir+'s lock. Fails, naming the run that
|
|
9
9
|
# holds it, if another does.
|
|
10
10
|
def self.hold: [T] (String dir) { () -> T } -> T
|
|
11
|
+
|
|
12
|
+
# The lock file at +path+, locked: the one there now.
|
|
13
|
+
def self.acquire: (String path, String dir) -> File
|
|
14
|
+
|
|
15
|
+
# The directories, +dir+ and those it's in, that aren't there yet,
|
|
16
|
+
# deepest first.
|
|
17
|
+
def self.missing: (String dir) -> Array[String]
|
|
18
|
+
|
|
19
|
+
# Removes the empty directories in +dir+, then +dir+, then those of
|
|
20
|
+
# +made+ that it's in, while they're empty.
|
|
21
|
+
def self.tidy: (String dir, Array[String] made) -> void
|
|
11
22
|
end
|
|
12
23
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Duel
|
|
2
|
+
# What the runner and a worker say to each other, marshaled.
|
|
3
|
+
# @api private
|
|
4
|
+
module Message
|
|
5
|
+
# Sends +message+ over +io+.
|
|
6
|
+
def self.write: (IO io, untyped message) -> Integer
|
|
7
|
+
|
|
8
|
+
# The next message over +io+, or nil once the other end has closed it.
|
|
9
|
+
def self.read: (IO io) -> untyped
|
|
10
|
+
end
|
|
11
|
+
end
|
data/sig/duel/native.rbs
CHANGED
|
@@ -15,6 +15,9 @@ module Duel
|
|
|
15
15
|
|
|
16
16
|
# A C function of the process's own libraries, by name, taking and
|
|
17
17
|
# returning Fiddle types (:INT, :LONG, :VOIDP...).
|
|
18
|
+
# Loads Fiddle, as the first C function is made.
|
|
19
|
+
def self.require_fiddle: () -> bool
|
|
20
|
+
|
|
18
21
|
def self.function: (String name, Array[Symbol] args, Symbol returns) -> _Function
|
|
19
22
|
|
|
20
23
|
# Instructions retired in user space, from the CPU's counters.
|
|
@@ -89,10 +92,17 @@ module Duel
|
|
|
89
92
|
|
|
90
93
|
# This process's resident memory in bytes, or nil where it can't tell.
|
|
91
94
|
module Memory
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
STATUS: String
|
|
96
|
+
self.@macos: MacOS?
|
|
97
|
+
|
|
98
|
+
# macOS's counter, opened as resident memory is first read, or nil.
|
|
99
|
+
def self.macos_counter: () -> MacOS?
|
|
100
|
+
|
|
101
|
+
def self.resident: (?status: String, ?macos: MacOS?) -> Integer?
|
|
102
|
+
|
|
103
|
+
def self.used: () -> Integer?
|
|
94
104
|
|
|
95
|
-
def self.
|
|
105
|
+
def self.collect: () -> void
|
|
96
106
|
end
|
|
97
107
|
end
|
|
98
108
|
end
|
data/sig/duel/resource.rbs
CHANGED
|
@@ -40,7 +40,16 @@ module Duel
|
|
|
40
40
|
# @api private
|
|
41
41
|
def self.environment: (String name, Hash[String, String?] env, Hash[String, String?] vars) -> Hash[String, String?]
|
|
42
42
|
|
|
43
|
-
# The worker it's for ("
|
|
43
|
+
# The worker it's for ("base-1", say).
|
|
44
|
+
# What a cache key names, without its version and hash.
|
|
45
|
+
NAME: Regexp
|
|
46
|
+
|
|
47
|
+
# The builds this process's runs used, by path.
|
|
48
|
+
USED: Set[String]
|
|
49
|
+
|
|
50
|
+
# Removes the builds that ones this process used replace.
|
|
51
|
+
def self.evict: (String cache) -> void
|
|
52
|
+
|
|
44
53
|
attr_reader name: String
|
|
45
54
|
|
|
46
55
|
# The directory it has of its own.
|
data/sig/duel/runner.rbs
CHANGED
|
@@ -16,6 +16,10 @@ module Duel
|
|
|
16
16
|
# @api private
|
|
17
17
|
YJIT_WARM: Float
|
|
18
18
|
|
|
19
|
+
# The seconds a run measures for, at most, by default.
|
|
20
|
+
# @api private
|
|
21
|
+
TIME_LIMIT: Float
|
|
22
|
+
|
|
19
23
|
# How a run is set up (see Duel::CLI for where each comes from).
|
|
20
24
|
# @api private
|
|
21
25
|
class Settings < Struct[String | Regexp | Integer | Float | bool | Config::ruby | Config::comment | Config::fail_on | nil]
|
|
@@ -31,6 +35,8 @@ module Duel
|
|
|
31
35
|
attr_accessor force: bool
|
|
32
36
|
attr_accessor config_path: String?
|
|
33
37
|
attr_accessor timeout: Float
|
|
38
|
+
# The seconds a run measures for, at most (--time-limit).
|
|
39
|
+
attr_accessor time_limit: Float
|
|
34
40
|
# Each version's Ruby (--ruby), over Config#ruby.
|
|
35
41
|
attr_accessor ruby: Config::ruby
|
|
36
42
|
# When the workflow comments on a pull request (--comment), over
|
|
@@ -49,12 +55,12 @@ module Duel
|
|
|
49
55
|
?Integer processes, ?Float limit, ?Float confidence, ?Float? warm, ?bool force, ?String? config_path,
|
|
50
56
|
?Float timeout, ?Config::ruby ruby, ?Config::comment? comment,
|
|
51
57
|
?Config::fail_on? fail_on, ?String? pushed,
|
|
52
|
-
?String? target) -> instance
|
|
58
|
+
?String? target, ?Float time_limit) -> instance
|
|
53
59
|
| (?base: String?, ?base_dir: String?, ?candidate_dir: String?, ?filter: Regexp, ?jobs: Integer,
|
|
54
60
|
?processes: Integer, ?limit: Float, ?confidence: Float, ?warm: Float?, ?force: bool,
|
|
55
61
|
?config_path: String?, ?timeout: Float, ?ruby: Config::ruby, ?comment: Config::comment?,
|
|
56
62
|
?fail_on: Config::fail_on?, ?pushed: String?,
|
|
57
|
-
?target: String?) -> instance
|
|
63
|
+
?target: String?, ?time_limit: Float) -> instance
|
|
58
64
|
|
|
59
65
|
def self.defaults: () -> Settings
|
|
60
66
|
end
|
|
@@ -68,10 +74,17 @@ module Duel
|
|
|
68
74
|
attr_accessor ruby: String
|
|
69
75
|
attr_accessor env: Hash[String, String?]
|
|
70
76
|
|
|
77
|
+
# What each version's workers are named for: "base" and "head", as
|
|
78
|
+
# long as each other.
|
|
79
|
+
LABELS: Hash[String, String]
|
|
80
|
+
|
|
71
81
|
def self.new: (String name, String root, String ruby, Hash[String, String?] env) -> instance
|
|
72
82
|
|
|
73
83
|
# Each version with nothing prepared: its tree, on the runner's Ruby.
|
|
74
84
|
def self.unprepared: (Config config, Settings settings, String base_root) -> Hash[String, Side]
|
|
85
|
+
|
|
86
|
+
# What its workers, and its version's resources, are named for.
|
|
87
|
+
def label: () -> String
|
|
75
88
|
end
|
|
76
89
|
|
|
77
90
|
# A worker process (Duel::Worker) running one version of the code.
|
|
@@ -95,6 +108,7 @@ module Duel
|
|
|
95
108
|
@runs: ProcessSample?
|
|
96
109
|
@description: String
|
|
97
110
|
@extensions: Hash[String, String]
|
|
111
|
+
@twice: Hash[String, Array[String]]
|
|
98
112
|
@gem_dirs: Array[String]
|
|
99
113
|
@pid: Integer
|
|
100
114
|
@socket: UNIXSocket
|
|
@@ -122,6 +136,9 @@ module Duel
|
|
|
122
136
|
# The native extensions it loaded, by feature.
|
|
123
137
|
attr_reader extensions: Hash[String, String]
|
|
124
138
|
|
|
139
|
+
# Those it loaded from more than one file, by feature.
|
|
140
|
+
attr_reader twice: Hash[String, Array[String]]
|
|
141
|
+
|
|
125
142
|
# The directories gems are installed in, as real paths ending in "/".
|
|
126
143
|
attr_reader gem_dirs: Array[String]
|
|
127
144
|
|
|
@@ -476,6 +493,14 @@ module Duel
|
|
|
476
493
|
|
|
477
494
|
@rubies: Hash[String, String]
|
|
478
495
|
@seconds: Float
|
|
496
|
+
@lock: Thread::Mutex
|
|
497
|
+
@started: Float
|
|
498
|
+
@unmeasured: Array[String]
|
|
499
|
+
@unconfirmed: Array[String]
|
|
500
|
+
@across_cut: bool
|
|
501
|
+
|
|
502
|
+
# What a run cut short at its time limit left undone.
|
|
503
|
+
type cut_short = Hash[String, Array[String] | bool]
|
|
479
504
|
|
|
480
505
|
# Across the board: {metric => verdict}. Set by #run.
|
|
481
506
|
attr_reader across: Hash[String, Across::verdict]
|
|
@@ -486,6 +511,9 @@ module Duel
|
|
|
486
511
|
# The seconds the run took. Set by #run.
|
|
487
512
|
attr_reader seconds: Float
|
|
488
513
|
|
|
514
|
+
# What the run left undone when it reached its time limit, or nil.
|
|
515
|
+
def cut_short: () -> cut_short?
|
|
516
|
+
|
|
489
517
|
def initialize: (Config config, Settings settings, String base_root, ?out: _Output) -> void
|
|
490
518
|
|
|
491
519
|
# Returns the Results.
|
|
@@ -496,6 +524,12 @@ module Duel
|
|
|
496
524
|
|
|
497
525
|
def regressed_across: () -> Array[String]
|
|
498
526
|
|
|
527
|
+
# What a run cut short at its time limit left undone, or nil.
|
|
528
|
+
def cut_short_note: () -> String?
|
|
529
|
+
|
|
530
|
+
# Whether the run has measured for longer than its time limit.
|
|
531
|
+
def out_of_time?: () -> bool
|
|
532
|
+
|
|
499
533
|
# The plugins the configuration used, by name.
|
|
500
534
|
def plugins: () -> Array[Symbol]
|
|
501
535
|
|
|
@@ -520,6 +554,11 @@ module Duel
|
|
|
520
554
|
|
|
521
555
|
def attempt: (Lane lane, String name) -> Result
|
|
522
556
|
|
|
557
|
+
# A benchmark the run reached its time limit before it measured.
|
|
558
|
+
def unmeasured: (String name) -> Result
|
|
559
|
+
|
|
560
|
+
def limit_text: () -> String
|
|
561
|
+
|
|
523
562
|
def confirm: (Array[Result] suspects) -> void
|
|
524
563
|
|
|
525
564
|
def profile: (Array[Result] regressed) -> void
|
data/sig/duel/summary.rbs
CHANGED
|
@@ -70,6 +70,9 @@ module Duel
|
|
|
70
70
|
def compared: () -> String
|
|
71
71
|
|
|
72
72
|
# The benchmarks that failed.
|
|
73
|
+
# What the run left undone at its time limit, if it reached it.
|
|
74
|
+
def cut_short: () -> String?
|
|
75
|
+
|
|
73
76
|
def failures: () -> String?
|
|
74
77
|
|
|
75
78
|
# What got worse, or the error's first line.
|
data/sig/duel/worker.rbs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Duel
|
|
2
2
|
# A worker process: loads one version of the code and the candidate's
|
|
3
|
-
# benchmarks, and answers the runner's requests
|
|
3
|
+
# benchmarks, and answers the runner's requests (see Message).
|
|
4
4
|
# @api private
|
|
5
5
|
class Worker
|
|
6
6
|
type hello = { "benchmarks" => Array[Definition::summary], "metrics" => Array[Metric::spec], "ruby" => String,
|
|
7
7
|
"memory" => bool, "profiler" => bool, "yjit" => bool, "extensions" => Hash[String, String],
|
|
8
|
-
"gem_dirs" => Array[String] }
|
|
8
|
+
"twice" => Hash[String, Array[String]], "gem_dirs" => Array[String] }
|
|
9
9
|
|
|
10
10
|
type ok = { "ok" => true }
|
|
11
11
|
|
|
@@ -24,6 +24,7 @@ module Duel
|
|
|
24
24
|
@specs: Array[Metric::spec]
|
|
25
25
|
@benchmarks: Hash[String, Definition]
|
|
26
26
|
@hooks: Hash[Symbol, Array[hook]]
|
|
27
|
+
@before: Array[String]
|
|
27
28
|
@harnesses: Hash[String, Harness]
|
|
28
29
|
|
|
29
30
|
def self.main: (String version_root, String candidate_root, String control, ?String? config_path) -> void
|
|
@@ -31,6 +32,13 @@ module Duel
|
|
|
31
32
|
# The native extensions loaded, by feature, at their real paths.
|
|
32
33
|
def self.extensions: (?Array[String] features, ?Array[String] load_path) -> Hash[String, String]
|
|
33
34
|
|
|
35
|
+
# Those of +features+ loaded from more than one file, by feature, at
|
|
36
|
+
# their real paths, in the order they loaded.
|
|
37
|
+
def self.twice: (Array[String] features, ?Array[String] load_path) -> Hash[String, Array[String]]
|
|
38
|
+
|
|
39
|
+
# The native extensions loaded, by feature, at their real paths.
|
|
40
|
+
def self.loaded: (Array[String] features, Array[String] load_path) -> Hash[String, Array[String]]
|
|
41
|
+
|
|
34
42
|
# The directories gems are installed in, as real paths ending in "/".
|
|
35
43
|
def self.gem_dirs: (?Array[String] dirs) -> Array[String]
|
|
36
44
|
|
|
@@ -44,7 +52,7 @@ module Duel
|
|
|
44
52
|
def self.yjit?: () -> bool
|
|
45
53
|
|
|
46
54
|
def initialize: (?Array[singleton(Metric)] plugin_metrics, ?Hash[String, Hash[Symbol, untyped]] measures,
|
|
47
|
-
?hooks: Hash[Symbol, Array[hook]]) -> void
|
|
55
|
+
?hooks: Hash[Symbol, Array[hook]], ?before: Array[String]) -> void
|
|
48
56
|
|
|
49
57
|
# Closes its metrics, last first, as it ends.
|
|
50
58
|
def close: () -> void
|
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.4
|
|
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/message.rb
|
|
60
61
|
- lib/duel/metric.rb
|
|
61
62
|
- lib/duel/native.rb
|
|
62
63
|
- lib/duel/process_sample.rb
|
|
@@ -84,6 +85,7 @@ files:
|
|
|
84
85
|
- sig/duel/init.rbs
|
|
85
86
|
- sig/duel/json_report.rbs
|
|
86
87
|
- sig/duel/lock.rbs
|
|
88
|
+
- sig/duel/message.rbs
|
|
87
89
|
- sig/duel/metric.rbs
|
|
88
90
|
- sig/duel/native.rbs
|
|
89
91
|
- sig/duel/process_sample.rbs
|
|
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
122
|
- !ruby/object:Gem::Version
|
|
121
123
|
version: '0'
|
|
122
124
|
requirements: []
|
|
123
|
-
rubygems_version: 4.0.
|
|
125
|
+
rubygems_version: 4.0.24
|
|
124
126
|
specification_version: 4
|
|
125
127
|
summary: 'Performance regression guards: fail when a change makes your code slower'
|
|
126
128
|
test_files: []
|