Commit f4085c8e authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

Revert "[wasm] Reduce job priority once baseline compilation finishes"

This reverts commit cf9a28b6.

Reason for revert: TSAN failures: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20TSAN/34374?

Original change's description:
> [wasm] Reduce job priority once baseline compilation finishes
>
> This Cl changes the priority of baseline compilation from kUserVisible
> to kUserBlocking. Once baseline compilation finishes, the priority is
> reduced to kUserVisible. The reason for using kUserBlocking is that
> thereby TurboFan compilation cannot block Liftoff compilation anymore.
> Additionally, kUserBlocking is quite appropriate, as the initial
> compilation does block a whole section of a web app from execution.
>
> R=​clemensb@chromium.org
>
> Bug: v8:11088
> Change-Id: Ifde42d20f36d4c0a5122b0008311ccdffbb60e48
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519559
> Commit-Queue: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#71404}

TBR=ahaas@chromium.org,clemensb@chromium.org

Change-Id: I9a975c4c43189015491b08d3a98de991d8167daf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:11088
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2560200Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71409}
parent 83edea07
......@@ -595,10 +595,9 @@ class CompilationStateImpl {
void WaitForCompilationEvent(CompilationEvent event);
void ReduceCompilationPriority() {
if (current_compile_job_ && current_compile_job_->UpdatePriorityEnabled()) {
current_compile_job_->UpdatePriority(TaskPriority::kUserVisible);
}
void SetHighPriority() {
base::MutexGuard guard(&mutex_);
has_priority_ = true;
}
bool failed() const {
......@@ -676,6 +675,8 @@ class CompilationStateImpl {
//////////////////////////////////////////////////////////////////////////////
// Protected by {mutex_}:
bool has_priority_ = false;
std::shared_ptr<JobHandle> current_compile_job_;
// Features detected to be used in this module. Features can be detected
......@@ -798,6 +799,8 @@ void CompilationState::WaitForTopTierFinished() {
top_tier_finished_semaphore->Wait();
}
void CompilationState::SetHighPriority() { Impl(this)->SetHighPriority(); }
void CompilationState::InitializeAfterDeserialization() {
Impl(this)->InitializeCompilationProgressAfterDeserialization();
}
......@@ -1635,6 +1638,8 @@ std::shared_ptr<NativeModule> CompileToNativeModule(
native_module = isolate->wasm_engine()->NewNativeModule(
isolate, enabled, module, code_size_estimate);
native_module->SetWireBytes(std::move(wire_bytes_copy));
// Sync compilation is user blocking, so we increase the priority.
native_module->compilation_state()->SetHighPriority();
v8::metrics::Recorder::ContextId context_id =
isolate->GetOrRegisterRecorderContextId(isolate->native_context());
......@@ -2714,13 +2719,7 @@ CompilationStateImpl::CompilationStateImpl(
? CompileMode::kTiering
: CompileMode::kRegular),
async_counters_(std::move(async_counters)),
compilation_unit_queues_(native_module->num_functions()) {
AddCallback([&](CompilationEvent event) {
if (event == CompilationEvent::kFinishedBaselineCompilation) {
ReduceCompilationPriority();
}
});
}
compilation_unit_queues_(native_module->num_functions()) {}
void CompilationStateImpl::CancelCompilation() {
// No more callbacks after abort.
......@@ -3242,9 +3241,15 @@ void CompilationStateImpl::ScheduleCompileJobForNewUnits() {
std::unique_ptr<JobTask> new_compile_job =
std::make_unique<BackgroundCompileJob>(native_module_weak_,
async_counters_);
// TODO(wasm): Lower priority for TurboFan-only jobs.
new_job_handle = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserBlocking, std::move(new_compile_job));
has_priority_ ? TaskPriority::kUserBlocking
: TaskPriority::kUserVisible,
std::move(new_compile_job));
current_compile_job_ = new_job_handle;
// Reset the priority. Later uses of the compilation state, e.g. for
// debugging, should compile with the default priority again.
has_priority_ = false;
}
if (new_job_handle) {
......@@ -3367,7 +3372,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
auto job = std::make_unique<CompileJSToWasmWrapperJob>(
&queue, &compilation_units, max_concurrency);
auto job_handle = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserBlocking, std::move(job));
TaskPriority::kUserVisible, std::move(job));
// Wait for completion, while contributing to the work.
job_handle->Join();
......
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