Commit 044ddd31 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[platform] Use more tasks for jobs

Wasm recently switched from spawning a number of background tasks for
compilation to just using a single job (via the pretty new
{Platform::PostJob} API). This caused major regressions in several
benchmarks running in d8, because the {DefaultPlatform} is only using
half of the available worker threads for executing jobs with "user
visible" priority.

This CL changes this to use all available worker threads for "user
blocking" or "user visible" jobs, and two threads for "best effort"
jobs. The limit of two threads for best effort is identical to what
chromium does with best effort *tasks*. For user blocking and user
visible, chromium does not impose any limit, so we also remove the
limitation to half of the threads from d8.

Drive-by: Use {NewDefaultJobHandle} for constructing {DefaultJobHandle}.

R=mlippautz@chromium.org
CC=ahaas@chromium.org, gab@chromium.org, etiennep@chromium.org

Bug: chromium:1113234, chromium:1101340
Change-Id: I9280e649a1cf3832c562ff7251e8bda0103af111
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339481Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Auto-Submit: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69265}
parent 6647f292
......@@ -213,20 +213,12 @@ bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) {
std::unique_ptr<JobHandle> DefaultPlatform::PostJob(
TaskPriority priority, std::unique_ptr<JobTask> job_task) {
size_t num_worker_threads = 0;
switch (priority) {
case TaskPriority::kUserBlocking:
num_worker_threads = NumberOfWorkerThreads();
break;
case TaskPriority::kUserVisible:
num_worker_threads = NumberOfWorkerThreads() / 2;
break;
case TaskPriority::kBestEffort:
num_worker_threads = 1;
break;
size_t num_worker_threads = NumberOfWorkerThreads();
if (priority == TaskPriority::kBestEffort && num_worker_threads > 2) {
num_worker_threads = 2;
}
return std::make_unique<DefaultJobHandle>(std::make_shared<DefaultJobState>(
this, std::move(job_task), priority, num_worker_threads));
return NewDefaultJobHandle(this, priority, std::move(job_task),
num_worker_threads);
}
double DefaultPlatform::MonotonicallyIncreasingTime() {
......
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