Commit 2d33821f authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Contribute to compilation while waiting

This was disabled previously because the number of queues could not grow
above a predefined limit. Now that this is fixed, we can contribute to
compilation again instead of just waiting for recompilation to finish
(which might never happen if there are no background threads).

R=thibaudm@chromium.org

Change-Id: Ia0567bc8872246efb20ae8aaf96f9d689fca1c49
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2637863Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72196}
parent 1694925c
......@@ -2891,19 +2891,18 @@ void CompilationStateImpl::InitializeRecompilation(
// is disabled).
base::Optional<base::MutexGuard> guard(&callbacks_mutex_);
// For now, we cannot contribute to compilation here, because this would bump
// the number of workers above the expected maximum concurrency. This can be
// fixed once we grow the number of compilation unit queues dynamically.
// TODO(clemensb): Contribute to compilation once the queues grow dynamically.
while (outstanding_recompilation_functions_ > 0) {
auto semaphore = std::make_shared<base::Semaphore>(0);
callbacks_.emplace_back([semaphore](CompilationEvent event) {
if (event == CompilationEvent::kFinishedRecompilation) {
semaphore->Signal();
}
});
// As long as there are outstanding recompilation functions, take part in
// compilation. This is to avoid recompiling for the same tier or for
// different tiers concurrently. Note that the compilation unit queues can run
// empty before {outstanding_recompilation_functions_} drops to zero. In this
// case, we do not wait for the last running compilation threads to finish
// their units, but just start our own recompilation already.
while (outstanding_recompilation_functions_ > 0 &&
compilation_unit_queues_.GetTotalSize() > 0) {
guard.reset();
semaphore->Wait();
constexpr JobDelegate* kNoDelegate = nullptr;
ExecuteCompilationUnits(native_module_weak_, async_counters_.get(),
kNoDelegate, kBaselineOrTopTier);
guard.emplace(&callbacks_mutex_);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment