Skip to content

Commit

Permalink
remove cond var entirely
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Liang <ekhliang@gmail.com>
  • Loading branch information
ericl committed Dec 20, 2023
1 parent 9923a3d commit dd5558e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 22 deletions.
1 change: 0 additions & 1 deletion python/ray/experimental/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Optional

import ray
from ray.exceptions import RaySystemError
from ray.util.annotations import PublicAPI

# Logger for this module. It should be configured at the entry point
Expand Down
19 changes: 0 additions & 19 deletions src/ray/object_manager/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,12 @@ void PlasmaObjectHeader::Init() {
pthread_mutex_init(&wr_mut, &mutex_attr);

sem_init(&rw_semaphore, PTHREAD_PROCESS_SHARED, 1);

// Condition is shared between writer and readers.
pthread_condattr_t cond_attr;
pthread_condattr_init(&cond_attr);
pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED);
pthread_cond_init(&cond, &cond_attr);
#endif
}

void PlasmaObjectHeader::Destroy() {
#ifdef __linux__
RAY_CHECK(pthread_mutex_destroy(&wr_mut) == 0);
RAY_CHECK(pthread_cond_destroy(&cond) == 0);
RAY_CHECK(sem_destroy(&rw_semaphore) == 0);
#endif
}
Expand Down Expand Up @@ -119,8 +112,6 @@ Status PlasmaObjectHeader::WriteRelease() {
RAY_LOG(DEBUG) << "WriteRelease done, num_readers: " << num_readers;
PrintPlasmaObjectHeader(this);
RAY_CHECK(pthread_mutex_unlock(&wr_mut) == 0);
// Signal to all readers.
RAY_CHECK(pthread_cond_broadcast(&cond) == 0);
return Status::OK();
}

Expand All @@ -140,14 +131,6 @@ Status PlasmaObjectHeader::ReadAcquire(int64_t version_to_read, int64_t *version
std::this_thread::yield(); // Too many tries, yield thread.
}
RAY_RETURN_NOT_OK(TryAcquireWriterMutex());
// TODO(ekl) this doesn't work since it requires re-acquiring the mutex regardless of
// timeout
// // Try to do a cond wait, checking every 1s for the error bit.
// struct timespec ts;
// do {
// clock_gettime(CLOCK_REALTIME, &ts);
// ts.tv_sec += 1;
// } while (pthread_cond_timedwait(&cond, &wr_mut, &ts));
}

bool success = false;
Expand Down Expand Up @@ -175,8 +158,6 @@ Status PlasmaObjectHeader::ReadAcquire(int64_t version_to_read, int64_t *version
PrintPlasmaObjectHeader(this);

RAY_CHECK(pthread_mutex_unlock(&wr_mut) == 0);
// Signal to other readers that they may read.
RAY_CHECK(pthread_cond_signal(&cond) == 0);
if (!success) {
return Status::Invalid(
"Reader missed a value. Are you sure there are num_readers many readers?");
Expand Down
2 changes: 0 additions & 2 deletions src/ray/object_manager/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ struct PlasmaObjectHeader {

// Protects all following state, used to signal from writer to readers.
pthread_mutex_t wr_mut;
// Used to signal to readers when the writer is done writing a new version.
pthread_cond_t cond;
// The object version. For immutable objects, this gets incremented to 1 on
// the first write and then should never be modified. For mutable objects,
// each new write must increment the version before releasing to readers.
Expand Down

0 comments on commit dd5558e

Please sign in to comment.