[wasm] Speed up waiting for events
In many cases, the event we are waiting for already happened. In that case, entering the {ExecuteCompilationUnits} function creates significant overhead. This CL fixes this by just checking whether the event we are waiting for already happened, and returning early in that case. This should restore the original performance before https://crrev.com/c/2351671. R=thibaudm@chromium.org Bug: v8:10922 Change-Id: I5229808162a3b348bbbb067bd10065894c8a655c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2414028 Reviewed-by: Thibaud Michaud <thibaudm@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#69976}
This commit is contained in:
parent
baad346049
commit
d88568eb3e
@ -3268,13 +3268,16 @@ void CompilationStateImpl::SetError() {
|
|||||||
void CompilationStateImpl::WaitForCompilationEvent(
|
void CompilationStateImpl::WaitForCompilationEvent(
|
||||||
CompilationEvent expect_event) {
|
CompilationEvent expect_event) {
|
||||||
auto compilation_event_semaphore = std::make_shared<base::Semaphore>(0);
|
auto compilation_event_semaphore = std::make_shared<base::Semaphore>(0);
|
||||||
AddCallback(
|
base::EnumSet<CompilationEvent> events{expect_event,
|
||||||
[compilation_event_semaphore, expect_event](CompilationEvent event) {
|
CompilationEvent::kFailedCompilation};
|
||||||
if (event == expect_event ||
|
{
|
||||||
event == CompilationEvent::kFailedCompilation) {
|
base::MutexGuard callbacks_guard(&callbacks_mutex_);
|
||||||
compilation_event_semaphore->Signal();
|
if (finished_events_.contains_any(events)) return;
|
||||||
}
|
callbacks_.emplace_back(
|
||||||
});
|
[compilation_event_semaphore, events](CompilationEvent event) {
|
||||||
|
if (events.contains(event)) compilation_event_semaphore->Signal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
constexpr JobDelegate* kNoDelegate = nullptr;
|
constexpr JobDelegate* kNoDelegate = nullptr;
|
||||||
ExecuteCompilationUnits(background_compile_token_, async_counters_.get(),
|
ExecuteCompilationUnits(background_compile_token_, async_counters_.get(),
|
||||||
|
Loading…
Reference in New Issue
Block a user