Skip to content

[Auditor] Make the auditor multithreaded #1364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 9, 2025
Merged

Conversation

giordano
Copy link
Member

@giordano giordano commented Feb 9, 2025

Completely untested, but saving my progress for now. Let's see how far we get with this.

@giordano giordano force-pushed the mg/auditor-multi-threaded branch from b7d2e8a to 0bf1332 Compare February 9, 2025 01:01
@giordano giordano changed the title [Auditor] Make running the auditor multithreaded [Auditor] Make the auditor multithreaded Feb 9, 2025
@giordano giordano force-pushed the mg/auditor-multi-threaded branch from e5a60e0 to 4bd3af6 Compare February 9, 2025 03:16
@giordano
Copy link
Member Author

giordano commented Feb 9, 2025

Good news: building locally JuliaPackaging/Yggdrasil#10479 (with hot ccache 🔥) goes from

[ Info: Timings: setup: 28.0s, build: 2m 14.22s, audit: 21m 23.27s, packaging: 12.44s

to

[ Info: Timings: setup: 27.72s, build: 2m 15.6s, audit: 8m 57.83s, packaging: 12.35s

when using 16 threads. Clearly scaling isn't ideal, but we have to put locks around all uses of the sanbox because otherwise it's a mess, but a 2x speedup is more than welcome.

Bad news: we need to put more locks around all logging macros because they aren't thread-safe and printing is messy, but hopefully they won't slow things down massively.

Note to self: we may be able to replace calls to patchelf at

set_soname_cmd = `$patchelf $(patchelf_flags(platform)) --set-soname $(soname) $(rel_path)`
and
relink_cmd = `$patchelf $(patchelf_flags(platform)) --replace-needed $(old_libpath) $(libname) $(rel_path)`
with the JLL, which removes the need to use locks in a couple of places.

@giordano giordano force-pushed the mg/auditor-multi-threaded branch from a867b21 to d4af135 Compare February 9, 2025 11:48
@giordano giordano force-pushed the mg/auditor-multi-threaded branch from a69f9e4 to 583af47 Compare February 9, 2025 12:03
There seems to be some issues with threading, tests don't pass, but this should
also not be a time-critical pass, so making it serial shouldn't be _too_ bad.
@giordano
Copy link
Member Author

giordano commented Feb 9, 2025

With Threads.@spawn instead of Threads.@threads I get marginally better timings, thanks to slightly more efficient load balancing (again with 16 julia threads):

[ Info: Timings: setup: 24.97s, build: 2m 7.83s, audit: 7m 27.03s, packaging: 12.16s

If CI is happy, this should be in a good shape.

Edit: sadly I had to revert this because it seems to introduce too many race conditions, especially in testing by capturing log messages. Better long-term solution is implementing #670 (have real "audit passes" objects which can be inspected for testing, rather than capturing logs in the ether, and also reorganise the passes to be more amenable to take advantage of parallelism), but here I'm trying to get basic threading working for the sake of making builds faster.

@giordano giordano force-pushed the mg/auditor-multi-threaded branch from 726e3ad to bfbe34e Compare February 9, 2025 14:29
@@ -1,4 +1,5 @@
using ObjectFile.ELF
using Patchelf_jll: patchelf
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see BB2 is already using patchelf, which is great: https://github.com/JuliaPackaging/BinaryBuilder2.jl/blob/54202516e430264dc6060f763c55a7f0fbbd542a/BinaryBuilderAuditor.jl/src/Scanning.jl#L1. But at a quick glance I don't see multi-threading enabled yet.

@giordano
Copy link
Member Author

giordano commented Feb 9, 2025

CI is happy now, let's see how it goes in production

@giordano giordano merged commit e8ae613 into master Feb 9, 2025
10 checks passed
@giordano giordano deleted the mg/auditor-multi-threaded branch February 9, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant