Skip to content

Commit

Permalink
Remove unnecessary code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcho committed Nov 22, 2023
1 parent 13a267e commit 6ed6213
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 45 deletions.
10 changes: 1 addition & 9 deletions python/ray/_raylet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,6 @@ cdef c_bool is_plasma_object(shared_ptr[CRayObject] obj):

cdef RayObjectsToDataMetadataPairs(
const c_vector[shared_ptr[CRayObject]] objects):
cdef:
shared_ptr[CBuffer] c_data

data_metadata_pairs = []
for i in range(objects.size()):
# core_worker will return a nullptr for objects that couldn't be
Expand All @@ -492,12 +489,7 @@ cdef RayObjectsToDataMetadataPairs(
data = None
metadata = None
if objects[i].get().HasData():
c_data = objects[i].get().GetData()
# Slice the data based on the size if needed.
#if c_data.get().IsPlasmaBuffer():
# LocalMemoryBuffer doesn't support slice.
#c_data = c_data.get().SliceBuffer(c_data, 0, objects[i].get().GetSize())
data = Buffer.make(c_data)
data = Buffer.make(objects[i].get().GetData())
if objects[i].get().HasMetadata():
metadata = Buffer.make(
objects[i].get().GetMetadata()).to_pybytes()
Expand Down
1 change: 0 additions & 1 deletion python/ray/includes/common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ cdef extern from "ray/common/buffer.h" namespace "ray" nogil:
uint8_t *Data() const
size_t Size() const
c_bool IsPlasmaBuffer() const
shared_ptr[CBuffer] SliceBuffer(const shared_ptr[CBuffer] &buffer, int64_t offset, int64_t size)

cdef cppclass LocalMemoryBuffer(CBuffer):
LocalMemoryBuffer(uint8_t *data, size_t size, c_bool copy_data)
Expand Down
11 changes: 0 additions & 11 deletions src/ray/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class Buffer {

virtual ~Buffer(){};

virtual std::shared_ptr<Buffer> SliceBuffer(const std::shared_ptr<Buffer> &buffer, int64_t offset, int64_t size) = 0;

bool operator==(const Buffer &rhs) const {
if (this->Size() != rhs.Size()) {
return false;
Expand Down Expand Up @@ -97,11 +95,6 @@ class LocalMemoryBuffer : public Buffer {

bool IsPlasmaBuffer() const override { return false; }

std::shared_ptr<Buffer> SliceBuffer(const std::shared_ptr<Buffer> &buffer, int64_t offset, int64_t size) override {
RAY_CHECK(false);
return std::make_shared<LocalMemoryBuffer>(size);
}

~LocalMemoryBuffer() {
size_ = 0;
if (buffer_ != NULL) {
Expand Down Expand Up @@ -155,10 +148,6 @@ class SharedMemoryBuffer : public Buffer {
return std::make_shared<SharedMemoryBuffer>(buffer, offset, size);
}

std::shared_ptr<Buffer> SliceBuffer(const std::shared_ptr<Buffer> &buffer, int64_t offset, int64_t size) override {
return std::make_shared<SharedMemoryBuffer>(buffer, offset, size);
}

uint8_t *Data() const override { return data_; }

size_t Size() const override { return size_; }
Expand Down
4 changes: 2 additions & 2 deletions src/ray/common/ray_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ namespace ray {

RayObject::RayObject(rpc::ErrorType error_type, const rpc::RayErrorInfo *ray_error_info) {
if (ray_error_info == nullptr) {
Init(nullptr, MakeErrorMetadataBuffer(error_type), {}, static_cast<uint64_t>(0));
Init(nullptr, MakeErrorMetadataBuffer(error_type), {});
return;
}

const auto error_buffer = MakeSerializedErrorBuffer<rpc::RayErrorInfo>(*ray_error_info);
Init(std::move(error_buffer), MakeErrorMetadataBuffer(error_type), {}, static_cast<uint64_t>(0));
Init(std::move(error_buffer), MakeErrorMetadataBuffer(error_type), {});
return;
}

Expand Down
10 changes: 1 addition & 9 deletions src/ray/common/ray_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class RayObject {
RayObject(const std::shared_ptr<Buffer> &data,
const std::shared_ptr<Buffer> &metadata,
const std::vector<rpc::ObjectReference> &nested_refs,
uint64_t size = 0,
bool copy_data = false) {
Init(data, metadata, nested_refs, size, copy_data);
Init(data, metadata, nested_refs, copy_data);
}

/// This constructor creates a ray object instance whose data will be generated
Expand Down Expand Up @@ -98,10 +97,6 @@ class RayObject {
const std::vector<rpc::ObjectReference> &GetNestedRefs() const { return nested_refs_; }

uint64_t GetSize() const {
if (size_) {
return size_;
}

uint64_t size = 0;
size += (data_ != nullptr) ? data_->Size() : 0;
size += (metadata_ != nullptr) ? metadata_->Size() : 0;
Expand Down Expand Up @@ -134,14 +129,12 @@ class RayObject {
void Init(const std::shared_ptr<Buffer> &data,
const std::shared_ptr<Buffer> &metadata,
const std::vector<rpc::ObjectReference> &nested_refs,
uint64_t size,
bool copy_data = false) {
data_ = data;
metadata_ = metadata;
nested_refs_ = nested_refs;
has_data_copy_ = copy_data;
creation_time_nanos_ = absl::GetCurrentTimeNanos();
size_ = size;

if (has_data_copy_) {
// If this object is required to hold a copy of the data,
Expand Down Expand Up @@ -173,7 +166,6 @@ class RayObject {
bool accessed_ = false;
/// The timestamp at which this object was created locally.
int64_t creation_time_nanos_;
uint64_t size_;
};

} // namespace ray
4 changes: 2 additions & 2 deletions src/ray/core_worker/store_provider/plasma_store_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Status CoreWorkerPlasmaStoreProvider::FetchAndGetFromPlasmaStore(
// We track the set of active data buffers in active_buffers_. On destruction,
// the buffer entry will be removed from the set via callback.
data = std::make_shared<TrackedBuffer>(
plasma_results[i].data, buffer_tracker_, object_id, /*release_on_destruction*/true);
plasma_results[i].data, buffer_tracker_, object_id);
buffer_tracker_->Record(object_id, data.get(), get_current_call_site_());
}
if (plasma_results[i].metadata && plasma_results[i].metadata->Size()) {
Expand Down Expand Up @@ -240,7 +240,7 @@ Status CoreWorkerPlasmaStoreProvider::GetIfLocal(
// We track the set of active data buffers in active_buffers_. On destruction,
// the buffer entry will be removed from the set via callback.
data = std::make_shared<TrackedBuffer>(
plasma_results[i].data, buffer_tracker_, object_id, /*release_on_destruction*/true);
plasma_results[i].data, buffer_tracker_, object_id);
buffer_tracker_->Record(object_id, data.get(), get_current_call_site_());
}
if (plasma_results[i].metadata && plasma_results[i].metadata->Size()) {
Expand Down
13 changes: 2 additions & 11 deletions src/ray/core_worker/store_provider/plasma_store_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ class TrackedBuffer : public Buffer {
public:
TrackedBuffer(std::shared_ptr<Buffer> buffer,
const std::shared_ptr<BufferTracker> &tracker,
const ObjectID &object_id,
bool release_on_destruction)
: buffer_(buffer), tracker_(tracker), object_id_(object_id), release_on_destruction_(release_on_destruction) {}
const ObjectID &object_id)
: buffer_(buffer), tracker_(tracker), object_id_(object_id) {}

uint8_t *Data() const override { return buffer_->Data(); }

Expand All @@ -72,11 +71,6 @@ class TrackedBuffer : public Buffer {

bool IsPlasmaBuffer() const override { return true; }

std::shared_ptr<Buffer> SliceBuffer(const std::shared_ptr<Buffer> &buffer, int64_t offset, int64_t size) override {
/// Sliced buffers are not tracked.
return std::make_shared<TrackedBuffer>(buffer_->SliceBuffer(buffer_, offset, size), tracker_, object_id_, /*release_on_destruction*/false);
}

~TrackedBuffer() { tracker_->Release(object_id_, this); }


Expand All @@ -87,9 +81,6 @@ class TrackedBuffer : public Buffer {
std::shared_ptr<Buffer> buffer_;
std::shared_ptr<BufferTracker> tracker_;
ObjectID object_id_;
/// If true, destructor will release the buffer.
/// sliced buffer shouldn't be tracked, so this must be set false
bool release_on_destruction_;
};

/// The class provides implementations for accessing plasma store, which includes both
Expand Down

0 comments on commit 6ed6213

Please sign in to comment.