Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LockTiming::waitingForOtherIsolate() #95

Merged
merged 1 commit into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/workerd/io/observer.h
Expand Up @@ -109,6 +109,10 @@ class IsolateObserver: public kj::AtomicRefcounted {

class LockTiming {
public:
virtual void waitingForOtherIsolate(kj::StringPtr id) {}
// Called by `Isolate::takeAsyncLock()` when it is blocked by a different isolate lock on the
// same thread.

virtual void reportAsyncInfo(uint currentLoad, bool threadWaitingSameLock,
uint threadWaitingDifferentLockCount) {}
// Call if this is an async lock attempt, before constructing LockRecord.
Expand Down
3 changes: 3 additions & 0 deletions src/workerd/io/worker.c++
Expand Up @@ -1780,6 +1780,9 @@ kj::Promise<Worker::AsyncLock> Worker::Isolate::takeAsyncLockImpl(
// be released before we try to lock a different isolate.
// TODO(perf): Use of ForkedPromise leads to thundering herd here. Should be minor in practice,
// but we could consider creating another linked list instead...
KJ_IF_MAYBE(lt, lockTiming) {
lt->get()->waitingForOtherIsolate(waiter->isolate->getId());
}
co_await waiter->releasePromise.addBranch();
}
}
Expand Down