Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1232,3 +1232,18 @@ this section verbatim). Each entry is one bullet starting with `- `.
This explicit status check still permits reports after ordinary upstream
failures, while allowing cancelled workflows to finish. Workflow-level
policy about which refs cancel older runs is a separate decision.

111. **Specify both thread pools for benchmark subprocesses.** On Julia 1.13,
`--threads=2` starts two default threads plus an interactive thread. A
benchmark that records only `Threads.nthreads()` can therefore report two
threads while Dagger revisions that register physical IDs `1:2` include the
interactive thread and omit a default thread. Launch benchmark and
Distributed worker subprocesses with `--threads=N,0` so the requested
compute count also describes their physical default-thread IDs. Julia
1.10/1.11 reject the explicit zero, so retain their bare `N` spelling,
which already disables the interactive pool. Preserve deliberately supplied
pool specifications. This is a benchmark topology control, separate from
production interactive-thread placement policy. AirspeedVelocity resolves
bare `julia` through `PATH`, so select the driver's executable directory
around its calls before choosing version-dependent flags. Check actual
Distributed worker versions rather than assuming a remote path matches.
8 changes: 5 additions & 3 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@
# operators (keeps tile counts bounded at large N). Defaults to "16".
# - BENCHMARK_PROCS: Worker/thread topology, as "numprocs:numthreads". This
# starts `numprocs` Distributed workers *inside the benchmark worker process*,
# each with `numthreads` threads. Defaults to no extra workers (everything
# runs on the worker process, which uses the orchestrator's thread count).
# each with `numthreads` default-pool threads and no interactive pool.
# Defaults to no extra workers (everything runs on the worker process,
# which uses the orchestrator's default-pool thread count).
# On Distributed CPU, the array and linalg suites also run addition into a
# cyclic destination and LU! on a fresh cyclic workspace. Their matching
# allocating leaves retain the scheduler's placement choices. Run the
Expand Down Expand Up @@ -171,6 +172,7 @@

using BenchmarkTools
import JSON3
include(joinpath(@__DIR__, "threadpools.jl"))

# --- AirspeedVelocity integration ------------------------------------------
# AirspeedVelocity calls `run(SUITE)` and serializes whatever it returns. We run
Expand Down Expand Up @@ -204,7 +206,7 @@ const PROC_TIMEOUT = parse(Float64, get(ENV, "BENCHMARK_PROC_TIMEOUT", "3600"))
const POLL = 0.05

worker_cmd() =
`$JULIA_BIN --project=$(Base.active_project()) --startup-file=no -t$NTHREADS $WORKER_SCRIPT $WORKDIR`
`$JULIA_BIN --project=$(Base.active_project()) --startup-file=no --threads=$(benchmark_thread_spec(NTHREADS)) $WORKER_SCRIPT $WORKDIR`

function _atomic_write(path, data)
tmp = path * ".tmp"
Expand Down
36 changes: 22 additions & 14 deletions benchmark/ci.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
# change must clear before it is called a regression or an improvement
# (default "1.0"). See "Regression check" below; set to "0" to disable the
# spread gate; the five-sample and confirmation requirements still apply.
# - BENCHMARK_CI_THREADS: Julia threads for each benchmark run (default "4").
# - BENCHMARK_CI_THREADS: Airspeed runner thread specification (default "4").
# Bare counts disable its interactive pool; explicit pool specifications such
# as "2,1" are passed through unchanged. Workload subprocesses use the runner
# default-pool count with no interactive pool.
# - BENCHMARK_OUTPUT_DIR: where JSON/plots/report are written
# (default "benchmark_results").

Expand All @@ -39,6 +42,7 @@ using AirspeedVelocity
using JSON3
using AirspeedVelocity.Utils: benchmark, load_results
using AirspeedVelocity.TableUtils: create_table
include(joinpath(@__DIR__, "threadpools.jl"))

const PROJECT_DIR = abspath(joinpath(@__DIR__, ".."))
const SCRIPT = joinpath(@__DIR__, "benchmarks.jl")
Expand Down Expand Up @@ -85,16 +89,18 @@ mkpath(OUTPUT_DIR)

@info "Benchmarking $CUR_REV vs $BASE_REV" project = PROJECT_DIR script = SCRIPT

benchmark(
"Dagger",
[BASE_REV, CUR_REV];
output_dir = OUTPUT_DIR,
script = SCRIPT,
path = PROJECT_DIR,
extra_pkgs = EXTRA_PKGS,
exeflags = `-t $CI_THREADS`,
tune = false,
)
with_benchmark_julia() do
benchmark(
"Dagger",
[BASE_REV, CUR_REV];
output_dir = OUTPUT_DIR,
script = SCRIPT,
path = PROJECT_DIR,
extra_pkgs = EXTRA_PKGS,
exeflags = `--threads=$(benchmark_thread_spec(CI_THREADS))`,
tune = false,
)
end

include(joinpath(@__DIR__, "compare.jl"))
function load_sampled_results(dir)
Expand Down Expand Up @@ -154,9 +160,11 @@ if any(entry -> entry[2] == "time", comparison.regressions)
confirmation_dir = joinpath(OUTPUT_DIR, "confirmation")
mkpath(confirmation_dir)
@info "Confirming timing regressions with a fresh comparison in reversed revision order"
benchmark("Dagger", [CUR_REV, BASE_REV]; output_dir=confirmation_dir,
script=SCRIPT, path=PROJECT_DIR, extra_pkgs=EXTRA_PKGS,
exeflags=`-t $CI_THREADS`, tune=false)
with_benchmark_julia() do
benchmark("Dagger", [CUR_REV, BASE_REV]; output_dir=confirmation_dir,
script=SCRIPT, path=PROJECT_DIR, extra_pkgs=EXTRA_PKGS,
exeflags=`--threads=$(benchmark_thread_spec(CI_THREADS))`, tune=false)
end
confirmation = load_sampled_results(confirmation_dir)
repeated = compare_benchmarks(confirmation[BASE_REV], confirmation[CUR_REV]; comparison_options...)
comparison = confirm_timing_regressions(comparison, repeated)
Expand Down
20 changes: 20 additions & 0 deletions benchmark/threadpools.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Shared by the CI driver, benchmark orchestrator and Distributed worker setup.
# They launch the current Julia executable. Remote deployments must provide
# that same Julia version at the executable path used by Distributed.
function benchmark_thread_spec(threads)
spec = string(threads)
# Preserve an explicitly requested pool topology (and let Julia validate it).
occursin(',', spec) && return spec
# Julia 1.10/1.11 reject an explicit zero interactive count; their bare
# default-pool count already leaves the interactive pool disabled.
return VERSION >= v"1.12.0-DEV" ? "$spec,0" : spec
end

# AirspeedVelocity launches bare `julia`, including its load-time samples.
# Keep that binary aligned with the VERSION used to select the thread syntax.
function with_benchmark_julia(f)
path = get(ENV, "PATH", "")
selected = isempty(path) ? Sys.BINDIR :
string(Sys.BINDIR, Sys.iswindows() ? ';' : ':', path)
return withenv(f, "PATH" => selected)
end
14 changes: 13 additions & 1 deletion benchmark/worker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using Dates, Random, Statistics, LinearAlgebra, InteractiveUtils
import JSON3

include(joinpath(@__DIR__, "common.jl"))
include(joinpath(@__DIR__, "threadpools.jl"))

const WORKDIR = abspath(ARGS[1])

Expand All @@ -51,7 +52,9 @@ else
const nt = 1
end

const worker_exeflags = `--project=$(Base.active_project()) -t $nt`
# Keep physical thread IDs and the requested compute-thread count aligned even
# on Julia versions that otherwise add an interactive thread by default.
const worker_exeflags = `--project=$(Base.active_project()) --threads=$(benchmark_thread_spec(nt))`
if np > 0
addprocs(np; exeflags=worker_exeflags)
end
Expand All @@ -62,6 +65,15 @@ if haskey(ENV, "BENCHMARK_REMOTES")
end
end

# The flag spelling is selected by this driver's Julia version. Check the
# actual children too, especially when BENCHMARK_REMOTES names SSH hosts.
for worker in procs()
worker == myid() && continue
worker_version = remotecall_fetch(getfield, worker, Base, :VERSION)
worker_version == VERSION ||
error("Benchmark worker $worker runs Julia $worker_version; driver runs $VERSION")
end

@everywhere using Dagger

# --- Load acceleration backends (only if requested) ------------------------
Expand Down
Loading