duel 0.1.8 → 0.2.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 +4 -4
- data/CHANGELOG.md +146 -1
- data/README.md +35 -0
- data/docs/ci.md +96 -3
- data/docs/configuration.md +35 -1
- data/docs/how-it-works.md +14 -8
- data/docs/plugins.md +16 -0
- data/lib/duel/across.rb +1 -6
- data/lib/duel/baseline.rb +8 -7
- data/lib/duel/cli.rb +45 -19
- data/lib/duel/comment.rb +71 -10
- data/lib/duel/config.rb +113 -2
- data/lib/duel/context.rb +33 -34
- data/lib/duel/control.rb +52 -0
- data/lib/duel/init.rb +142 -18
- data/lib/duel/lane.rb +734 -0
- data/lib/duel/lock.rb +34 -4
- data/lib/duel/memory.rb +14 -5
- data/lib/duel/metric.rb +97 -26
- data/lib/duel/native.rb +199 -32
- data/lib/duel/platform.rb +31 -0
- data/lib/duel/process_sample.rb +74 -49
- data/lib/duel/resource.rb +71 -42
- data/lib/duel/result.rb +165 -0
- data/lib/duel/rubies.rb +21 -3
- data/lib/duel/runner.rb +13 -1039
- data/lib/duel/spawn.rb +327 -0
- data/lib/duel/summary.rb +10 -10
- data/lib/duel/templates/perf-caller.yml.erb +43 -0
- data/lib/duel/templates/perf-comment-caller.yml.erb +42 -0
- data/lib/duel/templates/perf-comment.yml.erb +45 -3
- data/lib/duel/templates/perf.yml.erb +143 -7
- data/lib/duel/testing.rb +3 -0
- data/lib/duel/version.rb +1 -1
- data/lib/duel/worker.rb +13 -4
- data/lib/duel/worker_process.rb +142 -0
- data/lib/duel.rb +27 -3
- data/sig/duel/cli.rbs +8 -0
- data/sig/duel/comment.rbs +16 -1
- data/sig/duel/config.rbs +52 -2
- data/sig/duel/context.rbs +4 -31
- data/sig/duel/control.rbs +27 -0
- data/sig/duel/init.rbs +56 -0
- data/sig/duel/lane.rbs +202 -0
- data/sig/duel/lock.rbs +8 -1
- data/sig/duel/memory.rbs +1 -1
- data/sig/duel/metric.rbs +53 -10
- data/sig/duel/native.rbs +109 -9
- data/sig/duel/platform.rbs +13 -0
- data/sig/duel/process_sample.rbs +7 -9
- data/sig/duel/resource.rbs +28 -9
- data/sig/duel/result.rbs +164 -0
- data/sig/duel/rubies.rbs +4 -0
- data/sig/duel/runner.rbs +3 -460
- data/sig/duel/spawn.rbs +111 -0
- data/sig/duel/summary.rbs +3 -2
- data/sig/duel/worker_process.rbs +90 -0
- data/sig/duel.rbs +17 -3
- metadata +121 -107
data/sig/duel/context.rbs
CHANGED
|
@@ -189,8 +189,6 @@ module Duel
|
|
|
189
189
|
@timed: Hash[String, Metric::value]
|
|
190
190
|
@counted: Hash[String, Metric::value]
|
|
191
191
|
@details: Hash[String, String]
|
|
192
|
-
@started: true?
|
|
193
|
-
@stopped: true?
|
|
194
192
|
@heap: Integer
|
|
195
193
|
|
|
196
194
|
# What a metric learns of the sample: its benchmark and its iterations.
|
|
@@ -198,12 +196,6 @@ module Duel
|
|
|
198
196
|
|
|
199
197
|
attr_reader n: Integer
|
|
200
198
|
|
|
201
|
-
# @api private
|
|
202
|
-
attr_reader started: true?
|
|
203
|
-
|
|
204
|
-
# @api private
|
|
205
|
-
attr_reader stopped: true?
|
|
206
|
-
|
|
207
199
|
# Each timed measure's total, by name.
|
|
208
200
|
# @api private
|
|
209
201
|
attr_reader timed: Hash[String, Metric::value]
|
|
@@ -284,16 +276,9 @@ module Duel
|
|
|
284
276
|
# A run of a benchmark that measures nothing: to see that it runs.
|
|
285
277
|
# @api private
|
|
286
278
|
class Trial
|
|
287
|
-
|
|
288
|
-
@stopped: true?
|
|
289
|
-
|
|
290
|
-
attr_reader started: true?
|
|
291
|
-
|
|
292
|
-
attr_reader stopped: true?
|
|
293
|
-
|
|
294
|
-
def start: () -> true
|
|
279
|
+
def start: () -> void
|
|
295
280
|
|
|
296
|
-
def stop: () ->
|
|
281
|
+
def stop: () -> void
|
|
297
282
|
|
|
298
283
|
def pause: [T] () { () -> T } -> T
|
|
299
284
|
|
|
@@ -305,8 +290,6 @@ module Duel
|
|
|
305
290
|
# A stretch of a benchmark run for its peak memory.
|
|
306
291
|
# @api private
|
|
307
292
|
class MemorySample
|
|
308
|
-
@started: true?
|
|
309
|
-
@stopped: true?
|
|
310
293
|
# Resident memory where it started, plus what paused blocks left.
|
|
311
294
|
@base: Integer
|
|
312
295
|
# The most above it the watcher saw, outside paused blocks.
|
|
@@ -315,10 +298,7 @@ module Duel
|
|
|
315
298
|
# Resident memory when it last stopped watching.
|
|
316
299
|
@unwatched: Integer
|
|
317
300
|
@watcher: Thread
|
|
318
|
-
|
|
319
|
-
attr_reader started: true?
|
|
320
|
-
|
|
321
|
-
attr_reader stopped: true?
|
|
301
|
+
@lock: Thread::Mutex
|
|
322
302
|
|
|
323
303
|
# Bytes (once it's stopped).
|
|
324
304
|
attr_reader peak: Integer
|
|
@@ -358,16 +338,9 @@ module Duel
|
|
|
358
338
|
# What StackProf samples by here (see .mode).
|
|
359
339
|
MODE: :cpu | :wall
|
|
360
340
|
|
|
361
|
-
@started: true?
|
|
362
|
-
@stopped: true?
|
|
363
|
-
|
|
364
341
|
# What StackProf samples by on +platform+: CPU time, but elapsed time
|
|
365
342
|
# on macOS.
|
|
366
|
-
def self.mode: (?String
|
|
367
|
-
|
|
368
|
-
attr_reader started: true?
|
|
369
|
-
|
|
370
|
-
attr_reader stopped: true?
|
|
343
|
+
def self.mode: (?platform: String) -> (:cpu | :wall)
|
|
371
344
|
|
|
372
345
|
def start: () -> void
|
|
373
346
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Duel
|
|
2
|
+
# The runner's connection to a worker: a Unix socket, or a port of
|
|
3
|
+
# 127.0.0.1's where there are none.
|
|
4
|
+
# @api private
|
|
5
|
+
module Control
|
|
6
|
+
HOST: String
|
|
7
|
+
UNIX: bool
|
|
8
|
+
TCP: Regexp
|
|
9
|
+
|
|
10
|
+
# Whether a worker can reach a server on a Unix socket: not on
|
|
11
|
+
# Windows, nor where Ruby has none.
|
|
12
|
+
def self.unix_sockets?: (windows: bool, ?unix: bool) -> bool
|
|
13
|
+
|
|
14
|
+
# A server for a worker to connect to, at +path+ (or a port, unless
|
|
15
|
+
# +unix+), and its address.
|
|
16
|
+
def self.listen: (String path, unix: bool) -> [UNIXServer | TCPServer, String]
|
|
17
|
+
|
|
18
|
+
# A server on a port of 127.0.0.1's that the system chose.
|
|
19
|
+
def self.tcp_server: () -> TCPServer
|
|
20
|
+
|
|
21
|
+
# A connection to the server at +address+.
|
|
22
|
+
def self.connect: (String address) -> (UNIXSocket | TCPSocket)
|
|
23
|
+
|
|
24
|
+
# Removes a Unix socket's file.
|
|
25
|
+
def self.remove: (String address) -> void
|
|
26
|
+
end
|
|
27
|
+
end
|
data/sig/duel/init.rbs
CHANGED
|
@@ -18,6 +18,9 @@ module Duel
|
|
|
18
18
|
# The color of the label it creates.
|
|
19
19
|
LABEL_COLOR: String
|
|
20
20
|
|
|
21
|
+
# Where Duel's reusable workflows are.
|
|
22
|
+
REUSABLE: String
|
|
23
|
+
|
|
21
24
|
# Where it reads an answer.
|
|
22
25
|
interface _Input
|
|
23
26
|
def tty?: () -> bool
|
|
@@ -26,6 +29,7 @@ module Duel
|
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
@argv: Array[String]
|
|
32
|
+
@repository: String?
|
|
29
33
|
@out: _Output
|
|
30
34
|
@err: _Output
|
|
31
35
|
@input: _Input
|
|
@@ -33,6 +37,7 @@ module Duel
|
|
|
33
37
|
@label: bool?
|
|
34
38
|
@force: bool?
|
|
35
39
|
@dry_run: bool?
|
|
40
|
+
@reusable: bool?
|
|
36
41
|
@check: bool?
|
|
37
42
|
@gitlab: bool?
|
|
38
43
|
@badge: bool?
|
|
@@ -57,6 +62,10 @@ module Duel
|
|
|
57
62
|
# Whether the file at +path+ is +content+, saying so, or how it differs.
|
|
58
63
|
def same?: (String path, String content) -> bool
|
|
59
64
|
|
|
65
|
+
# How +lines+ (the file at +path+'s) differ from +content+, as diff -u
|
|
66
|
+
# has it.
|
|
67
|
+
def diff: (String path, String lines, String content) -> String
|
|
68
|
+
|
|
60
69
|
# Creates the label that accepts a regression, with gh, if it's missing
|
|
61
70
|
# and the answer to whether to is yes.
|
|
62
71
|
def create_label: () -> void
|
|
@@ -104,6 +113,21 @@ module Duel
|
|
|
104
113
|
|
|
105
114
|
def render: (String name) -> String
|
|
106
115
|
|
|
116
|
+
# Whether the templates are rendered as Duel's reusable workflows.
|
|
117
|
+
def reusable?: () -> bool
|
|
118
|
+
|
|
119
|
+
# Whether the workflow's jobs write to the repository.
|
|
120
|
+
def writes?: () -> bool?
|
|
121
|
+
|
|
122
|
+
# What a workflow it writes with --reusable passes on to Duel's, as
|
|
123
|
+
# its inputs, each as YAML has it.
|
|
124
|
+
def perf_inputs: () -> Hash[String, String]
|
|
125
|
+
|
|
126
|
+
def comment_inputs: () -> Hash[String, String]
|
|
127
|
+
|
|
128
|
+
# The glob release tags match, as .duel.rb sets it.
|
|
129
|
+
def set_release_tags: () -> String?
|
|
130
|
+
|
|
107
131
|
# The project's configuration, as the conventions have it.
|
|
108
132
|
def config: () -> Config
|
|
109
133
|
|
|
@@ -154,6 +178,9 @@ module Duel
|
|
|
154
178
|
# The project's directory, from its repository's root, or nil.
|
|
155
179
|
def working_directory: () -> String?
|
|
156
180
|
|
|
181
|
+
# +name+, or for a project in a subdirectory, +name+-<its path>.
|
|
182
|
+
def suffixed: (String name) -> String
|
|
183
|
+
|
|
157
184
|
def workflow_name: () -> String
|
|
158
185
|
|
|
159
186
|
# What marks the workflow's comment on a pull request.
|
|
@@ -176,5 +203,34 @@ module Duel
|
|
|
176
203
|
|
|
177
204
|
# The Ruby image's tag for GitLab CI.
|
|
178
205
|
def gitlab_ruby: () -> String
|
|
206
|
+
|
|
207
|
+
# Duel's reusable workflows: the templates, each setting an input.
|
|
208
|
+
class Reusable < Init
|
|
209
|
+
def files: () -> Hash[String, String]
|
|
210
|
+
|
|
211
|
+
private
|
|
212
|
+
|
|
213
|
+
def reusable?: () -> true
|
|
214
|
+
|
|
215
|
+
def accept_label: () -> String
|
|
216
|
+
|
|
217
|
+
def release_tags: () -> String
|
|
218
|
+
|
|
219
|
+
def ruby_version: () -> String
|
|
220
|
+
|
|
221
|
+
def working_directory: () -> String
|
|
222
|
+
|
|
223
|
+
def passed_branch: () -> String
|
|
224
|
+
|
|
225
|
+
def badge_branch: () -> String
|
|
226
|
+
|
|
227
|
+
def version_file: () -> true
|
|
228
|
+
|
|
229
|
+
def comment_on_pushes?: () -> true
|
|
230
|
+
|
|
231
|
+
def mark_passed?: () -> true
|
|
232
|
+
|
|
233
|
+
def badge?: () -> true
|
|
234
|
+
end
|
|
179
235
|
end
|
|
180
236
|
end
|
data/sig/duel/lane.rbs
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
module Duel
|
|
2
|
+
# Workers of both versions, taking turns.
|
|
3
|
+
# @api private
|
|
4
|
+
class Lane
|
|
5
|
+
TARGET_NS: Integer
|
|
6
|
+
RUNS: Integer
|
|
7
|
+
WARMUP: Integer
|
|
8
|
+
HEAP_CAP: Integer
|
|
9
|
+
STEP: Integer
|
|
10
|
+
MAX_PAIRS: Integer
|
|
11
|
+
# The round of a sample from every worker from which a benchmark
|
|
12
|
+
# judged by process is decided.
|
|
13
|
+
MIN_ROUNDS: Integer
|
|
14
|
+
PROCESS_PAIRS: Integer
|
|
15
|
+
COUNTS: Integer
|
|
16
|
+
JRUBY_COUNTS: Integer
|
|
17
|
+
# The rounds of a sample from every worker a count by process takes.
|
|
18
|
+
COUNT_ROUNDS: Integer
|
|
19
|
+
MEMORY_SAMPLES: Integer
|
|
20
|
+
PROFILE_SAMPLES: Integer
|
|
21
|
+
# A process benchmark's pairs before any are measured, and its runs a
|
|
22
|
+
# sample (unless it says), each sample the fastest of them, as many
|
|
23
|
+
# as take PROCESS_SAMPLE_NS of CPU time.
|
|
24
|
+
PROCESS_WARMUP: Integer
|
|
25
|
+
PROCESS_RUNS: Integer
|
|
26
|
+
PROCESS_SAMPLE_NS: Integer
|
|
27
|
+
# The longest TMPDIR a lane's directory goes in.
|
|
28
|
+
SHORT: Integer
|
|
29
|
+
|
|
30
|
+
self.@ids: Integer
|
|
31
|
+
self.@ids_lock: Thread::Mutex
|
|
32
|
+
|
|
33
|
+
# Its number (see .next_id).
|
|
34
|
+
@id: Integer
|
|
35
|
+
@dir: String
|
|
36
|
+
@resources: Array[Resource]
|
|
37
|
+
@workers: Array[WorkerProcess]
|
|
38
|
+
@lock: Thread::Mutex
|
|
39
|
+
@config: Config
|
|
40
|
+
@settings: Settings
|
|
41
|
+
@sides: Hash[String, Side]
|
|
42
|
+
# A process benchmark's peak memory samples, by version.
|
|
43
|
+
@peaks: Hash[String, Array[Integer?]]
|
|
44
|
+
@bases: Array[WorkerProcess]
|
|
45
|
+
@candidates: Array[WorkerProcess]
|
|
46
|
+
@profiler: bool
|
|
47
|
+
# The warm-up's seconds (see #warm).
|
|
48
|
+
@warm: Float
|
|
49
|
+
|
|
50
|
+
attr_reader profiler: bool
|
|
51
|
+
|
|
52
|
+
def initialize: (Config config, Settings settings, Hash[String, Side] sides, ?processes: Integer) -> void
|
|
53
|
+
|
|
54
|
+
# A number of its own for each lane, from 1.
|
|
55
|
+
def self.next_id: () -> Integer
|
|
56
|
+
|
|
57
|
+
# Whether +processes+ workers of each version are enough for a
|
|
58
|
+
# +confidence+ interval over them.
|
|
59
|
+
def self.by_process?: (Integer processes, Float confidence) -> bool
|
|
60
|
+
|
|
61
|
+
# A directory for a lane's sockets.
|
|
62
|
+
def self.tmpdir: () -> String
|
|
63
|
+
|
|
64
|
+
# Where lanes' directories go: TMPDIR if it's short, else /tmp.
|
|
65
|
+
def self.short_tmp: (?String tmpdir, ?windows: bool) -> String
|
|
66
|
+
|
|
67
|
+
# Opens a lane, yields it and always closes it.
|
|
68
|
+
def self.open: [T] (Config config, Settings settings, Hash[String, Side] sides, ?processes: Integer) { (Lane lane) -> T } -> T
|
|
69
|
+
|
|
70
|
+
def benchmarks: () -> Hash[String, Definition::summary]
|
|
71
|
+
|
|
72
|
+
# The Ruby each version runs on, by version.
|
|
73
|
+
def rubies: () -> Hash[String, String]
|
|
74
|
+
|
|
75
|
+
def stop: () -> void
|
|
76
|
+
|
|
77
|
+
# Measures one benchmark on both versions.
|
|
78
|
+
def compare: (String name) -> Result
|
|
79
|
+
|
|
80
|
+
# Profiles of the benchmark on each version, or nil without StackProf.
|
|
81
|
+
def profile: (String name, Integer n) -> Hash[String, Profile::profile]?
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def spawn: (String side, Integer index) -> WorkerProcess
|
|
86
|
+
|
|
87
|
+
# Fails if a version's workers loaded a native extension that isn't a
|
|
88
|
+
# build of its own.
|
|
89
|
+
def check_builds: () -> void
|
|
90
|
+
|
|
91
|
+
# Whether +path+ (that +worker+ loaded) is in +side+'s tree, and not
|
|
92
|
+
# in an installed gem.
|
|
93
|
+
def inside?: (String path, String side, WorkerProcess worker) -> bool
|
|
94
|
+
|
|
95
|
+
def each_worker: () { (WorkerProcess worker) -> void } -> void
|
|
96
|
+
|
|
97
|
+
def set_up: (String name, Result result) -> void
|
|
98
|
+
|
|
99
|
+
def metrics: () -> Array[Metric::spec]
|
|
100
|
+
|
|
101
|
+
# What the block returns for each item, each on a thread of its own.
|
|
102
|
+
# Adds an item to a list, from a thread of its own.
|
|
103
|
+
def keep: [T] (Array[T] list, T item) -> void
|
|
104
|
+
|
|
105
|
+
# Whether workers start (and stop) at once.
|
|
106
|
+
PARALLEL: bool
|
|
107
|
+
|
|
108
|
+
# (Untyped: Steep loses a generic in a thread's block.)
|
|
109
|
+
def in_parallel: (Array[untyped] items) { (untyped item) -> untyped } -> Array[untyped]
|
|
110
|
+
|
|
111
|
+
def measure: (String name, Result result) -> void
|
|
112
|
+
|
|
113
|
+
# A process benchmark's samples.
|
|
114
|
+
def measure_process: (String name, Result result) -> void
|
|
115
|
+
|
|
116
|
+
# The runs a process benchmark's sample takes, by its warm-up's.
|
|
117
|
+
def process_runs: (Array[[WorkerProcess::reply, WorkerProcess::reply]] floors) -> Integer
|
|
118
|
+
|
|
119
|
+
def warm: (String name, Integer n) -> void
|
|
120
|
+
|
|
121
|
+
# The seconds of samples whose median, no faster by STEADY_GAIN than
|
|
122
|
+
# the last's, end a worker's warm-up, without --warm.
|
|
123
|
+
STEADY: Float
|
|
124
|
+
STEADY_GAIN: Float
|
|
125
|
+
STEADY_WINDOWS: Integer
|
|
126
|
+
|
|
127
|
+
# Samples a worker until it's steady, or it's +warm_until+.
|
|
128
|
+
def steady: (WorkerProcess worker, String name, Integer n, Float warm_until) -> void
|
|
129
|
+
|
|
130
|
+
# STEADY seconds of a worker's samples' CPU time, and when they ended.
|
|
131
|
+
def window: (WorkerProcess worker, String name, Integer n, Float warm_until) -> [Array[Metric::value], Float]
|
|
132
|
+
|
|
133
|
+
def judge: (String name, Integer n, Array[[WorkerProcess::reply, WorkerProcess::reply]] floors, Result result) -> void
|
|
134
|
+
|
|
135
|
+
# Whether a benchmark's timings are judged by process.
|
|
136
|
+
def by_process?: (String name) -> bool
|
|
137
|
+
|
|
138
|
+
# Judges each of +judged+ over workers, in rounds of a sample from
|
|
139
|
+
# every worker.
|
|
140
|
+
def judge_processes: (String name, Integer n, Array[Metric::spec] judged, Result result) -> void
|
|
141
|
+
|
|
142
|
+
# The most rounds of +k+ workers' pairs.
|
|
143
|
+
def rounds: (Integer k) -> Integer
|
|
144
|
+
|
|
145
|
+
# Each worker's median, by version.
|
|
146
|
+
def medians: (Hash[String, Array[Array[Metric::value]]] values) -> Hash[String, Array[Metric::value]]
|
|
147
|
+
|
|
148
|
+
# The baseline's medians, at least 1, and the candidate's.
|
|
149
|
+
def clamped: (Hash[String, Array[Metric::value]] each) -> [Array[Metric::value], Array[Metric::value]]
|
|
150
|
+
|
|
151
|
+
# What each worker's medians say against the spec's limit.
|
|
152
|
+
def process_verdict: (Hash[String, Array[Metric::value]] each, Metric::spec spec) -> Stats::verdict
|
|
153
|
+
|
|
154
|
+
# Whether both versions' CPU time is below its floor.
|
|
155
|
+
def below_cpu_floor?: (Array[[Worker::sampled, Worker::sampled]] floors) -> bool
|
|
156
|
+
|
|
157
|
+
# Whether one version's samples are above a spec's floors.
|
|
158
|
+
def above_floors?: (Array[Hash[String, Metric::value]] samples, Metric::spec spec) -> bool
|
|
159
|
+
|
|
160
|
+
def limit: (Metric::spec spec) -> Float
|
|
161
|
+
|
|
162
|
+
def verdict: (Array[Float] ratios, Metric::spec spec) -> Stats::verdict
|
|
163
|
+
|
|
164
|
+
# The verdicts that decide a measure at the end of a round, and after
|
|
165
|
+
# any other pair.
|
|
166
|
+
DECISIVE: Hash[bool, Array[Stats::verdict]]
|
|
167
|
+
|
|
168
|
+
# Whether +verdict+ decides a measure, at the end of a round or not.
|
|
169
|
+
def decided?: (Stats::verdict verdict, bool round) -> bool
|
|
170
|
+
|
|
171
|
+
def calibrate: (String name, Integer target, Integer n) -> Integer
|
|
172
|
+
|
|
173
|
+
# The most iterations whose allocations fit HEAP_CAP (infinite when it
|
|
174
|
+
# allocated nothing).
|
|
175
|
+
def most_iterations: (Integer n, Integer heap) -> (Integer | Float)
|
|
176
|
+
|
|
177
|
+
# The +index+th pair: [baseline's reply, candidate's].
|
|
178
|
+
def pair: (String name, Integer n, Integer index, ?runs: Integer, ?count: bool) -> [WorkerProcess::reply, WorkerProcess::reply]
|
|
179
|
+
|
|
180
|
+
# A sample from a baseline worker and from a candidate worker: [baseline's reply, candidate's].
|
|
181
|
+
def sampled: (String name, Integer n, WorkerProcess base, WorkerProcess candidate, base_first: bool, ?runs: Integer, ?count: bool) -> [WorkerProcess::reply, WorkerProcess::reply]
|
|
182
|
+
|
|
183
|
+
def count: (String name, Integer n, Result result) -> void
|
|
184
|
+
|
|
185
|
+
# The samples a count takes.
|
|
186
|
+
def counts: () -> Integer
|
|
187
|
+
|
|
188
|
+
# Each counted measure, by each worker's fewest, and how much more
|
|
189
|
+
# the candidate's are at least.
|
|
190
|
+
def count_by_process: (String name, Integer n, Result result) -> void
|
|
191
|
+
|
|
192
|
+
# Keeps each count of a worker's sample where it's that worker's
|
|
193
|
+
# fewest so far.
|
|
194
|
+
def fewest!: (Hash[String, Hash[String, Hash[Integer, Metric::value]]] fewest, String side, Integer worker, WorkerProcess::reply sample) -> void
|
|
195
|
+
|
|
196
|
+
def peak_memory: (String name, Integer n, Result result) -> void
|
|
197
|
+
|
|
198
|
+
def fresh: [T] (String side) { (WorkerProcess worker) -> T } -> T
|
|
199
|
+
|
|
200
|
+
def monotonic: () -> Float
|
|
201
|
+
end
|
|
202
|
+
end
|
data/sig/duel/lock.rbs
CHANGED
|
@@ -7,13 +7,20 @@ module Duel
|
|
|
7
7
|
|
|
8
8
|
# Runs the block holding +dir+'s lock. Fails, naming the run that
|
|
9
9
|
# holds it, if another does.
|
|
10
|
-
def self.hold: [T] (String dir) { () -> T } -> T
|
|
10
|
+
def self.hold: [T] (String dir, ?windows: bool) { () -> T } -> T
|
|
11
11
|
|
|
12
12
|
# The lock file at +path+, locked: the one there now.
|
|
13
13
|
def self.acquire: (String path, String dir) -> File
|
|
14
14
|
|
|
15
15
|
# The directories, +dir+ and those it's in, that aren't there yet,
|
|
16
16
|
# deepest first.
|
|
17
|
+
# The pid another run wrote in its lock, or "".
|
|
18
|
+
HELD: Array[String]
|
|
19
|
+
|
|
20
|
+
def self.lock: (File file) -> (Integer | false)
|
|
21
|
+
|
|
22
|
+
def self.whose: (File file) -> String
|
|
23
|
+
|
|
17
24
|
def self.missing: (String dir) -> Array[String]
|
|
18
25
|
|
|
19
26
|
# Removes the empty directories in +dir+, then +dir+, then those of
|
data/sig/duel/memory.rbs
CHANGED
|
@@ -10,7 +10,7 @@ module Duel
|
|
|
10
10
|
ROOT: String
|
|
11
11
|
|
|
12
12
|
# The bytes available, or nil where Duel can't tell.
|
|
13
|
-
def self.available: (?root: String, ?vm_stat: ^() -> String?) -> Integer?
|
|
13
|
+
def self.available: (?root: String, ?vm_stat: ^() -> String?, ?windows: ^() -> Integer?) -> Integer?
|
|
14
14
|
|
|
15
15
|
# MemAvailable, at most what the cgroup leaves, or nil.
|
|
16
16
|
def self.linux: (String root) -> Integer?
|
data/sig/duel/metric.rbs
CHANGED
|
@@ -30,7 +30,7 @@ module Duel
|
|
|
30
30
|
|
|
31
31
|
# A measure's settings, every one, resolved (see Metric.resolve).
|
|
32
32
|
type resolved = { kind: kind, unit: String?, plural: String?, floor: value, cpu_floor: value, limit: Float?, unit_ns: value,
|
|
33
|
-
sizes_samples: bool, across: bool, tolerance: value, allowance: value }
|
|
33
|
+
sizes_samples: bool, across: bool, tolerance: value, allowance: value, ?calibrate: bool }
|
|
34
34
|
|
|
35
35
|
# No measure's settings changed.
|
|
36
36
|
# @api private
|
|
@@ -75,10 +75,6 @@ module Duel
|
|
|
75
75
|
# within +tolerance+ an iteration and +allowance+ a sample.
|
|
76
76
|
def self.within?: (value more, Integer n, tolerance: value, allowance: value) -> bool
|
|
77
77
|
|
|
78
|
-
# Each measure's kind, by name.
|
|
79
|
-
# @api private
|
|
80
|
-
def self.kinds: () -> Hash[String, kind]
|
|
81
|
-
|
|
82
78
|
# Fails unless +settings+ (a measure's) are settings there are, with a
|
|
83
79
|
# kind there is.
|
|
84
80
|
# @api private
|
|
@@ -90,7 +86,7 @@ module Duel
|
|
|
90
86
|
|
|
91
87
|
# A measure's settings: those given, and the rest as by default.
|
|
92
88
|
# @api private
|
|
93
|
-
def self.resolve: (Hash[Symbol, untyped] given) -> resolved
|
|
89
|
+
def self.resolve: (Hash[Symbol, untyped] given) -> Metric::resolved
|
|
94
90
|
|
|
95
91
|
# Its measures as the runner learns them, with +overrides+ by name.
|
|
96
92
|
# @api private
|
|
@@ -239,6 +235,11 @@ module Duel
|
|
|
239
235
|
# (Its measures as Config#metric takes them: from keywords too.)
|
|
240
236
|
def self.define: (Hash[untyped, untyped] measures, (^() -> read[Metric::value, untyped])? read) -> singleton(Snapshot)
|
|
241
237
|
|
|
238
|
+
# A measure's settings, resolved, and whether its reading's cost is
|
|
239
|
+
# learned and taken away (calibrate).
|
|
240
|
+
# @api private
|
|
241
|
+
def self.resolve: (Hash[Symbol, untyped] given) -> Metric::resolved
|
|
242
|
+
|
|
242
243
|
# Sets what it measures and how it reads them, and returns it.
|
|
243
244
|
# @api private
|
|
244
245
|
def self.reading: (Hash[untyped, untyped] measures, ^() -> read[Metric::value, untyped] read) -> singleton(Snapshot)
|
|
@@ -299,12 +300,54 @@ module Duel
|
|
|
299
300
|
def grew: (totals[Metric::value] before, String name) -> Metric::value
|
|
300
301
|
end
|
|
301
302
|
|
|
302
|
-
# CPU time in nanoseconds: the benchmark thread's, or the process's
|
|
303
|
+
# CPU time in nanoseconds: the benchmark thread's, or the process's
|
|
304
|
+
# (on Windows, a Float: see CycleClock).
|
|
303
305
|
# @api private
|
|
304
306
|
module Clock
|
|
305
|
-
def self.thread: () -> Integer
|
|
307
|
+
def self.thread: () -> (Integer | Float)
|
|
306
308
|
|
|
307
|
-
def self.process: () -> Integer
|
|
309
|
+
def self.process: () -> (Integer | Float)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# CPU time on Windows: the cycles charged to the thread or the
|
|
313
|
+
# process, in nanoseconds at the run's rate.
|
|
314
|
+
# @api private
|
|
315
|
+
module CycleClock
|
|
316
|
+
RATE: String
|
|
317
|
+
CALIBRATION_NS: Integer
|
|
318
|
+
CALIBRATIONS: Integer
|
|
319
|
+
|
|
320
|
+
interface _Counter
|
|
321
|
+
def read: () -> Float
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# The environment (ENV, or a Hash in its place).
|
|
325
|
+
interface _Env
|
|
326
|
+
def []: (String name) -> String?
|
|
327
|
+
|
|
328
|
+
def []=: (String name, String? value) -> String?
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
self.@thread: Native::Windows::Cycles
|
|
332
|
+
self.@process: Native::Windows::Cycles
|
|
333
|
+
self.@rate: Float
|
|
334
|
+
|
|
335
|
+
def self.thread: () -> Float
|
|
336
|
+
|
|
337
|
+
def self.process: () -> Float
|
|
338
|
+
|
|
339
|
+
# +cycles+, in whole nanoseconds.
|
|
340
|
+
def self.ns: (Float cycles) -> Integer
|
|
341
|
+
|
|
342
|
+
# The cycles in a nanosecond: +env+'s, or else measured, and set
|
|
343
|
+
# there.
|
|
344
|
+
def self.rate: (?env: _Env) -> Float
|
|
345
|
+
|
|
346
|
+
# Measures the rate on Windows, before a run starts its workers.
|
|
347
|
+
def self.prepare: (?windows: bool) -> Float?
|
|
348
|
+
|
|
349
|
+
# The most cycles +cycles+ counted in a nanosecond of +clock+'s.
|
|
350
|
+
def self.calibrate: (?cycles: _Counter, ?clock: ^() -> Integer) -> Float
|
|
308
351
|
end
|
|
309
352
|
|
|
310
353
|
# Bytes allocated, by the benchmark thread or by every thread (JRuby).
|
|
@@ -322,7 +365,7 @@ module Duel
|
|
|
322
365
|
# CPU time, in nanoseconds.
|
|
323
366
|
class CPU < Metric
|
|
324
367
|
@clock: :thread | :process
|
|
325
|
-
@started: Integer
|
|
368
|
+
@started: Integer | Float
|
|
326
369
|
|
|
327
370
|
def start_sample: (Sample sample) -> void
|
|
328
371
|
|