Repository navigation
Windows,Bazel client: multithreaded file writing - #5600
laszlocsomor wants to merge 3 commits into
Conversation
The Bazel client on Windows now writes extracted binaries to disk in parallel. On all other systems it writes them serially (as before). This change makes blaze.cc:ActuallyExtractData() about 3x faster when using a HDD. (In previous experiments I saw no speedup with multi-threaded writing on machines with an SSD.) The Windows-specific code uses the native Threadpool API of Windows, creating a pool of at least 8 and at most 16 threads. (This seems to be a good balance between speed and thread count.) The OS manages everything about the pool; Bazel submits callbacks and the pool executes them asynchronously. blaze.cc:ActuallyExtractData() speed, before: - Windows: 6.48s (avg) / 6.38s (median) - Linux (Debian): 4.78s (avg) / 4.79s (median) blaze.cc:ActuallyExtractData() speed, after: - Windows (8-16 threads): 2.05s (avg) / 2.01s (md) - Windows (1 thread): 5.77s (avg) / 5.74s (median) See bazelbuild#5444 Change-Id: I7211f3d28eb8b9837352c16ff8df0411d5a9ebe1
|
@laszlocsomor Very excited to see the huge speedup! How many cores are there for the machine you are testing? (Although I think it might not really matters since this is I/O bound task, not CPU bound task). My machine has 2 cores with 4 logical processors, HDD.
|
|
|
||
| using std::atomic_bool; | ||
| using std::mutex; | ||
| using std::set; |
There was a problem hiding this comment.
Try not to introduce more using std::type aliases. When reader sees mutex in a function, it is not immediately clear if it is std::mutex or Bazel's own custom mutex implementation.
using MagicMap = std::unordered_map<std::string, MagicItem> that saves significant amount of typing is strongly encouraged.
There was a problem hiding this comment.
Done. Thanks for the advice!
Change-Id: I7e92c75a5602090e7278fe907e85a0bd116fcb9c
Great! Good to hear someone's waiting for this PR to land :) My Windows machine has 6 physical cores (12 logical ones). As you say this is I/O bound and this being a corporate workstation I probably have plenty of I/O work running in the background. I experimented with different thread counts (1, 2, 4, 6, 8, 10, 20, 40, 100) but found around 8-10 to be the
Good point! It won't. The race condition is benign, access is guarded by the one-time-flip of the atomic bool. I added comments to the code. |
Change-Id: I7a74d62a563c92948a4dfa8ad5ac83eae018db10
After this PR is landed, I can tweak the constants and report back the result for my local machine.
👍 |
Thanks, that'd be great! You can already experiment with it:
|
The Bazel client on Windows now writes extracted binaries to disk in parallel. On all other systems it writes them serially (as before). This change makes blaze.cc:ActuallyExtractData() about 3x faster when using a HDD. (In previous experiments I saw no speedup with multi-threaded writing on machines with an SSD.) The Windows-specific code uses the native Threadpool API of Windows, creating a pool of at least 8 and at most 16 threads. (This seems to be a good balance between speed and thread count.) The OS manages everything about the pool; Bazel submits callbacks and the pool executes them asynchronously. blaze.cc:ActuallyExtractData() speed, before: - Windows: 6.48s (avg) / 6.38s (median) - Linux (Debian): 4.78s (avg) / 4.79s (median) blaze.cc:ActuallyExtractData() speed, after: - Windows (8-16 threads): 2.05s (avg) / 2.01s (md) - Windows (1 thread): 5.77s (avg) / 5.74s (median) See bazelbuild#5444 Change-Id: I7211f3d28eb8b9837352c16ff8df0411d5a9ebe1 Closes bazelbuild#5600. Change-Id: I7a74d62a563c92948a4dfa8ad5ac83eae018db10 PiperOrigin-RevId: 204891217
The Bazel client on Windows now writes extracted
binaries to disk in parallel. On all other systems
it writes them serially (as before).
This change makes blaze.cc:ActuallyExtractData()
about 3x faster when using a HDD. (In previous
experiments I saw no speedup with multi-threaded
writing on machines with an SSD.)
The Windows-specific code uses the native
Threadpool API of Windows, creating a pool of at
least 8 and at most 16 threads. (This seems to be
a good balance between speed and thread count.)
The OS manages everything about the pool; Bazel
submits callbacks and the pool executes them
asynchronously.
blaze.cc:ActuallyExtractData() speed, before:
blaze.cc:ActuallyExtractData() speed, after:
See #5444
Change-Id: I7211f3d28eb8b9837352c16ff8df0411d5a9ebe1