Skip to content

Commit d617592

Browse files
use TimerOutputs
1 parent ee05c44 commit d617592

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RegistryTools = "d1eb7eb1-105f-429d-abf5-b0f65cb9e2c4"
2828
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
2929
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
3030
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
31+
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
3132
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
3233
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
3334
ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"
@@ -50,6 +51,7 @@ Registrator = "1.1"
5051
RegistryTools = "2.1"
5152
SHA = "0.7, 1"
5253
Scratch = "1.0"
54+
TimerOutputs = "0.5"
5355
TOML = "1"
5456
ghr_jll = "0.13, 0.14, 0.17"
5557
julia = "1.7"

src/Auditor.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ using Base.BinaryPlatforms
55
using Pkg
66
using ObjectFile
77

8-
using BinaryBuilderBase: march
8+
using BinaryBuilderBase: march, BBB_TIMER
9+
using TimerOutputs: @timeit
910

1011
export audit, collect_files, collapse_symlinks
1112

@@ -30,17 +31,22 @@ This prevents concurrent patchelf operations on the same file.
3031
"""
3132
function with_patchelf_lock(f, path::AbstractString)
3233
# Normalize the path to ensure consistent locking
33-
path = realpath(path)
34+
norm_path = realpath(path)
35+
filename = basename(norm_path)
3436

3537
# Get or create the lock for this file
3638
file_lock = Base.@lock PATCHELF_FILE_LOCKS_LOCK begin
37-
get!(PATCHELF_FILE_LOCKS, path) do
39+
get!(PATCHELF_FILE_LOCKS, norm_path) do
3840
ReentrantLock()
3941
end
4042
end
4143

42-
# Execute with the file-specific lock held
43-
Base.@lock file_lock f()
44+
# Execute with the file-specific lock held, timing both the lock wait and the inner operation
45+
@timeit BBB_TIMER "patchelf $(filename) (incl. lock)" begin
46+
Base.@lock file_lock begin
47+
@timeit BBB_TIMER "patchelf $(filename)" f()
48+
end
49+
end
4450
end
4551

4652
# Helper function to run a command and print to `io` its invocation and full

src/AutoBuild.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export build_tarballs, autobuild, build, get_meta_json
22
import GitHub: gh_get_json, DEFAULT_API
33
import SHA: sha256, sha1
44
using TOML, Dates, UUIDs
5+
using TimerOutputs: @timeit, print_timer
6+
using BinaryBuilderBase: BBB_TIMER, reset_bbb_timer!
57
using RegistryTools
68
import LibGit2
79
import PkgLicenses
@@ -193,6 +195,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
193195
compression_format::String="gzip",
194196
kwargs...)
195197
@nospecialize
198+
reset_bbb_timer!()
196199
# See if someone has passed in `--help`, and if so, give them the
197200
# assistance they so clearly long for
198201
if "--help" in ARGS
@@ -441,6 +444,8 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
441444
upload_to_github_releases(deploy_bin_repo, tag, products_dir; verbose=verbose)
442445
end
443446

447+
print_timer(BBB_TIMER; sortby=:firstexec)
448+
println()
444449
return build_output_meta
445450
end
446451

@@ -836,13 +841,14 @@ function autobuild(dir::AbstractString,
836841
end
837842

838843
# We must prepare our sources. Download them, hash them, etc...
839-
source_files = download_source.(sources; verbose=verbose)
844+
source_files = @timeit BBB_TIMER "Downloading sources" download_source.(sources; verbose=verbose)
840845

841846
# Our build products will go into ./products
842847
out_path = joinpath(dir, "products")
843848
try mkpath(out_path) catch; end
844849

845850
for platform in sort(collect(platforms), by = triplet)
851+
@timeit BBB_TIMER "Building for $(triplet(platform))" begin
846852
timer = BuildTimer()
847853
timer.begin_setup = time()
848854

@@ -928,7 +934,7 @@ function autobuild(dir::AbstractString,
928934
"""
929935

930936
dest_prefix = Prefix(BinaryBuilderBase.destdir(prefix.path, concrete_platform))
931-
did_succeed = with_logfile(dest_prefix, "$(src_name).log"; subdir=src_name) do io
937+
did_succeed = @timeit BBB_TIMER "Running build script" with_logfile(dest_prefix, "$(src_name).log"; subdir=src_name) do io
932938
# Let's start the presentations with BinaryBuilder.jl
933939
write(io, "BinaryBuilder.jl version: $(get_bb_version())\n\n")
934940
# Get the list of compilers...
@@ -959,6 +965,7 @@ function autobuild(dir::AbstractString,
959965
# Run an audit of the prefix to ensure it is properly relocatable
960966
timer.begin_audit = time()
961967
if !skip_audit
968+
@timeit BBB_TIMER "Auditing build artifacts" begin
962969
audit_result = audit(dest_prefix, src_name;
963970
platform=platform, verbose=verbose,
964971
has_csl = any(getname.(dependencies) .== "CompilerSupportLibraries_jll"),
@@ -971,6 +978,7 @@ function autobuild(dir::AbstractString,
971978
""", '\n' => ' ')
972979
error(strip(msg))
973980
end
981+
end # @timeit audit
974982
end
975983
timer.end_audit = time()
976984

@@ -1075,6 +1083,7 @@ function autobuild(dir::AbstractString,
10751083
rm(build_path; recursive=true)
10761084
end
10771085
verbose && @info "$(timer)"
1086+
end # @timeit platform
10781087
end
10791088

10801089
# Return our product hashes

0 commit comments

Comments
 (0)