Commit 8e143a2b authored by Daniel Lehmann's avatar Daniel Lehmann Committed by V8 LUCI CQ

[wasm] Always publish TurboFan units in batches

So far, units compiled with TurboFan were published one-by-one as soon
as they were ready, which reduces the latency until the faster code is
available. However, especially when write-protecting code with mprotect,
this yielded a lot of page protection switches, which incurs syscall and
lock contention overhead. Thus, https://crrev.com/c/2922114 already
introduced TurboFan batching when using write-protection.

During experiments, we found this could even be beneficial in the
default configuration, i.e., without write-protection enabled. This CL
changes to always do the publishing in batches. This choice should be
revisited once the tier-up strategy changes, e.g., with lazy compilation
or dynamic tier-up.

R=clemensb@chromium.org
CC=​​​​jkummerow@chromium.org

Change-Id: I0ba792c969f7e017ac57103d2bbfe9a142cf302d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2928186Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Daniel Lehmann <dlehmann@google.com>
Cr-Commit-Position: refs/heads/master@{#74871}
parent 8ff87ecc
......@@ -1347,21 +1347,12 @@ CompilationExecutionResult ExecuteCompilationUnits(
// when all threads publish at the end.
bool batch_full =
queue->ShouldPublish(static_cast<int>(results_to_publish.size()));
// Also publish each time the compilation tier changes from Liftoff to
// TurboFan, such that we immediately publish the baseline compilation
// results to start execution, and do not wait for a batch to fill up.
bool liftoff_finished = unit->tier() != current_tier &&
unit->tier() == ExecutionTier::kTurbofan;
// Without mprotect-based write protection, publish even more often,
// namely every TurboFan unit individually (no batching) to reduce
// peak memory consumption. However, with write protection, this results
// in a high number of page protection switches (once for each function),
// incurring syscalls and lock contention, so don't do it then.
bool publish_turbofan_unit = !FLAG_wasm_write_protect_code_memory &&
unit->tier() == ExecutionTier::kTurbofan;
if (batch_full || liftoff_finished || publish_turbofan_unit) {
if (batch_full || liftoff_finished) {
std::vector<std::unique_ptr<WasmCode>> unpublished_code =
compile_scope.native_module()->AddCompiledCode(
VectorOf(std::move(results_to_publish)));
......
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