Commit 6bcfa620 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Use worker_count in job API

The signature of {GetMaxConcurrency} was recently extended to pass the
{worker_count}, i.e. the number of workers that are currently running.
This number allows us to return a more precise number for the current
maximum concurrency.
In the case of background function compilation, we were sometimes
returning a slightly too small number, resulting in too few workers to
be spawned, resulting in slightly longer compilation.
For wrapper compilation on the other hand, the returned number is
already correct, and this CL adds a comment explaining why.

R=thibaudm@chromium.org

Bug: chromium:1101340
Change-Id: I0e3122c8b99ba1cdf97616de922d4f07874b0aeb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2410383Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69906}
parent 29581b7f
......@@ -1628,7 +1628,7 @@ class BackgroundCompileJob : public JobTask {
std::shared_ptr<BackgroundCompileToken> token,
std::shared_ptr<Counters> async_counters,
std::shared_ptr<std::atomic<int>> current_concurrency,
int max_concurrency)
size_t max_concurrency)
: token_(std::move(token)),
async_counters_(std::move(async_counters)),
current_concurrency_(std::move(current_concurrency)),
......@@ -1657,15 +1657,18 @@ class BackgroundCompileJob : public JobTask {
}
}
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return std::min(max_concurrency_, current_concurrency_->load());
size_t GetMaxConcurrency(size_t worker_count) const override {
// {current_concurrency_} does not reflect the units that running workers
// are processing, thus add the current worker count to that number.
return std::min(max_concurrency_,
worker_count + current_concurrency_->load());
}
private:
const std::shared_ptr<BackgroundCompileToken> token_;
const std::shared_ptr<Counters> async_counters_;
const std::shared_ptr<std::atomic<int>> current_concurrency_;
const int max_concurrency_;
const size_t max_concurrency_;
};
} // namespace
......@@ -3295,6 +3298,9 @@ class CompileJSToWasmWrapperJob final : public JobTask {
}
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
// {outstanding_units_} includes the units that other workers are currently
// working on, so we can safely ignore the {worker_count} and just return
// the current number of outstanding units.
return std::min(max_concurrency_,
outstanding_units_.load(std::memory_order_relaxed));
}
......
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