Commit a29a6e8e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm][cleanup] Always enable throttling

Throttling of background compilation tasks is enabled in all paths
anyway (async compilation, parallel compilation). Hence remove the bool
to control that.

R=ahaas@chromium.org

Change-Id: Id5d4de38d22e1eb63c8864f41c219f4dd28429e0
Reviewed-on: https://chromium-review.googlesource.com/1002814
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52482}
parent 040a0ab4
...@@ -84,15 +84,12 @@ class CompilationState { ...@@ -84,15 +84,12 @@ class CompilationState {
bool ShouldIncreaseWorkload() const; bool ShouldIncreaseWorkload() const;
void EnableThrottling() { throttle_ = true; }
private: private:
size_t GetRandomIndexInSchedule(); size_t GetRandomIndexInSchedule();
base::RandomNumberGenerator* random_number_generator_ = nullptr; base::RandomNumberGenerator* random_number_generator_ = nullptr;
std::vector<std::unique_ptr<compiler::WasmCompilationUnit>> schedule_; std::vector<std::unique_ptr<compiler::WasmCompilationUnit>> schedule_;
const size_t max_memory_; const size_t max_memory_;
bool throttle_ = false;
size_t allocated_memory_ = 0; size_t allocated_memory_ = 0;
}; };
...@@ -126,7 +123,6 @@ class CompilationState { ...@@ -126,7 +123,6 @@ class CompilationState {
void ScheduleFinisherTask(); void ScheduleFinisherTask();
bool CanAcceptWork() const; bool CanAcceptWork() const;
void EnableThrottling();
void Abort(); void Abort();
...@@ -987,7 +983,6 @@ void CompileInParallel(Isolate* isolate, NativeModule* native_module, ...@@ -987,7 +983,6 @@ void CompileInParallel(Isolate* isolate, NativeModule* native_module,
CanonicalHandleScope canonical(isolate); CanonicalHandleScope canonical(isolate);
CompilationState* compilation_state = native_module->compilation_state(); CompilationState* compilation_state = native_module->compilation_state();
compilation_state->EnableThrottling();
// Make sure that no foreground task is spawned for finishing // Make sure that no foreground task is spawned for finishing
// the compilation units. This foreground thread will be // the compilation units. This foreground thread will be
// responsible for finishing compilation. // responsible for finishing compilation.
...@@ -2660,9 +2655,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -2660,9 +2655,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
job_->compiled_module_ = NewCompiledModule( job_->compiled_module_ = NewCompiledModule(
job_->isolate_, module_, export_wrappers, job_->module_env_.get()); job_->isolate_, module_, export_wrappers, job_->module_env_.get());
job_->compiled_module_->GetNativeModule()
->compilation_state()
->EnableThrottling();
{ {
DeferredHandleScope deferred(job_->isolate_); DeferredHandleScope deferred(job_->isolate_);
...@@ -3017,12 +3009,12 @@ void CompilationState::CodeGenerationSchedule::Schedule( ...@@ -3017,12 +3009,12 @@ void CompilationState::CodeGenerationSchedule::Schedule(
} }
bool CompilationState::CodeGenerationSchedule::CanAcceptWork() const { bool CompilationState::CodeGenerationSchedule::CanAcceptWork() const {
return !throttle_ || allocated_memory_ <= max_memory_; return allocated_memory_ <= max_memory_;
} }
bool CompilationState::CodeGenerationSchedule::ShouldIncreaseWorkload() const { bool CompilationState::CodeGenerationSchedule::ShouldIncreaseWorkload() const {
// Half the memory is unused again, we can increase the workload again. // Half the memory is unused again, we can increase the workload again.
return !throttle_ || allocated_memory_ <= max_memory_ / 2; return allocated_memory_ <= max_memory_ / 2;
} }
std::unique_ptr<compiler::WasmCompilationUnit> std::unique_ptr<compiler::WasmCompilationUnit>
...@@ -3210,11 +3202,6 @@ bool CompilationState::CanAcceptWork() const { ...@@ -3210,11 +3202,6 @@ bool CompilationState::CanAcceptWork() const {
return executed_units_.CanAcceptWork(); return executed_units_.CanAcceptWork();
} }
void CompilationState::EnableThrottling() {
base::LockGuard<base::Mutex> guard(&mutex_);
executed_units_.EnableThrottling();
}
void CompilationState::Abort() { void CompilationState::Abort() {
{ {
base::LockGuard<base::Mutex> guard(&mutex_); base::LockGuard<base::Mutex> guard(&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