mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Lint plasma source files (#12171)
This commit is contained in:
parent
dfc796b8ec
commit
7bf5145d36
31 changed files with 758 additions and 720 deletions
|
@ -1 +0,0 @@
|
|||
DisableFormat: true
|
|
@ -73,13 +73,13 @@ struct GpuProcessHandle {
|
|||
// This is necessary as IPC handles can only be mapped once per process.
|
||||
// Thus if multiple clients in the same process get the same gpu object,
|
||||
// they need to access the same mapped CudaBuffer.
|
||||
std::unordered_map<ObjectID, GpuProcessHandle*> gpu_object_map;
|
||||
std::unordered_map<ObjectID, GpuProcessHandle *> gpu_object_map;
|
||||
std::mutex gpu_mutex;
|
||||
|
||||
// Return a new CudaBuffer pointing to the same data as the GpuProcessHandle,
|
||||
// but able to persist after the original IPC-backed buffer is closed
|
||||
// (ARROW-5924).
|
||||
std::shared_ptr<Buffer> MakeBufferFromGpuProcessHandle(GpuProcessHandle* handle) {
|
||||
std::shared_ptr<Buffer> MakeBufferFromGpuProcessHandle(GpuProcessHandle *handle) {
|
||||
return std::make_shared<CudaBuffer>(handle->ptr->address(), handle->ptr->size(),
|
||||
handle->ptr->context());
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ class RAY_NO_EXPORT PlasmaBuffer : public Buffer {
|
|||
public:
|
||||
~PlasmaBuffer();
|
||||
|
||||
PlasmaBuffer(std::shared_ptr<PlasmaClient::Impl> client, const ObjectID& object_id,
|
||||
const std::shared_ptr<Buffer>& buffer)
|
||||
PlasmaBuffer(std::shared_ptr<PlasmaClient::Impl> client, const ObjectID &object_id,
|
||||
const std::shared_ptr<Buffer> &buffer)
|
||||
: Buffer(buffer, 0, buffer->size()), client_(client), object_id_(object_id) {
|
||||
if (buffer->is_mutable()) {
|
||||
is_mutable_ = true;
|
||||
|
@ -115,7 +115,7 @@ class RAY_NO_EXPORT PlasmaBuffer : public Buffer {
|
|||
/// be called in the associated Seal call.
|
||||
class RAY_NO_EXPORT PlasmaMutableBuffer : public MutableBuffer {
|
||||
public:
|
||||
PlasmaMutableBuffer(std::shared_ptr<PlasmaClient::Impl> client, uint8_t* mutable_data,
|
||||
PlasmaMutableBuffer(std::shared_ptr<PlasmaClient::Impl> client, uint8_t *mutable_data,
|
||||
int64_t data_size)
|
||||
: MutableBuffer(mutable_data, data_size), client_(client) {}
|
||||
|
||||
|
@ -147,42 +147,42 @@ class PlasmaClient::Impl : public std::enable_shared_from_this<PlasmaClient::Imp
|
|||
|
||||
// PlasmaClient method implementations
|
||||
|
||||
Status Connect(const std::string& store_socket_name,
|
||||
const std::string& manager_socket_name, int release_delay = 0,
|
||||
Status Connect(const std::string &store_socket_name,
|
||||
const std::string &manager_socket_name, int release_delay = 0,
|
||||
int num_retries = -1);
|
||||
|
||||
Status SetClientOptions(const std::string& client_name, int64_t output_memory_quota);
|
||||
Status SetClientOptions(const std::string &client_name, int64_t output_memory_quota);
|
||||
|
||||
Status Create(const ObjectID& object_id, const ray::rpc::Address& owner_address,
|
||||
int64_t data_size, const uint8_t* metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer>* data, int device_num = 0,
|
||||
Status Create(const ObjectID &object_id, const ray::rpc::Address &owner_address,
|
||||
int64_t data_size, const uint8_t *metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer> *data, int device_num = 0,
|
||||
bool evict_if_full = true);
|
||||
|
||||
Status Get(const std::vector<ObjectID>& object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer>* object_buffers);
|
||||
Status Get(const std::vector<ObjectID> &object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer> *object_buffers);
|
||||
|
||||
Status Get(const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
ObjectBuffer* object_buffers);
|
||||
Status Get(const ObjectID *object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
ObjectBuffer *object_buffers);
|
||||
|
||||
Status Release(const ObjectID& object_id);
|
||||
Status Release(const ObjectID &object_id);
|
||||
|
||||
Status Contains(const ObjectID& object_id, bool* has_object);
|
||||
Status Contains(const ObjectID &object_id, bool *has_object);
|
||||
|
||||
Status Abort(const ObjectID& object_id);
|
||||
Status Abort(const ObjectID &object_id);
|
||||
|
||||
Status Seal(const ObjectID& object_id);
|
||||
Status Seal(const ObjectID &object_id);
|
||||
|
||||
Status Delete(const std::vector<ObjectID>& object_ids);
|
||||
Status Delete(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
Status Evict(int64_t num_bytes, int64_t& num_bytes_evicted);
|
||||
Status Evict(int64_t num_bytes, int64_t &num_bytes_evicted);
|
||||
|
||||
Status Refresh(const std::vector<ObjectID>& object_ids);
|
||||
Status Refresh(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
Status Disconnect();
|
||||
|
||||
std::string DebugString();
|
||||
|
||||
bool IsInUse(const ObjectID& object_id);
|
||||
bool IsInUse(const ObjectID &object_id);
|
||||
|
||||
int64_t store_capacity() { return store_capacity_; }
|
||||
|
||||
|
@ -193,23 +193,23 @@ class PlasmaClient::Impl : public std::enable_shared_from_this<PlasmaClient::Imp
|
|||
///
|
||||
/// \param store_fd File descriptor to fetch from the store.
|
||||
/// \return The pointer corresponding to store_fd.
|
||||
uint8_t* GetStoreFdAndMmap(MEMFD_TYPE store_fd, int64_t map_size);
|
||||
uint8_t *GetStoreFdAndMmap(MEMFD_TYPE store_fd, int64_t map_size);
|
||||
|
||||
/// This is a helper method for marking an object as unused by this client.
|
||||
///
|
||||
/// \param object_id The object ID we mark unused.
|
||||
/// \return The return status.
|
||||
Status MarkObjectUnused(const ObjectID& object_id);
|
||||
Status MarkObjectUnused(const ObjectID &object_id);
|
||||
|
||||
/// Common helper for Get() variants
|
||||
Status GetBuffers(const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
Status GetBuffers(const ObjectID *object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
const std::function<std::shared_ptr<Buffer>(
|
||||
const ObjectID&, const std::shared_ptr<Buffer>&)>& wrap_buffer,
|
||||
ObjectBuffer* object_buffers);
|
||||
const ObjectID &, const std::shared_ptr<Buffer> &)> &wrap_buffer,
|
||||
ObjectBuffer *object_buffers);
|
||||
|
||||
uint8_t* LookupMmappedFile(MEMFD_TYPE store_fd_val);
|
||||
uint8_t *LookupMmappedFile(MEMFD_TYPE store_fd_val);
|
||||
|
||||
void IncrementObjectCount(const ObjectID& object_id, PlasmaObject* object,
|
||||
void IncrementObjectCount(const ObjectID &object_id, PlasmaObject *object,
|
||||
bool is_sealed);
|
||||
|
||||
/// The boost::asio IO context for the client.
|
||||
|
@ -234,7 +234,7 @@ class PlasmaClient::Impl : public std::enable_shared_from_this<PlasmaClient::Imp
|
|||
|
||||
#ifdef PLASMA_CUDA
|
||||
/// Cuda Device Manager.
|
||||
arrow::cuda::CudaDeviceManager* manager_;
|
||||
arrow::cuda::CudaDeviceManager *manager_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -253,7 +253,8 @@ PlasmaClient::Impl::~Impl() {}
|
|||
// If the file descriptor fd has been mmapped in this client process before,
|
||||
// return the pointer that was returned by mmap, otherwise mmap it and store the
|
||||
// pointer in a hash table.
|
||||
uint8_t* PlasmaClient::Impl::GetStoreFdAndMmap(MEMFD_TYPE store_fd_val, int64_t map_size) {
|
||||
uint8_t *PlasmaClient::Impl::GetStoreFdAndMmap(MEMFD_TYPE store_fd_val,
|
||||
int64_t map_size) {
|
||||
auto entry = mmap_table_.find(store_fd_val);
|
||||
if (entry != mmap_table_.end()) {
|
||||
return entry->second->pointer();
|
||||
|
@ -268,25 +269,25 @@ uint8_t* PlasmaClient::Impl::GetStoreFdAndMmap(MEMFD_TYPE store_fd_val, int64_t
|
|||
|
||||
// Get a pointer to a file that we know has been memory mapped in this client
|
||||
// process before.
|
||||
uint8_t* PlasmaClient::Impl::LookupMmappedFile(MEMFD_TYPE store_fd_val) {
|
||||
uint8_t *PlasmaClient::Impl::LookupMmappedFile(MEMFD_TYPE store_fd_val) {
|
||||
auto entry = mmap_table_.find(store_fd_val);
|
||||
RAY_CHECK(entry != mmap_table_.end());
|
||||
return entry->second->pointer();
|
||||
}
|
||||
|
||||
bool PlasmaClient::Impl::IsInUse(const ObjectID& object_id) {
|
||||
bool PlasmaClient::Impl::IsInUse(const ObjectID &object_id) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
const auto elem = objects_in_use_.find(object_id);
|
||||
return (elem != objects_in_use_.end());
|
||||
}
|
||||
|
||||
void PlasmaClient::Impl::IncrementObjectCount(const ObjectID& object_id,
|
||||
PlasmaObject* object, bool is_sealed) {
|
||||
void PlasmaClient::Impl::IncrementObjectCount(const ObjectID &object_id,
|
||||
PlasmaObject *object, bool is_sealed) {
|
||||
// Increment the count of the object to track the fact that it is being used.
|
||||
// The corresponding decrement should happen in PlasmaClient::Release.
|
||||
auto elem = objects_in_use_.find(object_id);
|
||||
ObjectInUseEntry* object_entry;
|
||||
ObjectInUseEntry *object_entry;
|
||||
if (elem == objects_in_use_.end()) {
|
||||
// Add this object ID to the hash table of object IDs in use. The
|
||||
// corresponding call to free happens in PlasmaClient::Release.
|
||||
|
@ -306,16 +307,18 @@ void PlasmaClient::Impl::IncrementObjectCount(const ObjectID& object_id,
|
|||
object_entry->count += 1;
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Create(const ObjectID& object_id, const ray::rpc::Address& owner_address,
|
||||
int64_t data_size, const uint8_t* metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer>* data, int device_num,
|
||||
bool evict_if_full) {
|
||||
Status PlasmaClient::Impl::Create(const ObjectID &object_id,
|
||||
const ray::rpc::Address &owner_address,
|
||||
int64_t data_size, const uint8_t *metadata,
|
||||
int64_t metadata_size, std::shared_ptr<Buffer> *data,
|
||||
int device_num, bool evict_if_full) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
RAY_LOG(DEBUG) << "called plasma_create on conn " << store_conn_ << " with size "
|
||||
<< data_size << " and metadata size " << metadata_size;
|
||||
RAY_RETURN_NOT_OK(SendCreateRequest(store_conn_, object_id, owner_address, evict_if_full, data_size,
|
||||
metadata_size, device_num));
|
||||
<< data_size << " and metadata size " << metadata_size;
|
||||
RAY_RETURN_NOT_OK(SendCreateRequest(store_conn_, object_id, owner_address,
|
||||
evict_if_full, data_size, metadata_size,
|
||||
device_num));
|
||||
std::vector<uint8_t> buffer;
|
||||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaCreateReply, &buffer));
|
||||
ObjectID id;
|
||||
|
@ -345,7 +348,7 @@ Status PlasmaClient::Impl::Create(const ObjectID& object_id, const ray::rpc::Add
|
|||
#ifdef PLASMA_CUDA
|
||||
std::shared_ptr<CudaContext> context;
|
||||
ARROW_ASSIGN_OR_RAISE(context, manager_->GetContext(device_num - 1));
|
||||
GpuProcessHandle* handle = new GpuProcessHandle();
|
||||
GpuProcessHandle *handle = new GpuProcessHandle();
|
||||
handle->client_count = 2;
|
||||
ARROW_ASSIGN_OR_RAISE(handle->ptr, context->OpenIpcBuffer(*object.ipc_handle));
|
||||
{
|
||||
|
@ -376,10 +379,10 @@ Status PlasmaClient::Impl::Create(const ObjectID& object_id, const ray::rpc::Add
|
|||
}
|
||||
|
||||
Status PlasmaClient::Impl::GetBuffers(
|
||||
const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
const ObjectID *object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
const std::function<std::shared_ptr<Buffer>(
|
||||
const ObjectID&, const std::shared_ptr<Buffer>&)>& wrap_buffer,
|
||||
ObjectBuffer* object_buffers) {
|
||||
const ObjectID &, const std::shared_ptr<Buffer> &)> &wrap_buffer,
|
||||
ObjectBuffer *object_buffers) {
|
||||
// Fill out the info for the objects that are already in use locally.
|
||||
bool all_present = true;
|
||||
for (int64_t i = 0; i < num_objects; ++i) {
|
||||
|
@ -398,11 +401,11 @@ Status PlasmaClient::Impl::GetBuffers(
|
|||
<< "Attempting to get an object that this client created but hasn't sealed.";
|
||||
all_present = false;
|
||||
} else {
|
||||
PlasmaObject* object = &object_entry->second->object;
|
||||
PlasmaObject *object = &object_entry->second->object;
|
||||
std::shared_ptr<Buffer> physical_buf;
|
||||
|
||||
if (object->device_num == 0) {
|
||||
uint8_t* data = LookupMmappedFile(object->store_fd);
|
||||
uint8_t *data = LookupMmappedFile(object->store_fd);
|
||||
physical_buf = std::make_shared<Buffer>(
|
||||
data + object->data_offset, object->data_size + object->metadata_size);
|
||||
} else {
|
||||
|
@ -438,11 +441,11 @@ Status PlasmaClient::Impl::GetBuffers(
|
|||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaGetReply, &buffer));
|
||||
std::vector<ObjectID> received_object_ids(num_objects);
|
||||
std::vector<PlasmaObject> object_data(num_objects);
|
||||
PlasmaObject* object;
|
||||
PlasmaObject *object;
|
||||
std::vector<MEMFD_TYPE> store_fds;
|
||||
std::vector<int64_t> mmap_sizes;
|
||||
RAY_RETURN_NOT_OK(ReadGetReply(buffer.data(), buffer.size(), received_object_ids.data(),
|
||||
object_data.data(), num_objects, store_fds, mmap_sizes));
|
||||
object_data.data(), num_objects, store_fds, mmap_sizes));
|
||||
|
||||
// We mmap all of the file descriptors here so that we can avoid look them up
|
||||
// in the subsequent loop based on just the store file descriptor and without
|
||||
|
@ -467,7 +470,7 @@ Status PlasmaClient::Impl::GetBuffers(
|
|||
if (object->data_size != -1) {
|
||||
std::shared_ptr<Buffer> physical_buf;
|
||||
if (object->device_num == 0) {
|
||||
uint8_t* data = LookupMmappedFile(object->store_fd);
|
||||
uint8_t *data = LookupMmappedFile(object->store_fd);
|
||||
physical_buf = std::make_shared<Buffer>(
|
||||
data + object->data_offset, object->data_size + object->metadata_size);
|
||||
} else {
|
||||
|
@ -477,7 +480,7 @@ Status PlasmaClient::Impl::GetBuffers(
|
|||
if (iter == gpu_object_map.end()) {
|
||||
std::shared_ptr<CudaContext> context;
|
||||
ARROW_ASSIGN_OR_RAISE(context, manager_->GetContext(object->device_num - 1));
|
||||
GpuProcessHandle* obj_handle = new GpuProcessHandle();
|
||||
GpuProcessHandle *obj_handle = new GpuProcessHandle();
|
||||
obj_handle->client_count = 1;
|
||||
ARROW_ASSIGN_OR_RAISE(obj_handle->ptr,
|
||||
context->OpenIpcBuffer(*object->ipc_handle));
|
||||
|
@ -510,12 +513,12 @@ Status PlasmaClient::Impl::GetBuffers(
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Get(const std::vector<ObjectID>& object_ids,
|
||||
int64_t timeout_ms, std::vector<ObjectBuffer>* out) {
|
||||
Status PlasmaClient::Impl::Get(const std::vector<ObjectID> &object_ids,
|
||||
int64_t timeout_ms, std::vector<ObjectBuffer> *out) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
const auto wrap_buffer = [=](const ObjectID& object_id,
|
||||
const std::shared_ptr<Buffer>& buffer) {
|
||||
const auto wrap_buffer = [=](const ObjectID &object_id,
|
||||
const std::shared_ptr<Buffer> &buffer) {
|
||||
return std::make_shared<PlasmaBuffer>(shared_from_this(), object_id, buffer);
|
||||
};
|
||||
const size_t num_objects = object_ids.size();
|
||||
|
@ -523,16 +526,16 @@ Status PlasmaClient::Impl::Get(const std::vector<ObjectID>& object_ids,
|
|||
return GetBuffers(&object_ids[0], num_objects, timeout_ms, wrap_buffer, &(*out)[0]);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Get(const ObjectID* object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms, ObjectBuffer* out) {
|
||||
Status PlasmaClient::Impl::Get(const ObjectID *object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms, ObjectBuffer *out) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
const auto wrap_buffer = [](const ObjectID& object_id,
|
||||
const std::shared_ptr<Buffer>& buffer) { return buffer; };
|
||||
const auto wrap_buffer = [](const ObjectID &object_id,
|
||||
const std::shared_ptr<Buffer> &buffer) { return buffer; };
|
||||
return GetBuffers(object_ids, num_objects, timeout_ms, wrap_buffer, out);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::MarkObjectUnused(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Impl::MarkObjectUnused(const ObjectID &object_id) {
|
||||
auto object_entry = objects_in_use_.find(object_id);
|
||||
RAY_CHECK(object_entry != objects_in_use_.end());
|
||||
RAY_CHECK(object_entry->second->count == 0);
|
||||
|
@ -542,7 +545,7 @@ Status PlasmaClient::Impl::MarkObjectUnused(const ObjectID& object_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Release(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Impl::Release(const ObjectID &object_id) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
// If the client is already disconnected, ignore release requests.
|
||||
|
@ -581,7 +584,7 @@ Status PlasmaClient::Impl::Release(const ObjectID& object_id) {
|
|||
}
|
||||
|
||||
// This method is used to query whether the plasma store contains an object.
|
||||
Status PlasmaClient::Impl::Contains(const ObjectID& object_id, bool* has_object) {
|
||||
Status PlasmaClient::Impl::Contains(const ObjectID &object_id, bool *has_object) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
// Check if we already have a reference to the object.
|
||||
|
@ -592,7 +595,8 @@ Status PlasmaClient::Impl::Contains(const ObjectID& object_id, bool* has_object)
|
|||
// to see if we have the object.
|
||||
RAY_RETURN_NOT_OK(SendContainsRequest(store_conn_, object_id));
|
||||
std::vector<uint8_t> buffer;
|
||||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaContainsReply, &buffer));
|
||||
RAY_RETURN_NOT_OK(
|
||||
PlasmaReceive(store_conn_, MessageType::PlasmaContainsReply, &buffer));
|
||||
ObjectID object_id2;
|
||||
RAY_DCHECK(buffer.size() > 0);
|
||||
RAY_RETURN_NOT_OK(
|
||||
|
@ -601,7 +605,7 @@ Status PlasmaClient::Impl::Contains(const ObjectID& object_id, bool* has_object)
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Seal(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Impl::Seal(const ObjectID &object_id) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
// Make sure this client has a reference to the object before sending the
|
||||
|
@ -609,12 +613,10 @@ Status PlasmaClient::Impl::Seal(const ObjectID& object_id) {
|
|||
auto object_entry = objects_in_use_.find(object_id);
|
||||
|
||||
if (object_entry == objects_in_use_.end()) {
|
||||
return Status::ObjectNotFound(
|
||||
"Seal() called on an object without a reference to it");
|
||||
return Status::ObjectNotFound("Seal() called on an object without a reference to it");
|
||||
}
|
||||
if (object_entry->second->is_sealed) {
|
||||
return Status::ObjectAlreadySealed(
|
||||
"Seal() called on an already sealed object");
|
||||
return Status::ObjectAlreadySealed("Seal() called on an already sealed object");
|
||||
}
|
||||
|
||||
object_entry->second->is_sealed = true;
|
||||
|
@ -633,7 +635,7 @@ Status PlasmaClient::Impl::Seal(const ObjectID& object_id) {
|
|||
return Release(object_id);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Abort(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Impl::Abort(const ObjectID &object_id) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
auto object_entry = objects_in_use_.find(object_id);
|
||||
RAY_CHECK(object_entry != objects_in_use_.end())
|
||||
|
@ -671,11 +673,11 @@ Status PlasmaClient::Impl::Abort(const ObjectID& object_id) {
|
|||
return ReadAbortReply(buffer.data(), buffer.size(), &id);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Delete(const std::vector<ObjectID>& object_ids) {
|
||||
Status PlasmaClient::Impl::Delete(const std::vector<ObjectID> &object_ids) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
std::vector<ObjectID> not_in_use_ids;
|
||||
for (auto& object_id : object_ids) {
|
||||
for (auto &object_id : object_ids) {
|
||||
// If the object is in used, skip it.
|
||||
if (objects_in_use_.count(object_id) == 0) {
|
||||
not_in_use_ids.push_back(object_id);
|
||||
|
@ -686,7 +688,8 @@ Status PlasmaClient::Impl::Delete(const std::vector<ObjectID>& object_ids) {
|
|||
if (not_in_use_ids.size() > 0) {
|
||||
RAY_RETURN_NOT_OK(SendDeleteRequest(store_conn_, not_in_use_ids));
|
||||
std::vector<uint8_t> buffer;
|
||||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaDeleteReply, &buffer));
|
||||
RAY_RETURN_NOT_OK(
|
||||
PlasmaReceive(store_conn_, MessageType::PlasmaDeleteReply, &buffer));
|
||||
RAY_DCHECK(buffer.size() > 0);
|
||||
std::vector<PlasmaError> error_codes;
|
||||
not_in_use_ids.clear();
|
||||
|
@ -696,7 +699,7 @@ Status PlasmaClient::Impl::Delete(const std::vector<ObjectID>& object_ids) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Evict(int64_t num_bytes, int64_t& num_bytes_evicted) {
|
||||
Status PlasmaClient::Impl::Evict(int64_t num_bytes, int64_t &num_bytes_evicted) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
// Send a request to the store to evict objects.
|
||||
|
@ -707,17 +710,18 @@ Status PlasmaClient::Impl::Evict(int64_t num_bytes, int64_t& num_bytes_evicted)
|
|||
return ReadEvictReply(buffer.data(), buffer.size(), num_bytes_evicted);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Refresh(const std::vector<ObjectID>& object_ids) {
|
||||
Status PlasmaClient::Impl::Refresh(const std::vector<ObjectID> &object_ids) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
RAY_RETURN_NOT_OK(SendRefreshLRURequest(store_conn_, object_ids));
|
||||
std::vector<uint8_t> buffer;
|
||||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaRefreshLRUReply, &buffer));
|
||||
RAY_RETURN_NOT_OK(
|
||||
PlasmaReceive(store_conn_, MessageType::PlasmaRefreshLRUReply, &buffer));
|
||||
return ReadRefreshLRUReply(buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::Connect(const std::string& store_socket_name,
|
||||
const std::string& manager_socket_name,
|
||||
Status PlasmaClient::Impl::Connect(const std::string &store_socket_name,
|
||||
const std::string &manager_socket_name,
|
||||
int release_delay, int num_retries) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
|
||||
|
@ -733,12 +737,13 @@ Status PlasmaClient::Impl::Connect(const std::string& store_socket_name,
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status PlasmaClient::Impl::SetClientOptions(const std::string& client_name,
|
||||
Status PlasmaClient::Impl::SetClientOptions(const std::string &client_name,
|
||||
int64_t output_memory_quota) {
|
||||
std::lock_guard<std::recursive_mutex> guard(client_mutex_);
|
||||
RAY_RETURN_NOT_OK(SendSetOptionsRequest(store_conn_, client_name, output_memory_quota));
|
||||
std::vector<uint8_t> buffer;
|
||||
RAY_RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType::PlasmaSetOptionsReply, &buffer));
|
||||
RAY_RETURN_NOT_OK(
|
||||
PlasmaReceive(store_conn_, MessageType::PlasmaSetOptionsReply, &buffer));
|
||||
return ReadSetOptionsReply(buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
|
@ -778,61 +783,62 @@ PlasmaClient::PlasmaClient() : impl_(std::make_shared<PlasmaClient::Impl>()) {}
|
|||
|
||||
PlasmaClient::~PlasmaClient() {}
|
||||
|
||||
Status PlasmaClient::Connect(const std::string& store_socket_name,
|
||||
const std::string& manager_socket_name, int release_delay,
|
||||
Status PlasmaClient::Connect(const std::string &store_socket_name,
|
||||
const std::string &manager_socket_name, int release_delay,
|
||||
int num_retries) {
|
||||
return impl_->Connect(store_socket_name, manager_socket_name, release_delay,
|
||||
num_retries);
|
||||
}
|
||||
|
||||
Status PlasmaClient::SetClientOptions(const std::string& client_name,
|
||||
Status PlasmaClient::SetClientOptions(const std::string &client_name,
|
||||
int64_t output_memory_quota) {
|
||||
return impl_->SetClientOptions(client_name, output_memory_quota);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Create(const ObjectID& object_id, const ray::rpc::Address& owner_address, int64_t data_size,
|
||||
const uint8_t* metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer>* data, int device_num,
|
||||
Status PlasmaClient::Create(const ObjectID &object_id,
|
||||
const ray::rpc::Address &owner_address, int64_t data_size,
|
||||
const uint8_t *metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer> *data, int device_num,
|
||||
bool evict_if_full) {
|
||||
return impl_->Create(object_id, owner_address, data_size, metadata, metadata_size, data, device_num,
|
||||
evict_if_full);
|
||||
return impl_->Create(object_id, owner_address, data_size, metadata, metadata_size, data,
|
||||
device_num, evict_if_full);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Get(const std::vector<ObjectID>& object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer>* object_buffers) {
|
||||
Status PlasmaClient::Get(const std::vector<ObjectID> &object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer> *object_buffers) {
|
||||
return impl_->Get(object_ids, timeout_ms, object_buffers);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Get(const ObjectID* object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms, ObjectBuffer* object_buffers) {
|
||||
Status PlasmaClient::Get(const ObjectID *object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms, ObjectBuffer *object_buffers) {
|
||||
return impl_->Get(object_ids, num_objects, timeout_ms, object_buffers);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Release(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Release(const ObjectID &object_id) {
|
||||
return impl_->Release(object_id);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Contains(const ObjectID& object_id, bool* has_object) {
|
||||
Status PlasmaClient::Contains(const ObjectID &object_id, bool *has_object) {
|
||||
return impl_->Contains(object_id, has_object);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Abort(const ObjectID& object_id) { return impl_->Abort(object_id); }
|
||||
Status PlasmaClient::Abort(const ObjectID &object_id) { return impl_->Abort(object_id); }
|
||||
|
||||
Status PlasmaClient::Seal(const ObjectID& object_id) { return impl_->Seal(object_id); }
|
||||
Status PlasmaClient::Seal(const ObjectID &object_id) { return impl_->Seal(object_id); }
|
||||
|
||||
Status PlasmaClient::Delete(const ObjectID& object_id) {
|
||||
Status PlasmaClient::Delete(const ObjectID &object_id) {
|
||||
return impl_->Delete(std::vector<ObjectID>{object_id});
|
||||
}
|
||||
|
||||
Status PlasmaClient::Delete(const std::vector<ObjectID>& object_ids) {
|
||||
Status PlasmaClient::Delete(const std::vector<ObjectID> &object_ids) {
|
||||
return impl_->Delete(object_ids);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Evict(int64_t num_bytes, int64_t& num_bytes_evicted) {
|
||||
Status PlasmaClient::Evict(int64_t num_bytes, int64_t &num_bytes_evicted) {
|
||||
return impl_->Evict(num_bytes, num_bytes_evicted);
|
||||
}
|
||||
|
||||
Status PlasmaClient::Refresh(const std::vector<ObjectID>& object_ids) {
|
||||
Status PlasmaClient::Refresh(const std::vector<ObjectID> &object_ids) {
|
||||
return impl_->Refresh(object_ids);
|
||||
}
|
||||
|
||||
|
@ -840,7 +846,7 @@ Status PlasmaClient::Disconnect() { return impl_->Disconnect(); }
|
|||
|
||||
std::string PlasmaClient::DebugString() { return impl_->DebugString(); }
|
||||
|
||||
bool PlasmaClient::IsInUse(const ObjectID& object_id) {
|
||||
bool PlasmaClient::IsInUse(const ObjectID &object_id) {
|
||||
return impl_->IsInUse(object_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class RAY_EXPORT PlasmaClient {
|
|||
/// \param release_delay Deprecated (not used).
|
||||
/// \param num_retries number of attempts to connect to IPC socket, default 50
|
||||
/// \return The return status.
|
||||
Status Connect(const std::string& store_socket_name,
|
||||
const std::string& manager_socket_name = "", int release_delay = 0,
|
||||
Status Connect(const std::string &store_socket_name,
|
||||
const std::string &manager_socket_name = "", int release_delay = 0,
|
||||
int num_retries = -1);
|
||||
|
||||
/// Set runtime options for this client.
|
||||
|
@ -72,7 +72,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
/// \param client_name The name of the client, used in debug messages.
|
||||
/// \param output_memory_quota The memory quota in bytes for objects created by
|
||||
/// this client.
|
||||
Status SetClientOptions(const std::string& client_name, int64_t output_memory_quota);
|
||||
Status SetClientOptions(const std::string &client_name, int64_t output_memory_quota);
|
||||
|
||||
/// Create an object in the Plasma Store. Any metadata for this object must be
|
||||
/// be passed in when the object is created.
|
||||
|
@ -99,9 +99,9 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// The returned object must be released once it is done with. It must also
|
||||
/// be either sealed or aborted.
|
||||
Status Create(const ObjectID& object_id, const ray::rpc::Address& owner_address,
|
||||
int64_t data_size, const uint8_t* metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer>* data, int device_num = 0,
|
||||
Status Create(const ObjectID &object_id, const ray::rpc::Address &owner_address,
|
||||
int64_t data_size, const uint8_t *metadata, int64_t metadata_size,
|
||||
std::shared_ptr<Buffer> *data, int device_num = 0,
|
||||
bool evict_if_full = true);
|
||||
|
||||
/// Get some objects from the Plasma Store. This function will block until the
|
||||
|
@ -118,8 +118,8 @@ class RAY_EXPORT PlasmaClient {
|
|||
/// request times out. If this value is -1, then no timeout is set.
|
||||
/// \param[out] object_buffers The object results.
|
||||
/// \return The return status.
|
||||
Status Get(const std::vector<ObjectID>& object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer>* object_buffers);
|
||||
Status Get(const std::vector<ObjectID> &object_ids, int64_t timeout_ms,
|
||||
std::vector<ObjectBuffer> *object_buffers);
|
||||
|
||||
/// Deprecated variant of Get() that doesn't automatically release buffers
|
||||
/// when they get out of scope.
|
||||
|
@ -133,8 +133,8 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// The caller is responsible for releasing any retrieved objects, but it
|
||||
/// should not release objects that were not retrieved.
|
||||
Status Get(const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
ObjectBuffer* object_buffers);
|
||||
Status Get(const ObjectID *object_ids, int64_t num_objects, int64_t timeout_ms,
|
||||
ObjectBuffer *object_buffers);
|
||||
|
||||
/// Tell Plasma that the client no longer needs the object. This should be
|
||||
/// called after Get() or Create() when the client is done with the object.
|
||||
|
@ -142,7 +142,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// \param object_id The ID of the object that is no longer needed.
|
||||
/// \return The return status.
|
||||
Status Release(const ObjectID& object_id);
|
||||
Status Release(const ObjectID &object_id);
|
||||
|
||||
/// Check if the object store contains a particular object and the object has
|
||||
/// been sealed. The result will be stored in has_object.
|
||||
|
@ -154,7 +154,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
/// \param has_object The function will write true at this address if
|
||||
/// the object is present and false if it is not present.
|
||||
/// \return The return status.
|
||||
Status Contains(const ObjectID& object_id, bool* has_object);
|
||||
Status Contains(const ObjectID &object_id, bool *has_object);
|
||||
|
||||
/// Abort an unsealed object in the object store. If the abort succeeds, then
|
||||
/// it will be as if the object was never created at all. The unsealed object
|
||||
|
@ -163,7 +163,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// \param object_id The ID of the object to abort.
|
||||
/// \return The return status.
|
||||
Status Abort(const ObjectID& object_id);
|
||||
Status Abort(const ObjectID &object_id);
|
||||
|
||||
/// Seal an object in the object store. The object will be immutable after
|
||||
/// this
|
||||
|
@ -171,7 +171,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// \param object_id The ID of the object to seal.
|
||||
/// \return The return status.
|
||||
Status Seal(const ObjectID& object_id);
|
||||
Status Seal(const ObjectID &object_id);
|
||||
|
||||
/// Delete an object from the object store. This currently assumes that the
|
||||
/// object is present, has been sealed and not used by another client. Otherwise,
|
||||
|
@ -182,7 +182,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// \param object_id The ID of the object to delete.
|
||||
/// \return The return status.
|
||||
Status Delete(const ObjectID& object_id);
|
||||
Status Delete(const ObjectID &object_id);
|
||||
|
||||
/// Delete a list of objects from the object store. This currently assumes that the
|
||||
/// object is present, has been sealed and not used by another client. Otherwise,
|
||||
|
@ -190,7 +190,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
///
|
||||
/// \param object_ids The list of IDs of the objects to delete.
|
||||
/// \return The return status. If all the objects are non-existent, return OK.
|
||||
Status Delete(const std::vector<ObjectID>& object_ids);
|
||||
Status Delete(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
/// Delete objects until we have freed up num_bytes bytes or there are no more
|
||||
/// released objects that can be deleted.
|
||||
|
@ -199,14 +199,14 @@ class RAY_EXPORT PlasmaClient {
|
|||
/// \param num_bytes_evicted Out parameter for total number of bytes of space
|
||||
/// retrieved.
|
||||
/// \return The return status.
|
||||
Status Evict(int64_t num_bytes, int64_t& num_bytes_evicted);
|
||||
Status Evict(int64_t num_bytes, int64_t &num_bytes_evicted);
|
||||
|
||||
/// Bump objects up in the LRU cache, i.e. treat them as recently accessed.
|
||||
/// Objects that do not exist in the store will be ignored.
|
||||
///
|
||||
/// \param object_ids The IDs of the objects to bump.
|
||||
/// \return The return status.
|
||||
Status Refresh(const std::vector<ObjectID>& object_ids);
|
||||
Status Refresh(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
/// Disconnect from the local plasma instance, including the local store and
|
||||
/// manager.
|
||||
|
@ -231,7 +231,7 @@ class RAY_EXPORT PlasmaClient {
|
|||
FRIEND_TEST(TestPlasmaStore, LegacyGetTest);
|
||||
FRIEND_TEST(TestPlasmaStore, AbortTest);
|
||||
|
||||
bool IsInUse(const ObjectID& object_id);
|
||||
bool IsInUse(const ObjectID &object_id);
|
||||
|
||||
class RAY_NO_EXPORT Impl;
|
||||
std::shared_ptr<Impl> impl_;
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
using ray::ObjectID;
|
||||
using ray::NodeID;
|
||||
using ray::ObjectID;
|
||||
using ray::WorkerID;
|
||||
|
||||
enum class ObjectLocation : int32_t { Local, Remote, Nonexistent };
|
||||
|
@ -73,7 +73,7 @@ struct ObjectTableEntry {
|
|||
/// Offset from the base of the mmap.
|
||||
ptrdiff_t offset;
|
||||
/// Pointer to the object data. Needed to free the object.
|
||||
uint8_t* pointer;
|
||||
uint8_t *pointer;
|
||||
/// Size of the object in bytes.
|
||||
int64_t data_size;
|
||||
/// Size of the object metadata in bytes.
|
||||
|
|
|
@ -37,9 +37,9 @@ mach_port_t pthread_mach_thread_np(pthread_t);
|
|||
// headers you need manually.
|
||||
// (https://stackoverflow.com/a/8294669)
|
||||
#define WIN32_LEAN_AND_MEAN // Prevent inclusion of WinSock2.h
|
||||
#endif // #ifndef WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h> // Force inclusion of WinGDI here to resolve name conflict
|
||||
#endif // #ifndef _WINDOWS_
|
||||
#endif // #ifndef WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h> // Force inclusion of WinGDI here to resolve name conflict
|
||||
#endif // #ifndef _WINDOWS_
|
||||
#define MEMFD_TYPE HANDLE
|
||||
#define INVALID_FD NULL
|
||||
// https://docs.microsoft.com/en-us/windows/win32/winauto/32-bit-and-64-bit-interoperability
|
||||
|
|
|
@ -47,8 +47,7 @@ const std::vector<std::string> GenerateEnumNames(const char *const *enum_names_p
|
|||
}
|
||||
|
||||
static const std::vector<std::string> object_store_message_enum =
|
||||
GenerateEnumNames(flatbuf::EnumNamesMessageType(),
|
||||
static_cast<int>(MessageType::MIN),
|
||||
GenerateEnumNames(flatbuf::EnumNamesMessageType(), static_cast<int>(MessageType::MIN),
|
||||
static_cast<int>(MessageType::MAX));
|
||||
} // namespace
|
||||
|
||||
|
@ -59,21 +58,21 @@ Client::Client(ray::MessageHandler &message_handler, ray::local_stream_socket &&
|
|||
|
||||
std::shared_ptr<Client> Client::Create(PlasmaStoreMessageHandler message_handler,
|
||||
ray::local_stream_socket &&socket) {
|
||||
ray::MessageHandler ray_message_handler = [message_handler](
|
||||
std::shared_ptr<ray::ClientConnection> client,
|
||||
int64_t message_type, const std::vector<uint8_t> &message) {
|
||||
Status s = message_handler(
|
||||
std::static_pointer_cast<Client>(client->shared_ClientConnection_from_this()),
|
||||
(MessageType)message_type, message);
|
||||
if (!s.ok()) {
|
||||
if (!s.IsDisconnected()) {
|
||||
RAY_LOG(ERROR) << "Fail to process client message. " << s.ToString();
|
||||
}
|
||||
client->Close();
|
||||
} else {
|
||||
client->ProcessMessages();
|
||||
}
|
||||
};
|
||||
ray::MessageHandler ray_message_handler =
|
||||
[message_handler](std::shared_ptr<ray::ClientConnection> client,
|
||||
int64_t message_type, const std::vector<uint8_t> &message) {
|
||||
Status s = message_handler(
|
||||
std::static_pointer_cast<Client>(client->shared_ClientConnection_from_this()),
|
||||
(MessageType)message_type, message);
|
||||
if (!s.ok()) {
|
||||
if (!s.IsDisconnected()) {
|
||||
RAY_LOG(ERROR) << "Fail to process client message. " << s.ToString();
|
||||
}
|
||||
client->Close();
|
||||
} else {
|
||||
client->ProcessMessages();
|
||||
}
|
||||
};
|
||||
std::shared_ptr<Client> self(new Client(ray_message_handler, std::move(socket)));
|
||||
// Let our manager process our new connection.
|
||||
self->ProcessMessages();
|
||||
|
@ -97,17 +96,18 @@ Status Client::SendFd(MEMFD_TYPE fd) {
|
|||
}
|
||||
HANDLE target_handle = NULL;
|
||||
bool success = DuplicateHandle(GetCurrentProcess(), fd, target_process,
|
||||
&target_handle, 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||
&target_handle, 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||
if (!success) {
|
||||
// TODO(suquark): Define better error type.
|
||||
return Status::IOError("Fail to duplicate handle to PID = " + std::to_string(target_pid));
|
||||
return Status::IOError("Fail to duplicate handle to PID = " +
|
||||
std::to_string(target_pid));
|
||||
}
|
||||
Status s = WriteBuffer({boost::asio::buffer(&target_handle, sizeof(target_handle))});
|
||||
if (!s.ok()) {
|
||||
/* we failed to send the handle, and it needs cleaning up! */
|
||||
HANDLE duplicated_back = NULL;
|
||||
if (DuplicateHandle(target_process, fd, GetCurrentProcess(),
|
||||
&duplicated_back, 0, FALSE, DUPLICATE_CLOSE_SOURCE)) {
|
||||
if (DuplicateHandle(target_process, fd, GetCurrentProcess(), &duplicated_back, 0,
|
||||
FALSE, DUPLICATE_CLOSE_SOURCE)) {
|
||||
CloseHandle(duplicated_back);
|
||||
}
|
||||
CloseHandle(target_process);
|
||||
|
@ -129,8 +129,8 @@ Status Client::SendFd(MEMFD_TYPE fd) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
StoreConn::StoreConn(ray::local_stream_socket &&socket) :
|
||||
ray::ServerConnection(std::move(socket)) {}
|
||||
StoreConn::StoreConn(ray::local_stream_socket &&socket)
|
||||
: ray::ServerConnection(std::move(socket)) {}
|
||||
|
||||
Status StoreConn::RecvFd(MEMFD_TYPE *fd) {
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
namespace plasma {
|
||||
|
||||
namespace flatbuf {
|
||||
enum class MessageType : int64_t;
|
||||
enum class MessageType : int64_t;
|
||||
}
|
||||
|
||||
class Client;
|
||||
|
||||
using PlasmaStoreMessageHandler =
|
||||
std::function<ray::Status(std::shared_ptr<Client>, flatbuf::MessageType, const std::vector<uint8_t>&)>;
|
||||
using PlasmaStoreMessageHandler = std::function<ray::Status(
|
||||
std::shared_ptr<Client>, flatbuf::MessageType, const std::vector<uint8_t> &)>;
|
||||
|
||||
class ClientInterface {
|
||||
public:
|
||||
|
@ -22,10 +22,10 @@ class ClientInterface {
|
|||
};
|
||||
|
||||
/// Contains all information that is associated with a Plasma store client.
|
||||
class Client : public ray::ClientConnection, public ClientInterface {
|
||||
class Client : public ray::ClientConnection, public ClientInterface {
|
||||
public:
|
||||
static std::shared_ptr<Client> Create(
|
||||
PlasmaStoreMessageHandler message_handler, ray::local_stream_socket &&socket);
|
||||
static std::shared_ptr<Client> Create(PlasmaStoreMessageHandler message_handler,
|
||||
ray::local_stream_socket &&socket);
|
||||
|
||||
ray::Status SendFd(MEMFD_TYPE fd);
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
void CreateRequestQueue::AddRequest(const std::shared_ptr<ClientInterface> &client, const CreateObjectCallback &request_callback) {
|
||||
void CreateRequestQueue::AddRequest(const std::shared_ptr<ClientInterface> &client,
|
||||
const CreateObjectCallback &request_callback) {
|
||||
queue_.push_back({client, request_callback});
|
||||
}
|
||||
|
||||
Status CreateRequestQueue::ProcessRequests() {
|
||||
for (auto request_it = queue_.begin();
|
||||
request_it != queue_.end(); ) {
|
||||
for (auto request_it = queue_.begin(); request_it != queue_.end();) {
|
||||
auto status = request_it->second();
|
||||
if (status.IsTransientObjectStoreFull()) {
|
||||
return status;
|
||||
|
@ -40,9 +40,9 @@ Status CreateRequestQueue::ProcessRequests() {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
void CreateRequestQueue::RemoveDisconnectedClientRequests(const std::shared_ptr<ClientInterface> &client) {
|
||||
for (auto it = queue_.begin(); it != queue_.end(); ) {
|
||||
void CreateRequestQueue::RemoveDisconnectedClientRequests(
|
||||
const std::shared_ptr<ClientInterface> &client) {
|
||||
for (auto it = queue_.begin(); it != queue_.end();) {
|
||||
if (it->first == client) {
|
||||
it = queue_.erase(it);
|
||||
} else {
|
||||
|
|
|
@ -38,7 +38,8 @@ class CreateRequestQueue {
|
|||
/// serviceable.
|
||||
///
|
||||
/// \param client The client that sent the request.
|
||||
void AddRequest(const std::shared_ptr<ClientInterface> &client, const CreateObjectCallback &request_callback);
|
||||
void AddRequest(const std::shared_ptr<ClientInterface> &client,
|
||||
const CreateObjectCallback &request_callback);
|
||||
|
||||
/// Process requests in the queue.
|
||||
///
|
||||
|
@ -67,7 +68,8 @@ class CreateRequestQueue {
|
|||
/// in the object store. Then, the client does not need to poll on an
|
||||
/// OutOfMemory error and we can just respond to them once there is enough
|
||||
/// space made, or after a timeout.
|
||||
std::list<std::pair<const std::shared_ptr<ClientInterface>, const CreateObjectCallback>> queue_;
|
||||
std::list<std::pair<const std::shared_ptr<ClientInterface>, const CreateObjectCallback>>
|
||||
queue_;
|
||||
};
|
||||
|
||||
} // namespace plasma
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
void* fake_mmap(size_t);
|
||||
int fake_munmap(void*, int64_t);
|
||||
void *fake_mmap(size_t);
|
||||
int fake_munmap(void *, int64_t);
|
||||
|
||||
#define MMAP(s) fake_mmap(s)
|
||||
#define MUNMAP(a, s) fake_munmap(a, s)
|
||||
|
@ -64,15 +64,15 @@ int fake_munmap(void*, int64_t);
|
|||
|
||||
constexpr int GRANULARITY_MULTIPLIER = 2;
|
||||
|
||||
static void* pointer_advance(void* p, ptrdiff_t n) { return (unsigned char*)p + n; }
|
||||
static void *pointer_advance(void *p, ptrdiff_t n) { return (unsigned char *)p + n; }
|
||||
|
||||
static void* pointer_retreat(void* p, ptrdiff_t n) { return (unsigned char*)p - n; }
|
||||
static void *pointer_retreat(void *p, ptrdiff_t n) { return (unsigned char *)p - n; }
|
||||
|
||||
#ifdef _WIN32
|
||||
void create_and_mmap_buffer(int64_t size, void **pointer, HANDLE* handle) {
|
||||
void create_and_mmap_buffer(int64_t size, void **pointer, HANDLE *handle) {
|
||||
*handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
|
||||
(DWORD)((uint64_t)size >> (CHAR_BIT * sizeof(DWORD))),
|
||||
(DWORD)(uint64_t)size, NULL);
|
||||
(DWORD)((uint64_t)size >> (CHAR_BIT * sizeof(DWORD))),
|
||||
(DWORD)(uint64_t)size, NULL);
|
||||
RAY_CHECK(*handle != NULL) << "Failed to create buffer during mmap";
|
||||
*pointer = MapViewOfFile(*handle, FILE_MAP_ALL_ACCESS, 0, 0, (size_t)size);
|
||||
if (*pointer == NULL) {
|
||||
|
@ -80,7 +80,7 @@ void create_and_mmap_buffer(int64_t size, void **pointer, HANDLE* handle) {
|
|||
}
|
||||
}
|
||||
#else
|
||||
void create_and_mmap_buffer(int64_t size, void **pointer, int* fd) {
|
||||
void create_and_mmap_buffer(int64_t size, void **pointer, int *fd) {
|
||||
// Create a buffer. This is creating a temporary file and then
|
||||
// immediately unlinking it so we do not leave traces in the system.
|
||||
std::string file_template = plasma_config->directory;
|
||||
|
@ -118,20 +118,20 @@ void create_and_mmap_buffer(int64_t size, void **pointer, int* fd) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void* fake_mmap(size_t size) {
|
||||
void *fake_mmap(size_t size) {
|
||||
// Add kMmapRegionsGap so that the returned pointer is deliberately not
|
||||
// page-aligned. This ensures that the segments of memory returned by
|
||||
// fake_mmap are never contiguous.
|
||||
size += kMmapRegionsGap;
|
||||
|
||||
void* pointer;
|
||||
void *pointer;
|
||||
MEMFD_TYPE fd;
|
||||
create_and_mmap_buffer(size, &pointer, &fd);
|
||||
|
||||
// Increase dlmalloc's allocation granularity directly.
|
||||
mparams.granularity *= GRANULARITY_MULTIPLIER;
|
||||
|
||||
MmapRecord& record = mmap_records[pointer];
|
||||
MmapRecord &record = mmap_records[pointer];
|
||||
record.fd = fd;
|
||||
record.size = size;
|
||||
|
||||
|
@ -141,7 +141,7 @@ void* fake_mmap(size_t size) {
|
|||
return pointer;
|
||||
}
|
||||
|
||||
int fake_munmap(void* addr, int64_t size) {
|
||||
int fake_munmap(void *addr, int64_t size) {
|
||||
RAY_LOG(DEBUG) << "fake_munmap(" << addr << ", " << size << ")";
|
||||
addr = pointer_retreat(addr, kMmapRegionsGap);
|
||||
size += kMmapRegionsGap;
|
||||
|
@ -173,6 +173,6 @@ int fake_munmap(void* addr, int64_t size) {
|
|||
|
||||
void SetMallocGranularity(int value) { change_mparam(M_GRANULARITY, value); }
|
||||
|
||||
const PlasmaStoreInfo* plasma_config;
|
||||
const PlasmaStoreInfo *plasma_config;
|
||||
|
||||
} // namespace plasma
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
void LRUCache::Add(const ObjectID& key, int64_t size) {
|
||||
void LRUCache::Add(const ObjectID &key, int64_t size) {
|
||||
auto it = item_map_.find(key);
|
||||
RAY_CHECK(it == item_map_.end());
|
||||
// Note that it is important to use a list so the iterators stay valid.
|
||||
|
@ -32,7 +32,7 @@ void LRUCache::Add(const ObjectID& key, int64_t size) {
|
|||
used_capacity_ += size;
|
||||
}
|
||||
|
||||
int64_t LRUCache::Remove(const ObjectID& key) {
|
||||
int64_t LRUCache::Remove(const ObjectID &key) {
|
||||
auto it = item_map_.find(key);
|
||||
if (it == item_map_.end()) {
|
||||
return -1;
|
||||
|
@ -47,7 +47,7 @@ int64_t LRUCache::Remove(const ObjectID& key) {
|
|||
|
||||
void LRUCache::AdjustCapacity(int64_t delta) {
|
||||
RAY_LOG(INFO) << "adjusting global lru capacity from " << Capacity() << " to "
|
||||
<< (Capacity() + delta) << " (max " << OriginalCapacity() << ")";
|
||||
<< (Capacity() + delta) << " (max " << OriginalCapacity() << ")";
|
||||
capacity_ += delta;
|
||||
RAY_CHECK(used_capacity_ >= 0) << DebugString();
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ int64_t LRUCache::OriginalCapacity() const { return original_capacity_; }
|
|||
|
||||
int64_t LRUCache::RemainingCapacity() const { return capacity_ - used_capacity_; }
|
||||
|
||||
void LRUCache::Foreach(std::function<void(const ObjectID&)> f) {
|
||||
for (auto& pair : item_list_) {
|
||||
void LRUCache::Foreach(std::function<void(const ObjectID &)> f) {
|
||||
for (auto &pair : item_list_) {
|
||||
f(pair.first);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ std::string LRUCache::DebugString() const {
|
|||
}
|
||||
|
||||
int64_t LRUCache::ChooseObjectsToEvict(int64_t num_bytes_required,
|
||||
std::vector<ObjectID>* objects_to_evict) {
|
||||
std::vector<ObjectID> *objects_to_evict) {
|
||||
int64_t bytes_evicted = 0;
|
||||
auto it = item_list_.end();
|
||||
while (bytes_evicted < num_bytes_required && it != item_list_.begin()) {
|
||||
|
@ -90,37 +90,38 @@ int64_t LRUCache::ChooseObjectsToEvict(int64_t num_bytes_required,
|
|||
return bytes_evicted;
|
||||
}
|
||||
|
||||
EvictionPolicy::EvictionPolicy(PlasmaStoreInfo* store_info, int64_t max_size)
|
||||
EvictionPolicy::EvictionPolicy(PlasmaStoreInfo *store_info, int64_t max_size)
|
||||
: pinned_memory_bytes_(0), store_info_(store_info), cache_("global lru", max_size) {}
|
||||
|
||||
int64_t EvictionPolicy::ChooseObjectsToEvict(int64_t num_bytes_required,
|
||||
std::vector<ObjectID>* objects_to_evict) {
|
||||
std::vector<ObjectID> *objects_to_evict) {
|
||||
int64_t bytes_evicted =
|
||||
cache_.ChooseObjectsToEvict(num_bytes_required, objects_to_evict);
|
||||
// Update the LRU cache.
|
||||
for (auto& object_id : *objects_to_evict) {
|
||||
for (auto &object_id : *objects_to_evict) {
|
||||
cache_.Remove(object_id);
|
||||
}
|
||||
return bytes_evicted;
|
||||
}
|
||||
|
||||
void EvictionPolicy::ObjectCreated(const ObjectID& object_id, Client* client,
|
||||
void EvictionPolicy::ObjectCreated(const ObjectID &object_id, Client *client,
|
||||
bool is_create) {
|
||||
cache_.Add(object_id, GetObjectSize(object_id));
|
||||
}
|
||||
|
||||
bool EvictionPolicy::SetClientQuota(Client* client, int64_t output_memory_quota) {
|
||||
bool EvictionPolicy::SetClientQuota(Client *client, int64_t output_memory_quota) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EvictionPolicy::EnforcePerClientQuota(Client* client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID>* objects_to_evict) {
|
||||
bool EvictionPolicy::EnforcePerClientQuota(Client *client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID> *objects_to_evict) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void EvictionPolicy::ClientDisconnected(Client* client) {}
|
||||
void EvictionPolicy::ClientDisconnected(Client *client) {}
|
||||
|
||||
int64_t EvictionPolicy::RequireSpace(int64_t size, std::vector<ObjectID>* objects_to_evict) {
|
||||
int64_t EvictionPolicy::RequireSpace(int64_t size,
|
||||
std::vector<ObjectID> *objects_to_evict) {
|
||||
// Check if there is enough space to create the object.
|
||||
int64_t required_space =
|
||||
PlasmaAllocator::Allocated() + size - PlasmaAllocator::GetFootprintLimit();
|
||||
|
@ -132,32 +133,32 @@ int64_t EvictionPolicy::RequireSpace(int64_t size, std::vector<ObjectID>* object
|
|||
// Choose some objects to evict, and update the return pointers.
|
||||
int64_t num_bytes_evicted = ChooseObjectsToEvict(space_to_free, objects_to_evict);
|
||||
RAY_LOG(INFO) << "There is not enough space to create this object, so evicting "
|
||||
<< objects_to_evict->size() << " objects to free up "
|
||||
<< num_bytes_evicted << " bytes. The number of bytes in use (before "
|
||||
<< "this eviction) is " << PlasmaAllocator::Allocated() << ".";
|
||||
<< objects_to_evict->size() << " objects to free up " << num_bytes_evicted
|
||||
<< " bytes. The number of bytes in use (before "
|
||||
<< "this eviction) is " << PlasmaAllocator::Allocated() << ".";
|
||||
return required_space - num_bytes_evicted;
|
||||
}
|
||||
|
||||
void EvictionPolicy::BeginObjectAccess(const ObjectID& object_id) {
|
||||
void EvictionPolicy::BeginObjectAccess(const ObjectID &object_id) {
|
||||
// If the object is in the LRU cache, remove it.
|
||||
cache_.Remove(object_id);
|
||||
pinned_memory_bytes_ += GetObjectSize(object_id);
|
||||
}
|
||||
|
||||
void EvictionPolicy::EndObjectAccess(const ObjectID& object_id) {
|
||||
void EvictionPolicy::EndObjectAccess(const ObjectID &object_id) {
|
||||
auto size = GetObjectSize(object_id);
|
||||
// Add the object to the LRU cache.
|
||||
cache_.Add(object_id, size);
|
||||
pinned_memory_bytes_ -= size;
|
||||
}
|
||||
|
||||
void EvictionPolicy::RemoveObject(const ObjectID& object_id) {
|
||||
void EvictionPolicy::RemoveObject(const ObjectID &object_id) {
|
||||
// If the object is in the LRU cache, remove it.
|
||||
cache_.Remove(object_id);
|
||||
}
|
||||
|
||||
void EvictionPolicy::RefreshObjects(const std::vector<ObjectID>& object_ids) {
|
||||
for (const auto& object_id : object_ids) {
|
||||
void EvictionPolicy::RefreshObjects(const std::vector<ObjectID> &object_ids) {
|
||||
for (const auto &object_id : object_ids) {
|
||||
int64_t size = cache_.Remove(object_id);
|
||||
if (size != -1) {
|
||||
cache_.Add(object_id, size);
|
||||
|
@ -165,7 +166,7 @@ void EvictionPolicy::RefreshObjects(const std::vector<ObjectID>& object_ids) {
|
|||
}
|
||||
}
|
||||
|
||||
int64_t EvictionPolicy::GetObjectSize(const ObjectID& object_id) const {
|
||||
int64_t EvictionPolicy::GetObjectSize(const ObjectID &object_id) const {
|
||||
auto entry = store_info_->objects[object_id].get();
|
||||
return entry->data_size + entry->metadata_size;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class Client;
|
|||
|
||||
class LRUCache {
|
||||
public:
|
||||
LRUCache(const std::string& name, int64_t size)
|
||||
LRUCache(const std::string &name, int64_t size)
|
||||
: name_(name),
|
||||
original_capacity_(size),
|
||||
capacity_(size),
|
||||
|
@ -49,12 +49,12 @@ class LRUCache {
|
|||
num_evictions_total_(0),
|
||||
bytes_evicted_total_(0) {}
|
||||
|
||||
void Add(const ObjectID& key, int64_t size);
|
||||
void Add(const ObjectID &key, int64_t size);
|
||||
|
||||
int64_t Remove(const ObjectID& key);
|
||||
int64_t Remove(const ObjectID &key);
|
||||
|
||||
int64_t ChooseObjectsToEvict(int64_t num_bytes_required,
|
||||
std::vector<ObjectID>* objects_to_evict);
|
||||
std::vector<ObjectID> *objects_to_evict);
|
||||
|
||||
int64_t OriginalCapacity() const;
|
||||
|
||||
|
@ -64,7 +64,7 @@ class LRUCache {
|
|||
|
||||
void AdjustCapacity(int64_t delta);
|
||||
|
||||
void Foreach(std::function<void(const ObjectID&)>);
|
||||
void Foreach(std::function<void(const ObjectID &)>);
|
||||
|
||||
std::string DebugString() const;
|
||||
|
||||
|
@ -99,7 +99,7 @@ class EvictionPolicy {
|
|||
/// \param store_info Information about the Plasma store that is exposed
|
||||
/// to the eviction policy.
|
||||
/// \param max_size Max size in bytes total of objects to store.
|
||||
explicit EvictionPolicy(PlasmaStoreInfo* store_info, int64_t max_size);
|
||||
explicit EvictionPolicy(PlasmaStoreInfo *store_info, int64_t max_size);
|
||||
|
||||
/// Destroy an eviction policy.
|
||||
virtual ~EvictionPolicy() {}
|
||||
|
@ -112,7 +112,7 @@ class EvictionPolicy {
|
|||
/// \param object_id The object ID of the object that was created.
|
||||
/// \param client The pointer to the client.
|
||||
/// \param is_create Whether we are creating a new object (vs reading an object).
|
||||
virtual void ObjectCreated(const ObjectID& object_id, Client* client, bool is_create);
|
||||
virtual void ObjectCreated(const ObjectID &object_id, Client *client, bool is_create);
|
||||
|
||||
/// Set quota for a client.
|
||||
///
|
||||
|
@ -123,7 +123,7 @@ class EvictionPolicy {
|
|||
/// out of the capacity of the global LRU cache for the client lifetime.
|
||||
///
|
||||
/// \return True if enough space can be reserved for the given client quota.
|
||||
virtual bool SetClientQuota(Client* client, int64_t output_memory_quota);
|
||||
virtual bool SetClientQuota(Client *client, int64_t output_memory_quota);
|
||||
|
||||
/// Determine what objects need to be evicted to enforce the given client's quota.
|
||||
///
|
||||
|
@ -134,14 +134,14 @@ class EvictionPolicy {
|
|||
/// be stored into this vector.
|
||||
///
|
||||
/// \return True if enough space could be freed and false otherwise.
|
||||
virtual bool EnforcePerClientQuota(Client* client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID>* objects_to_evict);
|
||||
virtual bool EnforcePerClientQuota(Client *client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID> *objects_to_evict);
|
||||
|
||||
/// Called to clean up any resources allocated by this client. This merges any
|
||||
/// per-client LRU queue created by SetClientQuota into the global LRU queue.
|
||||
///
|
||||
/// \param client The pointer to the client.
|
||||
virtual void ClientDisconnected(Client* client);
|
||||
virtual void ClientDisconnected(Client *client);
|
||||
|
||||
/// This method will be called when the Plasma store needs more space, perhaps
|
||||
/// to create a new object. When this method is called, the eviction
|
||||
|
@ -154,7 +154,7 @@ class EvictionPolicy {
|
|||
/// be stored into this vector.
|
||||
/// \return The number of bytes of space that is still needed, if
|
||||
/// any. If negative, then the required space has been made.
|
||||
virtual int64_t RequireSpace(int64_t size, std::vector<ObjectID>* objects_to_evict);
|
||||
virtual int64_t RequireSpace(int64_t size, std::vector<ObjectID> *objects_to_evict);
|
||||
|
||||
/// This method will be called whenever an unused object in the Plasma store
|
||||
/// starts to be used. When this method is called, the eviction policy will
|
||||
|
@ -162,7 +162,7 @@ class EvictionPolicy {
|
|||
/// the Plasma store by the caller.
|
||||
///
|
||||
/// \param object_id The ID of the object that is now being used.
|
||||
virtual void BeginObjectAccess(const ObjectID& object_id);
|
||||
virtual void BeginObjectAccess(const ObjectID &object_id);
|
||||
|
||||
/// This method will be called whenever an object in the Plasma store that was
|
||||
/// being used is no longer being used. When this method is called, the
|
||||
|
@ -170,7 +170,7 @@ class EvictionPolicy {
|
|||
/// fact be evicted from the Plasma store by the caller.
|
||||
///
|
||||
/// \param object_id The ID of the object that is no longer being used.
|
||||
virtual void EndObjectAccess(const ObjectID& object_id);
|
||||
virtual void EndObjectAccess(const ObjectID &object_id);
|
||||
|
||||
/// Choose some objects to evict from the Plasma store. When this method is
|
||||
/// called, the eviction policy will assume that the objects chosen to be
|
||||
|
@ -184,27 +184,27 @@ class EvictionPolicy {
|
|||
/// be stored into this vector.
|
||||
/// \return The total number of bytes of space chosen to be evicted.
|
||||
virtual int64_t ChooseObjectsToEvict(int64_t num_bytes_required,
|
||||
std::vector<ObjectID>* objects_to_evict);
|
||||
std::vector<ObjectID> *objects_to_evict);
|
||||
|
||||
/// This method will be called when an object is going to be removed
|
||||
///
|
||||
/// \param object_id The ID of the object that is now being used.
|
||||
virtual void RemoveObject(const ObjectID& object_id);
|
||||
virtual void RemoveObject(const ObjectID &object_id);
|
||||
|
||||
virtual void RefreshObjects(const std::vector<ObjectID>& object_ids);
|
||||
virtual void RefreshObjects(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
/// Returns debugging information for this eviction policy.
|
||||
virtual std::string DebugString() const;
|
||||
|
||||
protected:
|
||||
/// Returns the size of the object
|
||||
int64_t GetObjectSize(const ObjectID& object_id) const;
|
||||
int64_t GetObjectSize(const ObjectID &object_id) const;
|
||||
|
||||
/// The number of bytes pinned by applications.
|
||||
int64_t pinned_memory_bytes_;
|
||||
|
||||
/// Pointer to the plasma store info.
|
||||
PlasmaStoreInfo* store_info_;
|
||||
PlasmaStoreInfo *store_info_;
|
||||
/// Datastructure for the LRU cache.
|
||||
LRUCache cache_;
|
||||
};
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
Status ExternalStores::ExtractStoreName(const std::string& endpoint,
|
||||
std::string* store_name) {
|
||||
Status ExternalStores::ExtractStoreName(const std::string &endpoint,
|
||||
std::string *store_name) {
|
||||
size_t off = endpoint.find_first_of(':');
|
||||
if (off == std::string::npos) {
|
||||
return Status::Invalid("Malformed endpoint " + endpoint);
|
||||
|
@ -34,12 +34,12 @@ Status ExternalStores::ExtractStoreName(const std::string& endpoint,
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
void ExternalStores::RegisterStore(const std::string& store_name,
|
||||
void ExternalStores::RegisterStore(const std::string &store_name,
|
||||
std::shared_ptr<ExternalStore> store) {
|
||||
Stores().insert({store_name, store});
|
||||
}
|
||||
|
||||
void ExternalStores::DeregisterStore(const std::string& store_name) {
|
||||
void ExternalStores::DeregisterStore(const std::string &store_name) {
|
||||
auto it = Stores().find(store_name);
|
||||
if (it == Stores().end()) {
|
||||
return;
|
||||
|
@ -47,7 +47,7 @@ void ExternalStores::DeregisterStore(const std::string& store_name) {
|
|||
Stores().erase(it);
|
||||
}
|
||||
|
||||
std::shared_ptr<ExternalStore> ExternalStores::GetStore(const std::string& store_name) {
|
||||
std::shared_ptr<ExternalStore> ExternalStores::GetStore(const std::string &store_name) {
|
||||
auto it = Stores().find(store_name);
|
||||
if (it == Stores().end()) {
|
||||
return nullptr;
|
||||
|
@ -55,8 +55,8 @@ std::shared_ptr<ExternalStore> ExternalStores::GetStore(const std::string& store
|
|||
return it->second;
|
||||
}
|
||||
|
||||
ExternalStores::StoreMap& ExternalStores::Stores() {
|
||||
static auto* external_stores = new StoreMap();
|
||||
ExternalStores::StoreMap &ExternalStores::Stores() {
|
||||
static auto *external_stores = new StoreMap();
|
||||
return *external_stores;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class ExternalStore {
|
|||
/// external store.
|
||||
///
|
||||
/// \return The return status.
|
||||
virtual Status Connect(const std::string& endpoint) = 0;
|
||||
virtual Status Connect(const std::string &endpoint) = 0;
|
||||
|
||||
/// This method will be called whenever an object in the Plasma store needs
|
||||
/// to be evicted to the external store.
|
||||
|
@ -59,8 +59,8 @@ class ExternalStore {
|
|||
/// \param ids The IDs of the objects to put.
|
||||
/// \param data The object data to put.
|
||||
/// \return The return status.
|
||||
virtual Status Put(const std::vector<ObjectID>& ids,
|
||||
const std::vector<std::shared_ptr<Buffer>>& data) = 0;
|
||||
virtual Status Put(const std::vector<ObjectID> &ids,
|
||||
const std::vector<std::shared_ptr<Buffer>> &data) = 0;
|
||||
|
||||
/// This method will be called whenever an evicted object in the external
|
||||
/// store store needs to be accessed.
|
||||
|
@ -70,7 +70,7 @@ class ExternalStore {
|
|||
/// \param ids The IDs of the objects to get.
|
||||
/// \param buffers List of buffers the data should be written to.
|
||||
/// \return The return status.
|
||||
virtual Status Get(const std::vector<ObjectID>& ids,
|
||||
virtual Status Get(const std::vector<ObjectID> &ids,
|
||||
std::vector<std::shared_ptr<Buffer>> buffers) = 0;
|
||||
};
|
||||
|
||||
|
@ -82,31 +82,31 @@ class ExternalStores {
|
|||
/// \param endpoint The endpoint for the external store.
|
||||
/// \param[out] store_name The name of the external store.
|
||||
/// \return The return status.
|
||||
static Status ExtractStoreName(const std::string& endpoint, std::string* store_name);
|
||||
static Status ExtractStoreName(const std::string &endpoint, std::string *store_name);
|
||||
|
||||
/// Register a new external store.
|
||||
///
|
||||
/// \param store_name Name of the new external store.
|
||||
/// \param store The new external store object.
|
||||
static void RegisterStore(const std::string& store_name,
|
||||
static void RegisterStore(const std::string &store_name,
|
||||
std::shared_ptr<ExternalStore> store);
|
||||
|
||||
/// Remove an external store from the registry.
|
||||
///
|
||||
/// \param store_name Name of the external store to remove.
|
||||
static void DeregisterStore(const std::string& store_name);
|
||||
static void DeregisterStore(const std::string &store_name);
|
||||
|
||||
/// Obtain the external store given its name.
|
||||
///
|
||||
/// \param store_name Name of the external store.
|
||||
/// \return The external store object.
|
||||
static std::shared_ptr<ExternalStore> GetStore(const std::string& store_name);
|
||||
static std::shared_ptr<ExternalStore> GetStore(const std::string &store_name);
|
||||
|
||||
private:
|
||||
/// Obtain mapping between external store names and store instances.
|
||||
///
|
||||
/// \return Mapping between external store names and store instances.
|
||||
static StoreMap& Stores();
|
||||
static StoreMap &Stores();
|
||||
};
|
||||
|
||||
#define REGISTER_EXTERNAL_STORE(name, store) \
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define CMSG_LEN(len) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (len))
|
||||
#endif
|
||||
|
||||
void init_msg(struct msghdr* msg, struct iovec* iov, char* buf, size_t buf_len) {
|
||||
void init_msg(struct msghdr *msg, struct iovec *iov, char *buf, size_t buf_len) {
|
||||
iov->iov_base = buf;
|
||||
iov->iov_len = 1;
|
||||
|
||||
|
@ -56,14 +56,14 @@ int send_fd(int conn, int fd) {
|
|||
|
||||
init_msg(&msg, &iov, buf, sizeof(buf));
|
||||
|
||||
struct cmsghdr* header = CMSG_FIRSTHDR(&msg);
|
||||
struct cmsghdr *header = CMSG_FIRSTHDR(&msg);
|
||||
if (header == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
header->cmsg_level = SOL_SOCKET;
|
||||
header->cmsg_type = SCM_RIGHTS;
|
||||
header->cmsg_len = CMSG_LEN(sizeof(fd));
|
||||
memcpy(CMSG_DATA(header), reinterpret_cast<void*>(&fd), sizeof(fd));
|
||||
memcpy(CMSG_DATA(header), reinterpret_cast<void *>(&fd), sizeof(fd));
|
||||
|
||||
// Send file descriptor.
|
||||
while (true) {
|
||||
|
@ -73,7 +73,7 @@ int send_fd(int conn, int fd) {
|
|||
continue;
|
||||
} else if (errno == EMSGSIZE) {
|
||||
RAY_LOG(WARNING) << "Failed to send file descriptor"
|
||||
<< " (errno = EMSGSIZE), retrying.";
|
||||
<< " (errno = EMSGSIZE), retrying.";
|
||||
// If we failed to send the file descriptor, loop until we have sent it
|
||||
// successfully. TODO(rkn): This is problematic for two reasons. First
|
||||
// of all, sending the file descriptor should just succeed without any
|
||||
|
@ -117,14 +117,14 @@ int recv_fd(int conn) {
|
|||
|
||||
int found_fd = -1;
|
||||
int oh_noes = 0;
|
||||
for (struct cmsghdr* header = CMSG_FIRSTHDR(&msg); header != NULL;
|
||||
for (struct cmsghdr *header = CMSG_FIRSTHDR(&msg); header != NULL;
|
||||
header = CMSG_NXTHDR(&msg, header))
|
||||
if (header->cmsg_level == SOL_SOCKET && header->cmsg_type == SCM_RIGHTS) {
|
||||
ssize_t count = (header->cmsg_len -
|
||||
(CMSG_DATA(header) - reinterpret_cast<unsigned char*>(header))) /
|
||||
(CMSG_DATA(header) - reinterpret_cast<unsigned char *>(header))) /
|
||||
sizeof(int);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
int fd = (reinterpret_cast<int*>(CMSG_DATA(header)))[i];
|
||||
int fd = (reinterpret_cast<int *>(CMSG_DATA(header)))[i];
|
||||
if (found_fd == -1) {
|
||||
found_fd = fd;
|
||||
} else {
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
std::unordered_map<void*, MmapRecord> mmap_records;
|
||||
std::unordered_map<void *, MmapRecord> mmap_records;
|
||||
|
||||
static void* pointer_advance(void* p, ptrdiff_t n) { return (unsigned char*)p + n; }
|
||||
static void *pointer_advance(void *p, ptrdiff_t n) { return (unsigned char *)p + n; }
|
||||
|
||||
static ptrdiff_t pointer_distance(void const* pfrom, void const* pto) {
|
||||
return (unsigned char const*)pto - (unsigned char const*)pfrom;
|
||||
static ptrdiff_t pointer_distance(void const *pfrom, void const *pto) {
|
||||
return (unsigned char const *)pto - (unsigned char const *)pfrom;
|
||||
}
|
||||
|
||||
void GetMallocMapinfo(void* addr, MEMFD_TYPE* fd, int64_t* map_size, ptrdiff_t* offset) {
|
||||
void GetMallocMapinfo(void *addr, MEMFD_TYPE *fd, int64_t *map_size, ptrdiff_t *offset) {
|
||||
// TODO(rshin): Implement a more efficient search through mmap_records.
|
||||
for (const auto& entry : mmap_records) {
|
||||
for (const auto &entry : mmap_records) {
|
||||
if (addr >= entry.first && addr < pointer_advance(entry.first, entry.second.size)) {
|
||||
*fd = entry.second.fd;
|
||||
*map_size = entry.second.size;
|
||||
|
@ -48,7 +48,7 @@ void GetMallocMapinfo(void* addr, MEMFD_TYPE* fd, int64_t* map_size, ptrdiff_t*
|
|||
}
|
||||
|
||||
int64_t GetMmapSize(MEMFD_TYPE fd) {
|
||||
for (const auto& entry : mmap_records) {
|
||||
for (const auto &entry : mmap_records) {
|
||||
if (entry.second.fd == fd) {
|
||||
return entry.second.size;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ray/object_manager/plasma/compat.h"
|
||||
#include <unordered_map>
|
||||
#include "ray/object_manager/plasma/compat.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace plasma {
|
|||
/// (in the client we cannot guarantee that these mmaps are contiguous).
|
||||
constexpr int64_t kMmapRegionsGap = sizeof(size_t);
|
||||
|
||||
void GetMallocMapinfo(void* addr, MEMFD_TYPE* fd, int64_t* map_length, ptrdiff_t* offset);
|
||||
void GetMallocMapinfo(void *addr, MEMFD_TYPE *fd, int64_t *map_length, ptrdiff_t *offset);
|
||||
|
||||
/// Get the mmap size corresponding to a specific file descriptor.
|
||||
///
|
||||
|
@ -47,6 +47,6 @@ struct MmapRecord {
|
|||
/// Hashtable that contains one entry per segment that we got from the OS
|
||||
/// via mmap. Associates the address of that segment with its file descriptor
|
||||
/// and size.
|
||||
extern std::unordered_map<void*, MmapRecord> mmap_records;
|
||||
extern std::unordered_map<void *, MmapRecord> mmap_records;
|
||||
|
||||
} // namespace plasma
|
||||
|
|
|
@ -25,8 +25,8 @@ ObjectTableEntry::ObjectTableEntry() : pointer(nullptr), ref_count(0) {}
|
|||
|
||||
ObjectTableEntry::~ObjectTableEntry() { pointer = nullptr; }
|
||||
|
||||
ObjectTableEntry* GetObjectTableEntry(PlasmaStoreInfo* store_info,
|
||||
const ObjectID& object_id) {
|
||||
ObjectTableEntry *GetObjectTableEntry(PlasmaStoreInfo *store_info,
|
||||
const ObjectID &object_id) {
|
||||
auto it = store_info->objects.find(object_id);
|
||||
if (it == store_info->objects.end()) {
|
||||
return NULL;
|
||||
|
|
|
@ -56,7 +56,7 @@ struct PlasmaObject {
|
|||
/// Device number object is on.
|
||||
int device_num;
|
||||
|
||||
bool operator==(const PlasmaObject& other) const {
|
||||
bool operator==(const PlasmaObject &other) const {
|
||||
return (
|
||||
#ifdef PLASMA_CUDA
|
||||
(ipc_handle == other.ipc_handle) &&
|
||||
|
@ -94,10 +94,10 @@ struct PlasmaStoreInfo {
|
|||
/// \param object_id The object_id of the entry we are looking for.
|
||||
/// \return The entry associated with the object_id or NULL if the object_id
|
||||
/// is not present.
|
||||
ObjectTableEntry* GetObjectTableEntry(PlasmaStoreInfo* store_info,
|
||||
const ObjectID& object_id);
|
||||
ObjectTableEntry *GetObjectTableEntry(PlasmaStoreInfo *store_info,
|
||||
const ObjectID &object_id);
|
||||
|
||||
/// Globally accessible reference to plasma store configuration.
|
||||
extern const PlasmaStoreInfo* plasma_config;
|
||||
extern const PlasmaStoreInfo *plasma_config;
|
||||
|
||||
} // namespace plasma
|
||||
|
|
|
@ -23,24 +23,24 @@
|
|||
namespace plasma {
|
||||
|
||||
extern "C" {
|
||||
void* dlmemalign(size_t alignment, size_t bytes);
|
||||
void dlfree(void* mem);
|
||||
void *dlmemalign(size_t alignment, size_t bytes);
|
||||
void dlfree(void *mem);
|
||||
}
|
||||
|
||||
int64_t PlasmaAllocator::footprint_limit_ = 0;
|
||||
int64_t PlasmaAllocator::allocated_ = 0;
|
||||
|
||||
void* PlasmaAllocator::Memalign(size_t alignment, size_t bytes) {
|
||||
void *PlasmaAllocator::Memalign(size_t alignment, size_t bytes) {
|
||||
if (allocated_ + static_cast<int64_t>(bytes) > footprint_limit_) {
|
||||
return nullptr;
|
||||
}
|
||||
void* mem = dlmemalign(alignment, bytes);
|
||||
void *mem = dlmemalign(alignment, bytes);
|
||||
RAY_CHECK(mem);
|
||||
allocated_ += bytes;
|
||||
return mem;
|
||||
}
|
||||
|
||||
void PlasmaAllocator::Free(void* mem, size_t bytes) {
|
||||
void PlasmaAllocator::Free(void *mem, size_t bytes) {
|
||||
dlfree(mem);
|
||||
allocated_ -= bytes;
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ class PlasmaAllocator {
|
|||
/// \param alignment Memory alignment.
|
||||
/// \param bytes Number of bytes.
|
||||
/// \return Pointer to allocated memory.
|
||||
static void* Memalign(size_t alignment, size_t bytes);
|
||||
static void *Memalign(size_t alignment, size_t bytes);
|
||||
|
||||
/// Frees the memory space pointed to by mem, which must have been returned by
|
||||
/// a previous call to Memalign()
|
||||
///
|
||||
/// \param mem Pointer to memory to free.
|
||||
/// \param bytes Number of bytes to be freed.
|
||||
static void Free(void* mem, size_t bytes);
|
||||
static void Free(void *mem, size_t bytes);
|
||||
|
||||
/// Sets the memory footprint limit for Plasma.
|
||||
///
|
||||
|
|
|
@ -44,7 +44,7 @@ using flatbuffers::uoffset_t;
|
|||
static_assert(static_cast<int>(x) == static_cast<int>(y), "protocol mismatch")
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb, const ObjectID* object_ids,
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder *fbb, const ObjectID *object_ids,
|
||||
int64_t num_objects) {
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> results;
|
||||
for (int64_t i = 0; i < num_objects; i++) {
|
||||
|
@ -54,8 +54,8 @@ ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb, const ObjectID* object_ids,
|
|||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb,
|
||||
const std::vector<std::string>& strings) {
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder *fbb,
|
||||
const std::vector<std::string> &strings) {
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> results;
|
||||
for (size_t i = 0; i < strings.size(); i++) {
|
||||
results.push_back(fbb->CreateString(strings[i]));
|
||||
|
@ -65,11 +65,12 @@ ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb,
|
|||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<int64_t>> ToFlatbuffer(
|
||||
flatbuffers::FlatBufferBuilder* fbb, const std::vector<int64_t>& data) {
|
||||
flatbuffers::FlatBufferBuilder *fbb, const std::vector<int64_t> &data) {
|
||||
return fbb->CreateVector(arrow::util::MakeNonNull(data.data()), data.size());
|
||||
}
|
||||
|
||||
Status PlasmaReceive(const std::shared_ptr<StoreConn> &store_conn, MessageType message_type, std::vector<uint8_t>* buffer) {
|
||||
Status PlasmaReceive(const std::shared_ptr<StoreConn> &store_conn,
|
||||
MessageType message_type, std::vector<uint8_t> *buffer) {
|
||||
if (!store_conn) {
|
||||
return Status::IOError("Connection is closed.");
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ Status PlasmaReceive(const std::shared_ptr<StoreConn> &store_conn, MessageType m
|
|||
// Helper function to create a vector of elements from Data (Request/Reply struct).
|
||||
// The Getter function is used to extract one element from Data.
|
||||
template <typename T, typename Data, typename Getter>
|
||||
void ToVector(const Data& request, std::vector<T>* out, const Getter& getter) {
|
||||
void ToVector(const Data &request, std::vector<T> *out, const Getter &getter) {
|
||||
int count = request.count();
|
||||
out->clear();
|
||||
out->reserve(count);
|
||||
|
@ -89,8 +90,8 @@ void ToVector(const Data& request, std::vector<T>* out, const Getter& getter) {
|
|||
}
|
||||
|
||||
template <typename T, typename FlatbufferVectorPointer, typename Converter>
|
||||
void ConvertToVector(const FlatbufferVectorPointer fbvector, std::vector<T>* out,
|
||||
const Converter& converter) {
|
||||
void ConvertToVector(const FlatbufferVectorPointer fbvector, std::vector<T> *out,
|
||||
const Converter &converter) {
|
||||
out->clear();
|
||||
out->reserve(fbvector->size());
|
||||
for (size_t i = 0; i < fbvector->size(); ++i) {
|
||||
|
@ -99,44 +100,47 @@ void ConvertToVector(const FlatbufferVectorPointer fbvector, std::vector<T>* out
|
|||
}
|
||||
|
||||
template <typename Message>
|
||||
Status PlasmaSend(const std::shared_ptr<StoreConn> &store_conn, MessageType message_type, flatbuffers::FlatBufferBuilder* fbb,
|
||||
const Message& message) {
|
||||
Status PlasmaSend(const std::shared_ptr<StoreConn> &store_conn, MessageType message_type,
|
||||
flatbuffers::FlatBufferBuilder *fbb, const Message &message) {
|
||||
if (!store_conn) {
|
||||
return Status::IOError("Connection is closed.");
|
||||
}
|
||||
fbb->Finish(message);
|
||||
return store_conn->WriteMessage(static_cast<int64_t>(message_type), fbb->GetSize(), fbb->GetBufferPointer());
|
||||
return store_conn->WriteMessage(static_cast<int64_t>(message_type), fbb->GetSize(),
|
||||
fbb->GetBufferPointer());
|
||||
}
|
||||
|
||||
template <typename Message>
|
||||
Status PlasmaSend(const std::shared_ptr<Client> &client, MessageType message_type, flatbuffers::FlatBufferBuilder* fbb,
|
||||
const Message& message) {
|
||||
Status PlasmaSend(const std::shared_ptr<Client> &client, MessageType message_type,
|
||||
flatbuffers::FlatBufferBuilder *fbb, const Message &message) {
|
||||
if (!client) {
|
||||
return Status::IOError("Connection is closed.");
|
||||
}
|
||||
fbb->Finish(message);
|
||||
return client->WriteMessage(static_cast<int64_t>(message_type), fbb->GetSize(), fbb->GetBufferPointer());
|
||||
return client->WriteMessage(static_cast<int64_t>(message_type), fbb->GetSize(),
|
||||
fbb->GetBufferPointer());
|
||||
}
|
||||
|
||||
Status PlasmaErrorStatus(fb::PlasmaError plasma_error) {
|
||||
switch (plasma_error) {
|
||||
case fb::PlasmaError::OK:
|
||||
return Status::OK();
|
||||
case fb::PlasmaError::ObjectExists:
|
||||
return Status::ObjectExists("object already exists in the plasma store");
|
||||
case fb::PlasmaError::ObjectNonexistent:
|
||||
return Status::ObjectNotFound("object does not exist in the plasma store");
|
||||
case fb::PlasmaError::OutOfMemory:
|
||||
return Status::ObjectStoreFull("object does not fit in the plasma store");
|
||||
default:
|
||||
RAY_LOG(FATAL) << "unknown plasma error code " << static_cast<int>(plasma_error);
|
||||
case fb::PlasmaError::OK:
|
||||
return Status::OK();
|
||||
case fb::PlasmaError::ObjectExists:
|
||||
return Status::ObjectExists("object already exists in the plasma store");
|
||||
case fb::PlasmaError::ObjectNonexistent:
|
||||
return Status::ObjectNotFound("object does not exist in the plasma store");
|
||||
case fb::PlasmaError::OutOfMemory:
|
||||
return Status::ObjectStoreFull("object does not fit in the plasma store");
|
||||
default:
|
||||
RAY_LOG(FATAL) << "unknown plasma error code " << static_cast<int>(plasma_error);
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
// Set options messages.
|
||||
|
||||
Status SendSetOptionsRequest(const std::shared_ptr<StoreConn> &store_conn, const std::string& client_name,
|
||||
Status SendSetOptionsRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::string &client_name,
|
||||
int64_t output_memory_limit) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaSetOptionsRequest(fbb, fbb.CreateString(client_name),
|
||||
|
@ -144,8 +148,8 @@ Status SendSetOptionsRequest(const std::shared_ptr<StoreConn> &store_conn, const
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaSetOptionsRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadSetOptionsRequest(uint8_t* data, size_t size, std::string* client_name,
|
||||
int64_t* output_memory_quota) {
|
||||
Status ReadSetOptionsRequest(uint8_t *data, size_t size, std::string *client_name,
|
||||
int64_t *output_memory_quota) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaSetOptionsRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -160,7 +164,7 @@ Status SendSetOptionsReply(const std::shared_ptr<Client> &client, PlasmaError er
|
|||
return PlasmaSend(client, MessageType::PlasmaSetOptionsReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadSetOptionsReply(uint8_t* data, size_t size) {
|
||||
Status ReadSetOptionsReply(uint8_t *data, size_t size) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaSetOptionsReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -175,13 +179,14 @@ Status SendGetDebugStringRequest(const std::shared_ptr<StoreConn> &store_conn) {
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaGetDebugStringRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status SendGetDebugStringReply(const std::shared_ptr<Client> &client, const std::string& debug_string) {
|
||||
Status SendGetDebugStringReply(const std::shared_ptr<Client> &client,
|
||||
const std::string &debug_string) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaGetDebugStringReply(fbb, fbb.CreateString(debug_string));
|
||||
return PlasmaSend(client, MessageType::PlasmaGetDebugStringReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadGetDebugStringReply(uint8_t* data, size_t size, std::string* debug_string) {
|
||||
Status ReadGetDebugStringReply(uint8_t *data, size_t size, std::string *debug_string) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaGetDebugStringReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -192,24 +197,22 @@ Status ReadGetDebugStringReply(uint8_t* data, size_t size, std::string* debug_st
|
|||
// Create messages.
|
||||
|
||||
Status SendCreateRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id,
|
||||
const ray::rpc::Address& owner_address, bool evict_if_full,
|
||||
const ray::rpc::Address &owner_address, bool evict_if_full,
|
||||
int64_t data_size, int64_t metadata_size, int device_num) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message =
|
||||
fb::CreatePlasmaCreateRequest(fbb, fbb.CreateString(object_id.Binary()),
|
||||
fbb.CreateString(owner_address.raylet_id()),
|
||||
fbb.CreateString(owner_address.ip_address()),
|
||||
owner_address.port(),
|
||||
fbb.CreateString(owner_address.worker_id()),
|
||||
evict_if_full, data_size, metadata_size, device_num);
|
||||
auto message = fb::CreatePlasmaCreateRequest(
|
||||
fbb, fbb.CreateString(object_id.Binary()),
|
||||
fbb.CreateString(owner_address.raylet_id()),
|
||||
fbb.CreateString(owner_address.ip_address()), owner_address.port(),
|
||||
fbb.CreateString(owner_address.worker_id()), evict_if_full, data_size,
|
||||
metadata_size, device_num);
|
||||
return PlasmaSend(store_conn, MessageType::PlasmaCreateRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadCreateRequest(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
NodeID* owner_raylet_id, std::string* owner_ip_address,
|
||||
int* owner_port, WorkerID* owner_worker_id, bool* evict_if_full,
|
||||
int64_t* data_size, int64_t* metadata_size,
|
||||
int* device_num) {
|
||||
Status ReadCreateRequest(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
NodeID *owner_raylet_id, std::string *owner_ip_address,
|
||||
int *owner_port, WorkerID *owner_worker_id, bool *evict_if_full,
|
||||
int64_t *data_size, int64_t *metadata_size, int *device_num) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaCreateRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -225,12 +228,12 @@ Status ReadCreateRequest(uint8_t* data, size_t size, ObjectID* object_id,
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendCreateReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaObject* object,
|
||||
PlasmaError error_code, int64_t mmap_size) {
|
||||
Status SendCreateReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaObject *object, PlasmaError error_code, int64_t mmap_size) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
PlasmaObjectSpec plasma_object(FD2INT(object->store_fd), object->data_offset, object->data_size,
|
||||
object->metadata_offset, object->metadata_size,
|
||||
object->device_num);
|
||||
PlasmaObjectSpec plasma_object(FD2INT(object->store_fd), object->data_offset,
|
||||
object->data_size, object->metadata_offset,
|
||||
object->metadata_size, object->device_num);
|
||||
auto object_string = fbb.CreateString(object_id.Binary());
|
||||
#ifdef PLASMA_CUDA
|
||||
flatbuffers::Offset<fb::CudaHandle> ipc_handle;
|
||||
|
@ -258,8 +261,8 @@ Status SendCreateReply(const std::shared_ptr<Client> &client, ObjectID object_id
|
|||
return PlasmaSend(client, MessageType::PlasmaCreateReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadCreateReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
PlasmaObject* object, MEMFD_TYPE* store_fd, int64_t* mmap_size) {
|
||||
Status ReadCreateReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
PlasmaObject *object, MEMFD_TYPE *store_fd, int64_t *mmap_size) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaCreateReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -284,13 +287,14 @@ Status ReadCreateReply(uint8_t* data, size_t size, ObjectID* object_id,
|
|||
return PlasmaErrorStatus(message->error());
|
||||
}
|
||||
|
||||
Status SendAbortRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id) {
|
||||
Status SendAbortRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
ObjectID object_id) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaAbortRequest(fbb, fbb.CreateString(object_id.Binary()));
|
||||
return PlasmaSend(store_conn, MessageType::PlasmaAbortRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadAbortRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadAbortRequest(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaAbortRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -304,7 +308,7 @@ Status SendAbortReply(const std::shared_ptr<Client> &client, ObjectID object_id)
|
|||
return PlasmaSend(client, MessageType::PlasmaAbortReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadAbortReply(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadAbortReply(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaAbortReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -320,7 +324,7 @@ Status SendSealRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID ob
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaSealRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadSealRequest(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaSealRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -328,14 +332,15 @@ Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendSealReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaError error) {
|
||||
Status SendSealReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaError error) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message =
|
||||
fb::CreatePlasmaSealReply(fbb, fbb.CreateString(object_id.Binary()), error);
|
||||
return PlasmaSend(client, MessageType::PlasmaSealReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadSealReply(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadSealReply(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaSealReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -345,14 +350,15 @@ Status ReadSealReply(uint8_t* data, size_t size, ObjectID* object_id) {
|
|||
|
||||
// Release messages.
|
||||
|
||||
Status SendReleaseRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id) {
|
||||
Status SendReleaseRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
ObjectID object_id) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message =
|
||||
fb::CreatePlasmaReleaseRequest(fbb, fbb.CreateString(object_id.Binary()));
|
||||
return PlasmaSend(store_conn, MessageType::PlasmaReleaseRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadReleaseRequest(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaReleaseRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -360,14 +366,15 @@ Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendReleaseReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaError error) {
|
||||
Status SendReleaseReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaError error) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message =
|
||||
fb::CreatePlasmaReleaseReply(fbb, fbb.CreateString(object_id.Binary()), error);
|
||||
return PlasmaSend(client, MessageType::PlasmaReleaseReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadReleaseReply(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadReleaseReply(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaReleaseReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -377,7 +384,8 @@ Status ReadReleaseReply(uint8_t* data, size_t size, ObjectID* object_id) {
|
|||
|
||||
// Delete objects messages.
|
||||
|
||||
Status SendDeleteRequest(const std::shared_ptr<StoreConn> &store_conn, const std::vector<ObjectID>& object_ids) {
|
||||
Status SendDeleteRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::vector<ObjectID> &object_ids) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaDeleteRequest(
|
||||
fbb, static_cast<int32_t>(object_ids.size()),
|
||||
|
@ -385,34 +393,35 @@ Status SendDeleteRequest(const std::shared_ptr<StoreConn> &store_conn, const std
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaDeleteRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadDeleteRequest(uint8_t* data, size_t size, std::vector<ObjectID>* object_ids) {
|
||||
Status ReadDeleteRequest(uint8_t *data, size_t size, std::vector<ObjectID> *object_ids) {
|
||||
using fb::PlasmaDeleteRequest;
|
||||
|
||||
RAY_DCHECK(data);
|
||||
RAY_DCHECK(object_ids);
|
||||
auto message = flatbuffers::GetRoot<PlasmaDeleteRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
ToVector(*message, object_ids, [](const PlasmaDeleteRequest& request, int i) {
|
||||
ToVector(*message, object_ids, [](const PlasmaDeleteRequest &request, int i) {
|
||||
return ObjectID::FromBinary(request.object_ids()->Get(i)->str());
|
||||
});
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendDeleteReply(const std::shared_ptr<Client> &client, const std::vector<ObjectID>& object_ids,
|
||||
const std::vector<PlasmaError>& errors) {
|
||||
Status SendDeleteReply(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID> &object_ids,
|
||||
const std::vector<PlasmaError> &errors) {
|
||||
RAY_DCHECK(object_ids.size() == errors.size());
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaDeleteReply(
|
||||
fbb, static_cast<int32_t>(object_ids.size()),
|
||||
ToFlatbuffer(&fbb, &object_ids[0], object_ids.size()),
|
||||
fbb.CreateVector(
|
||||
arrow::util::MakeNonNull(reinterpret_cast<const int32_t*>(errors.data())),
|
||||
arrow::util::MakeNonNull(reinterpret_cast<const int32_t *>(errors.data())),
|
||||
object_ids.size()));
|
||||
return PlasmaSend(client, MessageType::PlasmaDeleteReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadDeleteReply(uint8_t* data, size_t size, std::vector<ObjectID>* object_ids,
|
||||
std::vector<PlasmaError>* errors) {
|
||||
Status ReadDeleteReply(uint8_t *data, size_t size, std::vector<ObjectID> *object_ids,
|
||||
std::vector<PlasmaError> *errors) {
|
||||
using fb::PlasmaDeleteReply;
|
||||
|
||||
RAY_DCHECK(data);
|
||||
|
@ -420,10 +429,10 @@ Status ReadDeleteReply(uint8_t* data, size_t size, std::vector<ObjectID>* object
|
|||
RAY_DCHECK(errors);
|
||||
auto message = flatbuffers::GetRoot<PlasmaDeleteReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
ToVector(*message, object_ids, [](const PlasmaDeleteReply& request, int i) {
|
||||
ToVector(*message, object_ids, [](const PlasmaDeleteReply &request, int i) {
|
||||
return ObjectID::FromBinary(request.object_ids()->Get(i)->str());
|
||||
});
|
||||
ToVector(*message, errors, [](const PlasmaDeleteReply& request, int i) {
|
||||
ToVector(*message, errors, [](const PlasmaDeleteReply &request, int i) {
|
||||
return static_cast<PlasmaError>(request.errors()->data()[i]);
|
||||
});
|
||||
return Status::OK();
|
||||
|
@ -431,14 +440,15 @@ Status ReadDeleteReply(uint8_t* data, size_t size, std::vector<ObjectID>* object
|
|||
|
||||
// Contains messages.
|
||||
|
||||
Status SendContainsRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id) {
|
||||
Status SendContainsRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
ObjectID object_id) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message =
|
||||
fb::CreatePlasmaContainsRequest(fbb, fbb.CreateString(object_id.Binary()));
|
||||
return PlasmaSend(store_conn, MessageType::PlasmaContainsRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadContainsRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
||||
Status ReadContainsRequest(uint8_t *data, size_t size, ObjectID *object_id) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaContainsRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -446,15 +456,16 @@ Status ReadContainsRequest(uint8_t* data, size_t size, ObjectID* object_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendContainsReply(const std::shared_ptr<Client> &client, ObjectID object_id, bool has_object) {
|
||||
Status SendContainsReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
bool has_object) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaContainsReply(fbb, fbb.CreateString(object_id.Binary()),
|
||||
has_object);
|
||||
return PlasmaSend(client, MessageType::PlasmaContainsReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadContainsReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
bool* has_object) {
|
||||
Status ReadContainsReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
bool *has_object) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaContainsReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -471,7 +482,7 @@ Status SendConnectRequest(const std::shared_ptr<StoreConn> &store_conn) {
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaConnectRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadConnectRequest(uint8_t* data) { return Status::OK(); }
|
||||
Status ReadConnectRequest(uint8_t *data) { return Status::OK(); }
|
||||
|
||||
Status SendConnectReply(const std::shared_ptr<Client> &client, int64_t memory_capacity) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
@ -479,7 +490,7 @@ Status SendConnectReply(const std::shared_ptr<Client> &client, int64_t memory_ca
|
|||
return PlasmaSend(client, MessageType::PlasmaConnectReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadConnectReply(uint8_t* data, size_t size, int64_t* memory_capacity) {
|
||||
Status ReadConnectReply(uint8_t *data, size_t size, int64_t *memory_capacity) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaConnectReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -495,7 +506,7 @@ Status SendEvictRequest(const std::shared_ptr<StoreConn> &store_conn, int64_t nu
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaEvictRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadEvictRequest(uint8_t* data, size_t size, int64_t* num_bytes) {
|
||||
Status ReadEvictRequest(uint8_t *data, size_t size, int64_t *num_bytes) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaEvictRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -509,7 +520,7 @@ Status SendEvictReply(const std::shared_ptr<Client> &client, int64_t num_bytes)
|
|||
return PlasmaSend(client, MessageType::PlasmaEvictReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadEvictReply(uint8_t* data, size_t size, int64_t& num_bytes) {
|
||||
Status ReadEvictReply(uint8_t *data, size_t size, int64_t &num_bytes) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaEvictReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -519,7 +530,8 @@ Status ReadEvictReply(uint8_t* data, size_t size, int64_t& num_bytes) {
|
|||
|
||||
// Get messages.
|
||||
|
||||
Status SendGetRequest(const std::shared_ptr<StoreConn> &store_conn, const ObjectID* object_ids, int64_t num_objects,
|
||||
Status SendGetRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const ObjectID *object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaGetRequest(
|
||||
|
@ -527,8 +539,8 @@ Status SendGetRequest(const std::shared_ptr<StoreConn> &store_conn, const Object
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaGetRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadGetRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids,
|
||||
int64_t* timeout_ms) {
|
||||
Status ReadGetRequest(uint8_t *data, size_t size, std::vector<ObjectID> &object_ids,
|
||||
int64_t *timeout_ms) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaGetRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -541,15 +553,15 @@ Status ReadGetRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_
|
|||
}
|
||||
|
||||
Status SendGetReply(const std::shared_ptr<Client> &client, ObjectID object_ids[],
|
||||
std::unordered_map<ObjectID, PlasmaObject>& plasma_objects,
|
||||
int64_t num_objects, const std::vector<MEMFD_TYPE>& store_fds,
|
||||
const std::vector<int64_t>& mmap_sizes) {
|
||||
std::unordered_map<ObjectID, PlasmaObject> &plasma_objects,
|
||||
int64_t num_objects, const std::vector<MEMFD_TYPE> &store_fds,
|
||||
const std::vector<int64_t> &mmap_sizes) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
std::vector<PlasmaObjectSpec> objects;
|
||||
|
||||
std::vector<flatbuffers::Offset<fb::CudaHandle>> handles;
|
||||
for (int64_t i = 0; i < num_objects; ++i) {
|
||||
const PlasmaObject& object = plasma_objects[object_ids[i]];
|
||||
const PlasmaObject &object = plasma_objects[object_ids[i]];
|
||||
objects.push_back(PlasmaObjectSpec(FD2INT(object.store_fd), object.data_offset,
|
||||
object.data_size, object.metadata_offset,
|
||||
object.metadata_size, object.device_num));
|
||||
|
@ -569,15 +581,17 @@ Status SendGetReply(const std::shared_ptr<Client> &client, ObjectID object_ids[]
|
|||
auto message = fb::CreatePlasmaGetReply(
|
||||
fbb, ToFlatbuffer(&fbb, object_ids, num_objects),
|
||||
fbb.CreateVectorOfStructs(arrow::util::MakeNonNull(objects.data()), num_objects),
|
||||
fbb.CreateVector(arrow::util::MakeNonNull(store_fds_as_int.data()), store_fds_as_int.size()),
|
||||
fbb.CreateVector(arrow::util::MakeNonNull(store_fds_as_int.data()),
|
||||
store_fds_as_int.size()),
|
||||
fbb.CreateVector(arrow::util::MakeNonNull(mmap_sizes.data()), mmap_sizes.size()),
|
||||
fbb.CreateVector(arrow::util::MakeNonNull(handles.data()), handles.size()));
|
||||
return PlasmaSend(client, MessageType::PlasmaGetReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
|
||||
Status ReadGetReply(uint8_t *data, size_t size, ObjectID object_ids[],
|
||||
PlasmaObject plasma_objects[], int64_t num_objects,
|
||||
std::vector<MEMFD_TYPE>& store_fds, std::vector<int64_t>& mmap_sizes) {
|
||||
std::vector<MEMFD_TYPE> &store_fds,
|
||||
std::vector<int64_t> &mmap_sizes) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaGetReply>(data);
|
||||
#ifdef PLASMA_CUDA
|
||||
|
@ -588,7 +602,7 @@ Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
|
|||
object_ids[i] = ObjectID::FromBinary(message->object_ids()->Get(i)->str());
|
||||
}
|
||||
for (uoffset_t i = 0; i < num_objects; ++i) {
|
||||
const PlasmaObjectSpec* object = message->plasma_objects()->Get(i);
|
||||
const PlasmaObjectSpec *object = message->plasma_objects()->Get(i);
|
||||
plasma_objects[i].store_fd = INT2FD(object->segment_index());
|
||||
plasma_objects[i].data_offset = object->data_offset();
|
||||
plasma_objects[i].data_size = object->data_size();
|
||||
|
@ -597,7 +611,7 @@ Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
|
|||
plasma_objects[i].device_num = object->device_num();
|
||||
#ifdef PLASMA_CUDA
|
||||
if (object->device_num() != 0) {
|
||||
const void* ipc_handle = message->handles()->Get(handle_pos)->handle()->data();
|
||||
const void *ipc_handle = message->handles()->Get(handle_pos)->handle()->data();
|
||||
ARROW_ASSIGN_OR_RAISE(plasma_objects[i].ipc_handle,
|
||||
CudaIpcMemHandle::FromBuffer(ipc_handle));
|
||||
handle_pos++;
|
||||
|
@ -614,7 +628,8 @@ Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
|
|||
|
||||
// Data messages.
|
||||
|
||||
Status SendDataRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id, const char* address, int port) {
|
||||
Status SendDataRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id,
|
||||
const char *address, int port) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto addr = fbb.CreateString(address, strlen(address));
|
||||
auto message =
|
||||
|
@ -622,8 +637,8 @@ Status SendDataRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID ob
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaDataRequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadDataRequest(uint8_t* data, size_t size, ObjectID* object_id, char** address,
|
||||
int* port) {
|
||||
Status ReadDataRequest(uint8_t *data, size_t size, ObjectID *object_id, char **address,
|
||||
int *port) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaDataRequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -638,16 +653,16 @@ Status ReadDataRequest(uint8_t* data, size_t size, ObjectID* object_id, char** a
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SendDataReply(const std::shared_ptr<Client> &client, ObjectID object_id, int64_t object_size,
|
||||
int64_t metadata_size) {
|
||||
Status SendDataReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
int64_t object_size, int64_t metadata_size) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = fb::CreatePlasmaDataReply(fbb, fbb.CreateString(object_id.Binary()),
|
||||
object_size, metadata_size);
|
||||
return PlasmaSend(client, MessageType::PlasmaDataReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
int64_t* object_size, int64_t* metadata_size) {
|
||||
Status ReadDataReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
int64_t *object_size, int64_t *metadata_size) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaDataReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -659,7 +674,8 @@ Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
|
|||
|
||||
// RefreshLRU messages.
|
||||
|
||||
Status SendRefreshLRURequest(const std::shared_ptr<StoreConn> &store_conn, const std::vector<ObjectID>& object_ids) {
|
||||
Status SendRefreshLRURequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::vector<ObjectID> &object_ids) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto message = fb::CreatePlasmaRefreshLRURequest(
|
||||
|
@ -668,8 +684,8 @@ Status SendRefreshLRURequest(const std::shared_ptr<StoreConn> &store_conn, const
|
|||
return PlasmaSend(store_conn, MessageType::PlasmaRefreshLRURequest, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadRefreshLRURequest(uint8_t* data, size_t size,
|
||||
std::vector<ObjectID>* object_ids) {
|
||||
Status ReadRefreshLRURequest(uint8_t *data, size_t size,
|
||||
std::vector<ObjectID> *object_ids) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaRefreshLRURequest>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
@ -686,7 +702,7 @@ Status SendRefreshLRUReply(const std::shared_ptr<Client> &client) {
|
|||
return PlasmaSend(client, MessageType::PlasmaRefreshLRUReply, &fbb, message);
|
||||
}
|
||||
|
||||
Status ReadRefreshLRUReply(uint8_t* data, size_t size) {
|
||||
Status ReadRefreshLRUReply(uint8_t *data, size_t size) {
|
||||
RAY_DCHECK(data);
|
||||
auto message = flatbuffers::GetRoot<fb::PlasmaRefreshLRUReply>(data);
|
||||
RAY_DCHECK(VerifyFlatbuffer(message, data, size));
|
||||
|
|
|
@ -38,45 +38,47 @@ using flatbuf::MessageType;
|
|||
using flatbuf::PlasmaError;
|
||||
|
||||
template <class T>
|
||||
bool VerifyFlatbuffer(T* object, uint8_t* data, size_t size) {
|
||||
bool VerifyFlatbuffer(T *object, uint8_t *data, size_t size) {
|
||||
flatbuffers::Verifier verifier(data, size);
|
||||
return object->Verify(verifier);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb, const ObjectID* object_ids,
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder *fbb, const ObjectID *object_ids,
|
||||
int64_t num_objects);
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder* fbb,
|
||||
const std::vector<std::string>& strings);
|
||||
ToFlatbuffer(flatbuffers::FlatBufferBuilder *fbb,
|
||||
const std::vector<std::string> &strings);
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<int64_t>> ToFlatbuffer(
|
||||
flatbuffers::FlatBufferBuilder* fbb, const std::vector<int64_t>& data);
|
||||
flatbuffers::FlatBufferBuilder *fbb, const std::vector<int64_t> &data);
|
||||
|
||||
/* Plasma receive message. */
|
||||
|
||||
Status PlasmaReceive(const std::shared_ptr<StoreConn> &store_conn, MessageType message_type, std::vector<uint8_t>* buffer);
|
||||
Status PlasmaReceive(const std::shared_ptr<StoreConn> &store_conn,
|
||||
MessageType message_type, std::vector<uint8_t> *buffer);
|
||||
|
||||
/* Set options messages. */
|
||||
|
||||
Status SendSetOptionsRequest(const std::shared_ptr<StoreConn> &store_conn, const std::string& client_name,
|
||||
int64_t output_memory_limit);
|
||||
Status SendSetOptionsRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::string &client_name, int64_t output_memory_limit);
|
||||
|
||||
Status ReadSetOptionsRequest(uint8_t* data, size_t size, std::string* client_name,
|
||||
int64_t* output_memory_quota);
|
||||
Status ReadSetOptionsRequest(uint8_t *data, size_t size, std::string *client_name,
|
||||
int64_t *output_memory_quota);
|
||||
|
||||
Status SendSetOptionsReply(const std::shared_ptr<Client> &client, PlasmaError error);
|
||||
|
||||
Status ReadSetOptionsReply(uint8_t* data, size_t size);
|
||||
Status ReadSetOptionsReply(uint8_t *data, size_t size);
|
||||
|
||||
/* Debug string messages. */
|
||||
|
||||
Status SendGetDebugStringRequest(const std::shared_ptr<StoreConn> &store_conn);
|
||||
|
||||
Status SendGetDebugStringReply(const std::shared_ptr<Client> &client, const std::string& debug_string);
|
||||
Status SendGetDebugStringReply(const std::shared_ptr<Client> &client,
|
||||
const std::string &debug_string);
|
||||
|
||||
Status ReadGetDebugStringReply(uint8_t* data, size_t size, std::string* debug_string);
|
||||
Status ReadGetDebugStringReply(uint8_t *data, size_t size, std::string *debug_string);
|
||||
|
||||
/* Plasma Create message functions. */
|
||||
|
||||
|
@ -84,128 +86,137 @@ Status SendCreateRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID
|
|||
const ray::rpc::Address &owner_address, bool evict_if_full,
|
||||
int64_t data_size, int64_t metadata_size, int device_num);
|
||||
|
||||
Status ReadCreateRequest(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
NodeID* owner_raylet_id, std::string* owner_ip_address,
|
||||
int* owner_port, WorkerID* owner_worker_id, bool* evict_if_full,
|
||||
int64_t* data_size, int64_t* metadata_size,
|
||||
int* device_num);
|
||||
Status ReadCreateRequest(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
NodeID *owner_raylet_id, std::string *owner_ip_address,
|
||||
int *owner_port, WorkerID *owner_worker_id, bool *evict_if_full,
|
||||
int64_t *data_size, int64_t *metadata_size, int *device_num);
|
||||
|
||||
Status SendCreateReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaObject* object,
|
||||
PlasmaError error, int64_t mmap_size);
|
||||
Status SendCreateReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaObject *object, PlasmaError error, int64_t mmap_size);
|
||||
|
||||
Status ReadCreateReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
PlasmaObject* object, MEMFD_TYPE* store_fd, int64_t* mmap_size);
|
||||
Status ReadCreateReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
PlasmaObject *object, MEMFD_TYPE *store_fd, int64_t *mmap_size);
|
||||
|
||||
Status SendAbortRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id);
|
||||
|
||||
Status ReadAbortRequest(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadAbortRequest(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
Status SendAbortReply(const std::shared_ptr<Client> &client, ObjectID object_id);
|
||||
|
||||
Status ReadAbortReply(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadAbortReply(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
/* Plasma Seal message functions. */
|
||||
|
||||
Status SendSealRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id);
|
||||
|
||||
Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadSealRequest(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
Status SendSealReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaError error);
|
||||
Status SendSealReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaError error);
|
||||
|
||||
Status ReadSealReply(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadSealReply(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
/* Plasma Get message functions. */
|
||||
|
||||
Status SendGetRequest(const std::shared_ptr<StoreConn> &store_conn, const ObjectID* object_ids, int64_t num_objects,
|
||||
Status SendGetRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const ObjectID *object_ids, int64_t num_objects,
|
||||
int64_t timeout_ms);
|
||||
|
||||
Status ReadGetRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids,
|
||||
int64_t* timeout_ms);
|
||||
Status ReadGetRequest(uint8_t *data, size_t size, std::vector<ObjectID> &object_ids,
|
||||
int64_t *timeout_ms);
|
||||
|
||||
Status SendGetReply(const std::shared_ptr<Client> &client, ObjectID object_ids[],
|
||||
std::unordered_map<ObjectID, PlasmaObject>& plasma_objects,
|
||||
int64_t num_objects, const std::vector<MEMFD_TYPE>& store_fds,
|
||||
const std::vector<int64_t>& mmap_sizes);
|
||||
std::unordered_map<ObjectID, PlasmaObject> &plasma_objects,
|
||||
int64_t num_objects, const std::vector<MEMFD_TYPE> &store_fds,
|
||||
const std::vector<int64_t> &mmap_sizes);
|
||||
|
||||
Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
|
||||
Status ReadGetReply(uint8_t *data, size_t size, ObjectID object_ids[],
|
||||
PlasmaObject plasma_objects[], int64_t num_objects,
|
||||
std::vector<MEMFD_TYPE>& store_fds, std::vector<int64_t>& mmap_sizes);
|
||||
std::vector<MEMFD_TYPE> &store_fds, std::vector<int64_t> &mmap_sizes);
|
||||
|
||||
/* Plasma Release message functions. */
|
||||
|
||||
Status SendReleaseRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id);
|
||||
Status SendReleaseRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
ObjectID object_id);
|
||||
|
||||
Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadReleaseRequest(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
Status SendReleaseReply(const std::shared_ptr<Client> &client, ObjectID object_id, PlasmaError error);
|
||||
Status SendReleaseReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
PlasmaError error);
|
||||
|
||||
Status ReadReleaseReply(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadReleaseReply(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
/* Plasma Delete objects message functions. */
|
||||
|
||||
Status SendDeleteRequest(const std::shared_ptr<StoreConn> &store_conn, const std::vector<ObjectID>& object_ids);
|
||||
Status SendDeleteRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::vector<ObjectID> &object_ids);
|
||||
|
||||
Status ReadDeleteRequest(uint8_t* data, size_t size, std::vector<ObjectID>* object_ids);
|
||||
Status ReadDeleteRequest(uint8_t *data, size_t size, std::vector<ObjectID> *object_ids);
|
||||
|
||||
Status SendDeleteReply(const std::shared_ptr<Client> &client, const std::vector<ObjectID>& object_ids,
|
||||
const std::vector<PlasmaError>& errors);
|
||||
Status SendDeleteReply(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID> &object_ids,
|
||||
const std::vector<PlasmaError> &errors);
|
||||
|
||||
Status ReadDeleteReply(uint8_t* data, size_t size, std::vector<ObjectID>* object_ids,
|
||||
std::vector<PlasmaError>* errors);
|
||||
Status ReadDeleteReply(uint8_t *data, size_t size, std::vector<ObjectID> *object_ids,
|
||||
std::vector<PlasmaError> *errors);
|
||||
|
||||
/* Plasma Contains message functions. */
|
||||
|
||||
Status SendContainsRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id);
|
||||
Status SendContainsRequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
ObjectID object_id);
|
||||
|
||||
Status ReadContainsRequest(uint8_t* data, size_t size, ObjectID* object_id);
|
||||
Status ReadContainsRequest(uint8_t *data, size_t size, ObjectID *object_id);
|
||||
|
||||
Status SendContainsReply(const std::shared_ptr<Client> &client, ObjectID object_id, bool has_object);
|
||||
Status SendContainsReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
bool has_object);
|
||||
|
||||
Status ReadContainsReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
bool* has_object);
|
||||
Status ReadContainsReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
bool *has_object);
|
||||
|
||||
/* Plasma Connect message functions. */
|
||||
|
||||
Status SendConnectRequest(const std::shared_ptr<StoreConn> &store_conn);
|
||||
|
||||
Status ReadConnectRequest(uint8_t* data, size_t size);
|
||||
Status ReadConnectRequest(uint8_t *data, size_t size);
|
||||
|
||||
Status SendConnectReply(const std::shared_ptr<Client> &client, int64_t memory_capacity);
|
||||
|
||||
Status ReadConnectReply(uint8_t* data, size_t size, int64_t* memory_capacity);
|
||||
Status ReadConnectReply(uint8_t *data, size_t size, int64_t *memory_capacity);
|
||||
|
||||
/* Plasma Evict message functions (no reply so far). */
|
||||
|
||||
Status SendEvictRequest(const std::shared_ptr<StoreConn> &store_conn, int64_t num_bytes);
|
||||
|
||||
Status ReadEvictRequest(uint8_t* data, size_t size, int64_t* num_bytes);
|
||||
Status ReadEvictRequest(uint8_t *data, size_t size, int64_t *num_bytes);
|
||||
|
||||
Status SendEvictReply(const std::shared_ptr<Client> &client, int64_t num_bytes);
|
||||
|
||||
Status ReadEvictReply(uint8_t* data, size_t size, int64_t& num_bytes);
|
||||
Status ReadEvictReply(uint8_t *data, size_t size, int64_t &num_bytes);
|
||||
|
||||
/* Data messages. */
|
||||
|
||||
Status SendDataRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id, const char* address, int port);
|
||||
Status SendDataRequest(const std::shared_ptr<StoreConn> &store_conn, ObjectID object_id,
|
||||
const char *address, int port);
|
||||
|
||||
Status ReadDataRequest(uint8_t* data, size_t size, ObjectID* object_id, char** address,
|
||||
int* port);
|
||||
Status ReadDataRequest(uint8_t *data, size_t size, ObjectID *object_id, char **address,
|
||||
int *port);
|
||||
|
||||
Status SendDataReply(const std::shared_ptr<Client> &client, ObjectID object_id, int64_t object_size,
|
||||
int64_t metadata_size);
|
||||
Status SendDataReply(const std::shared_ptr<Client> &client, ObjectID object_id,
|
||||
int64_t object_size, int64_t metadata_size);
|
||||
|
||||
Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
|
||||
int64_t* object_size, int64_t* metadata_size);
|
||||
Status ReadDataReply(uint8_t *data, size_t size, ObjectID *object_id,
|
||||
int64_t *object_size, int64_t *metadata_size);
|
||||
|
||||
/* Plasma refresh LRU cache functions. */
|
||||
|
||||
Status SendRefreshLRURequest(const std::shared_ptr<StoreConn> &store_conn, const std::vector<ObjectID>& object_ids);
|
||||
Status SendRefreshLRURequest(const std::shared_ptr<StoreConn> &store_conn,
|
||||
const std::vector<ObjectID> &object_ids);
|
||||
|
||||
Status ReadRefreshLRURequest(uint8_t* data, size_t size,
|
||||
std::vector<ObjectID>* object_ids);
|
||||
Status ReadRefreshLRURequest(uint8_t *data, size_t size,
|
||||
std::vector<ObjectID> *object_ids);
|
||||
|
||||
Status SendRefreshLRUReply(const std::shared_ptr<Client> &client);
|
||||
|
||||
Status ReadRefreshLRUReply(uint8_t* data, size_t size);
|
||||
Status ReadRefreshLRUReply(uint8_t *data, size_t size);
|
||||
|
||||
} // namespace plasma
|
||||
|
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
namespace plasma {
|
||||
|
||||
QuotaAwarePolicy::QuotaAwarePolicy(PlasmaStoreInfo* store_info, int64_t max_size)
|
||||
QuotaAwarePolicy::QuotaAwarePolicy(PlasmaStoreInfo *store_info, int64_t max_size)
|
||||
: EvictionPolicy(store_info, max_size) {}
|
||||
|
||||
bool QuotaAwarePolicy::HasQuota(Client* client, bool is_create) {
|
||||
bool QuotaAwarePolicy::HasQuota(Client *client, bool is_create) {
|
||||
if (!is_create) {
|
||||
return false; // no quota enforcement on read requests yet
|
||||
}
|
||||
return per_client_cache_.find(client) != per_client_cache_.end();
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::ObjectCreated(const ObjectID& object_id, Client* client,
|
||||
void QuotaAwarePolicy::ObjectCreated(const ObjectID &object_id, Client *client,
|
||||
bool is_create) {
|
||||
if (HasQuota(client, is_create)) {
|
||||
per_client_cache_[client]->Add(object_id, GetObjectSize(object_id));
|
||||
|
@ -46,7 +46,7 @@ void QuotaAwarePolicy::ObjectCreated(const ObjectID& object_id, Client* client,
|
|||
}
|
||||
}
|
||||
|
||||
bool QuotaAwarePolicy::SetClientQuota(Client* client, int64_t output_memory_quota) {
|
||||
bool QuotaAwarePolicy::SetClientQuota(Client *client, int64_t output_memory_quota) {
|
||||
if (per_client_cache_.find(client) != per_client_cache_.end()) {
|
||||
RAY_LOG(WARNING) << "Cannot change the client quota once set";
|
||||
return false;
|
||||
|
@ -65,17 +65,16 @@ bool QuotaAwarePolicy::SetClientQuota(Client* client, int64_t output_memory_quot
|
|||
return true;
|
||||
}
|
||||
|
||||
bool QuotaAwarePolicy::EnforcePerClientQuota(Client* client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID>* objects_to_evict) {
|
||||
bool QuotaAwarePolicy::EnforcePerClientQuota(Client *client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID> *objects_to_evict) {
|
||||
if (!HasQuota(client, is_create)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto& client_cache = per_client_cache_[client];
|
||||
auto &client_cache = per_client_cache_[client];
|
||||
if (size > client_cache->Capacity()) {
|
||||
RAY_LOG(WARNING) << "object too large (" << size
|
||||
<< " bytes) to fit in client quota " << client_cache->Capacity()
|
||||
<< " " << DebugString();
|
||||
RAY_LOG(WARNING) << "object too large (" << size << " bytes) to fit in client quota "
|
||||
<< client_cache->Capacity() << " " << DebugString();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -87,7 +86,7 @@ bool QuotaAwarePolicy::EnforcePerClientQuota(Client* client, int64_t size, bool
|
|||
if (space_to_free > 0) {
|
||||
std::vector<ObjectID> candidates;
|
||||
client_cache->ChooseObjectsToEvict(space_to_free, &candidates);
|
||||
for (ObjectID& object_id : candidates) {
|
||||
for (ObjectID &object_id : candidates) {
|
||||
if (shared_for_read_.count(object_id)) {
|
||||
// Pinned so we can't evict it, so demote the object to global LRU instead.
|
||||
// We an do this by simply removing it from all data structures, so that
|
||||
|
@ -103,7 +102,7 @@ bool QuotaAwarePolicy::EnforcePerClientQuota(Client* client, int64_t size, bool
|
|||
return true;
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::BeginObjectAccess(const ObjectID& object_id) {
|
||||
void QuotaAwarePolicy::BeginObjectAccess(const ObjectID &object_id) {
|
||||
if (owned_by_client_.find(object_id) != owned_by_client_.end()) {
|
||||
shared_for_read_.insert(object_id);
|
||||
pinned_memory_bytes_ += GetObjectSize(object_id);
|
||||
|
@ -112,7 +111,7 @@ void QuotaAwarePolicy::BeginObjectAccess(const ObjectID& object_id) {
|
|||
EvictionPolicy::BeginObjectAccess(object_id);
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::EndObjectAccess(const ObjectID& object_id) {
|
||||
void QuotaAwarePolicy::EndObjectAccess(const ObjectID &object_id) {
|
||||
if (owned_by_client_.find(object_id) != owned_by_client_.end()) {
|
||||
shared_for_read_.erase(object_id);
|
||||
pinned_memory_bytes_ -= GetObjectSize(object_id);
|
||||
|
@ -121,7 +120,7 @@ void QuotaAwarePolicy::EndObjectAccess(const ObjectID& object_id) {
|
|||
EvictionPolicy::EndObjectAccess(object_id);
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::RemoveObject(const ObjectID& object_id) {
|
||||
void QuotaAwarePolicy::RemoveObject(const ObjectID &object_id) {
|
||||
if (owned_by_client_.find(object_id) != owned_by_client_.end()) {
|
||||
per_client_cache_[owned_by_client_[object_id]]->Remove(object_id);
|
||||
owned_by_client_.erase(object_id);
|
||||
|
@ -131,8 +130,8 @@ void QuotaAwarePolicy::RemoveObject(const ObjectID& object_id) {
|
|||
EvictionPolicy::RemoveObject(object_id);
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::RefreshObjects(const std::vector<ObjectID>& object_ids) {
|
||||
for (const auto& object_id : object_ids) {
|
||||
void QuotaAwarePolicy::RefreshObjects(const std::vector<ObjectID> &object_ids) {
|
||||
for (const auto &object_id : object_ids) {
|
||||
if (owned_by_client_.find(object_id) != owned_by_client_.end()) {
|
||||
int64_t size = per_client_cache_[owned_by_client_[object_id]]->Remove(object_id);
|
||||
per_client_cache_[owned_by_client_[object_id]]->Add(object_id, size);
|
||||
|
@ -141,14 +140,14 @@ void QuotaAwarePolicy::RefreshObjects(const std::vector<ObjectID>& object_ids) {
|
|||
EvictionPolicy::RefreshObjects(object_ids);
|
||||
}
|
||||
|
||||
void QuotaAwarePolicy::ClientDisconnected(Client* client) {
|
||||
void QuotaAwarePolicy::ClientDisconnected(Client *client) {
|
||||
if (per_client_cache_.find(client) == per_client_cache_.end()) {
|
||||
return;
|
||||
}
|
||||
// return capacity back to global LRU
|
||||
cache_.AdjustCapacity(per_client_cache_[client]->Capacity());
|
||||
// clean up any entries used to track this client's quota usage
|
||||
per_client_cache_[client]->Foreach([this](const ObjectID& obj) {
|
||||
per_client_cache_[client]->Foreach([this](const ObjectID &obj) {
|
||||
if (!shared_for_read_.count(obj)) {
|
||||
// only add it to the global LRU if we have it in pinned mode
|
||||
// otherwise, EndObjectAccess will add it later
|
||||
|
@ -169,7 +168,7 @@ std::string QuotaAwarePolicy::DebugString() const {
|
|||
result << "\nallocation limit: " << PlasmaAllocator::GetFootprintLimit();
|
||||
result << "\npinned bytes: " << pinned_memory_bytes_;
|
||||
result << cache_.DebugString();
|
||||
for (const auto& pair : per_client_cache_) {
|
||||
for (const auto &pair : per_client_cache_) {
|
||||
result << pair.second->DebugString();
|
||||
}
|
||||
return result.str();
|
||||
|
|
|
@ -59,27 +59,27 @@ class QuotaAwarePolicy : public EvictionPolicy {
|
|||
/// \param store_info Information about the Plasma store that is exposed
|
||||
/// to the eviction policy.
|
||||
/// \param max_size Max size in bytes total of objects to store.
|
||||
explicit QuotaAwarePolicy(PlasmaStoreInfo* store_info, int64_t max_size);
|
||||
void ObjectCreated(const ObjectID& object_id, Client* client, bool is_create) override;
|
||||
bool SetClientQuota(Client* client, int64_t output_memory_quota) override;
|
||||
bool EnforcePerClientQuota(Client* client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID>* objects_to_evict) override;
|
||||
void ClientDisconnected(Client* client) override;
|
||||
void BeginObjectAccess(const ObjectID& object_id) override;
|
||||
void EndObjectAccess(const ObjectID& object_id) override;
|
||||
void RemoveObject(const ObjectID& object_id) override;
|
||||
void RefreshObjects(const std::vector<ObjectID>& object_ids) override;
|
||||
explicit QuotaAwarePolicy(PlasmaStoreInfo *store_info, int64_t max_size);
|
||||
void ObjectCreated(const ObjectID &object_id, Client *client, bool is_create) override;
|
||||
bool SetClientQuota(Client *client, int64_t output_memory_quota) override;
|
||||
bool EnforcePerClientQuota(Client *client, int64_t size, bool is_create,
|
||||
std::vector<ObjectID> *objects_to_evict) override;
|
||||
void ClientDisconnected(Client *client) override;
|
||||
void BeginObjectAccess(const ObjectID &object_id) override;
|
||||
void EndObjectAccess(const ObjectID &object_id) override;
|
||||
void RemoveObject(const ObjectID &object_id) override;
|
||||
void RefreshObjects(const std::vector<ObjectID> &object_ids) override;
|
||||
std::string DebugString() const override;
|
||||
|
||||
private:
|
||||
/// Returns whether we are enforcing memory quotas for an operation.
|
||||
bool HasQuota(Client* client, bool is_create);
|
||||
bool HasQuota(Client *client, bool is_create);
|
||||
|
||||
/// Per-client LRU caches, if quota is enabled.
|
||||
std::unordered_map<Client*, std::unique_ptr<LRUCache>> per_client_cache_;
|
||||
std::unordered_map<Client *, std::unique_ptr<LRUCache>> per_client_cache_;
|
||||
/// Tracks which client created which object. This only applies to clients
|
||||
/// that have a memory quota set.
|
||||
std::unordered_map<ObjectID, Client*> owned_by_client_;
|
||||
std::unordered_map<ObjectID, Client *> owned_by_client_;
|
||||
/// Tracks which objects are mapped for read and hence can't be evicted.
|
||||
/// However these objects are still tracked within the client caches.
|
||||
std::unordered_set<ObjectID> shared_for_read_;
|
||||
|
|
|
@ -18,14 +18,15 @@ ClientMmapTableEntry::ClientMmapTableEntry(MEMFD_TYPE fd, int64_t map_size)
|
|||
// in fake_mmap in malloc.h, to make map_size page-aligned again.
|
||||
length_ = map_size - kMmapRegionsGap;
|
||||
#ifdef _WIN32
|
||||
pointer_ = reinterpret_cast<uint8_t*>(MapViewOfFile(fd, FILE_MAP_ALL_ACCESS, 0, 0, length_));
|
||||
pointer_ =
|
||||
reinterpret_cast<uint8_t *>(MapViewOfFile(fd, FILE_MAP_ALL_ACCESS, 0, 0, length_));
|
||||
// TODO(pcm): Don't fail here, instead return a Status.
|
||||
if (pointer_ == NULL) {
|
||||
RAY_LOG(FATAL) << "mmap failed";
|
||||
}
|
||||
CloseHandle(fd); // Closing this fd has an effect on performance.
|
||||
#else
|
||||
pointer_ = reinterpret_cast<uint8_t*>(
|
||||
pointer_ = reinterpret_cast<uint8_t *>(
|
||||
mmap(NULL, length_, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
|
||||
// TODO(pcm): Don't fail here, instead return a Status.
|
||||
if (pointer_ == MAP_FAILED) {
|
||||
|
|
|
@ -14,7 +14,7 @@ class ClientMmapTableEntry {
|
|||
|
||||
~ClientMmapTableEntry();
|
||||
|
||||
uint8_t* pointer() { return pointer_; }
|
||||
uint8_t *pointer() { return pointer_; }
|
||||
|
||||
MEMFD_TYPE fd() { return fd_; }
|
||||
|
||||
|
@ -22,7 +22,7 @@ class ClientMmapTableEntry {
|
|||
/// The associated file descriptor on the client.
|
||||
MEMFD_TYPE fd_;
|
||||
/// The result of mmap for this file descriptor.
|
||||
uint8_t* pointer_;
|
||||
uint8_t *pointer_;
|
||||
/// The length of the memory-mapped file.
|
||||
size_t length_;
|
||||
|
||||
|
|
|
@ -65,19 +65,20 @@ namespace fb = plasma::flatbuf;
|
|||
namespace {
|
||||
|
||||
ray::ObjectID GetCreateRequestObjectId(const std::vector<uint8_t> &message) {
|
||||
uint8_t* input = (uint8_t*)message.data();
|
||||
uint8_t *input = (uint8_t *)message.data();
|
||||
size_t input_size = message.size();
|
||||
auto request = flatbuffers::GetRoot<fb::PlasmaCreateRequest>(input);
|
||||
RAY_DCHECK(plasma::VerifyFlatbuffer(request, input, input_size));
|
||||
return ray::ObjectID::FromBinary(request->object_id()->str());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace plasma {
|
||||
|
||||
struct GetRequest {
|
||||
GetRequest(boost::asio::io_service& io_context, const std::shared_ptr<Client> &client, const std::vector<ObjectID>& object_ids);
|
||||
GetRequest(boost::asio::io_service &io_context, const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID> &object_ids);
|
||||
/// The client that called get.
|
||||
std::shared_ptr<Client> client;
|
||||
/// The object IDs involved in this request. This is used in the reply.
|
||||
|
@ -92,7 +93,7 @@ struct GetRequest {
|
|||
int64_t num_satisfied;
|
||||
|
||||
void AsyncWait(int64_t timeout_ms,
|
||||
std::function<void(const boost::system::error_code&)> on_timeout) {
|
||||
std::function<void(const boost::system::error_code &)> on_timeout) {
|
||||
// Set an expiry time relative to now.
|
||||
timer_.expires_from_now(std::chrono::milliseconds(timeout_ms));
|
||||
timer_.async_wait(on_timeout);
|
||||
|
@ -106,7 +107,9 @@ struct GetRequest {
|
|||
boost::asio::steady_timer timer_;
|
||||
};
|
||||
|
||||
GetRequest::GetRequest(boost::asio::io_service& io_context, const std::shared_ptr<Client> &client, const std::vector<ObjectID>& object_ids)
|
||||
GetRequest::GetRequest(boost::asio::io_service &io_context,
|
||||
const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID> &object_ids)
|
||||
: client(client),
|
||||
object_ids(object_ids.begin(), object_ids.end()),
|
||||
objects(object_ids.size()),
|
||||
|
@ -116,8 +119,8 @@ GetRequest::GetRequest(boost::asio::io_service& io_context, const std::shared_pt
|
|||
num_objects_to_wait_for = unique_ids.size();
|
||||
}
|
||||
|
||||
PlasmaStore::PlasmaStore(boost::asio::io_service &main_service, std::string directory, bool hugepages_enabled,
|
||||
const std::string& socket_name,
|
||||
PlasmaStore::PlasmaStore(boost::asio::io_service &main_service, std::string directory,
|
||||
bool hugepages_enabled, const std::string &socket_name,
|
||||
std::shared_ptr<ExternalStore> external_store,
|
||||
ray::SpillObjectsCallback spill_objects_callback)
|
||||
: io_context_(main_service),
|
||||
|
@ -145,15 +148,13 @@ void PlasmaStore::Start() {
|
|||
DoAccept();
|
||||
}
|
||||
|
||||
void PlasmaStore::Stop() {
|
||||
acceptor_.close();
|
||||
}
|
||||
void PlasmaStore::Stop() { acceptor_.close(); }
|
||||
|
||||
const PlasmaStoreInfo* PlasmaStore::GetPlasmaStoreInfo() { return &store_info_; }
|
||||
const PlasmaStoreInfo *PlasmaStore::GetPlasmaStoreInfo() { return &store_info_; }
|
||||
|
||||
// If this client is not already using the object, add the client to the
|
||||
// object's list of clients, otherwise do nothing.
|
||||
void PlasmaStore::AddToClientObjectIds(const ObjectID& object_id, ObjectTableEntry* entry,
|
||||
void PlasmaStore::AddToClientObjectIds(const ObjectID &object_id, ObjectTableEntry *entry,
|
||||
const std::shared_ptr<Client> &client) {
|
||||
// Check if this client is already using the object.
|
||||
if (client->object_ids.find(object_id) != client->object_ids.end()) {
|
||||
|
@ -173,8 +174,9 @@ void PlasmaStore::AddToClientObjectIds(const ObjectID& object_id, ObjectTableEnt
|
|||
}
|
||||
|
||||
// Allocate memory
|
||||
uint8_t* PlasmaStore::AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE* fd,
|
||||
int64_t* map_size, ptrdiff_t* offset, const std::shared_ptr<Client> &client,
|
||||
uint8_t *PlasmaStore::AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE *fd,
|
||||
int64_t *map_size, ptrdiff_t *offset,
|
||||
const std::shared_ptr<Client> &client,
|
||||
bool is_create, PlasmaError *error) {
|
||||
// First free up space from the client's LRU queue if quota enforcement is on.
|
||||
if (evict_if_full) {
|
||||
|
@ -189,7 +191,7 @@ uint8_t* PlasmaStore::AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE
|
|||
}
|
||||
|
||||
// Try to evict objects until there is enough space.
|
||||
uint8_t* pointer = nullptr;
|
||||
uint8_t *pointer = nullptr;
|
||||
while (true) {
|
||||
// Allocate space for the new object. We use memalign instead of malloc
|
||||
// in order to align the allocated region to a 64-byte boundary. This is not
|
||||
|
@ -198,7 +200,7 @@ uint8_t* PlasmaStore::AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE
|
|||
// plasma_client.cc). Note that even though this pointer is 64-byte aligned,
|
||||
// it is not guaranteed that the corresponding pointer in the client will be
|
||||
// 64-byte aligned, but in practice it often will be.
|
||||
pointer = reinterpret_cast<uint8_t*>(PlasmaAllocator::Memalign(kBlockSize, size));
|
||||
pointer = reinterpret_cast<uint8_t *>(PlasmaAllocator::Memalign(kBlockSize, size));
|
||||
if (pointer || !evict_if_full) {
|
||||
// If we manage to allocate the memory, return the pointer. If we cannot
|
||||
// allocate the space, but we are also not allowed to evict anything to
|
||||
|
@ -250,25 +252,26 @@ uint8_t* PlasmaStore::AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE
|
|||
|
||||
#ifdef PLASMA_CUDA
|
||||
Status PlasmaStore::AllocateCudaMemory(
|
||||
int device_num, int64_t size, uint8_t** out_pointer,
|
||||
std::shared_ptr<CudaIpcMemHandle>* out_ipc_handle) {
|
||||
int device_num, int64_t size, uint8_t **out_pointer,
|
||||
std::shared_ptr<CudaIpcMemHandle> *out_ipc_handle) {
|
||||
DCHECK_NE(device_num, 0);
|
||||
ARROW_ASSIGN_OR_RAISE(auto context, manager_->GetContext(device_num - 1));
|
||||
ARROW_ASSIGN_OR_RAISE(auto cuda_buffer, context->Allocate(static_cast<int64_t>(size)));
|
||||
*out_pointer = reinterpret_cast<uint8_t*>(cuda_buffer->address());
|
||||
*out_pointer = reinterpret_cast<uint8_t *>(cuda_buffer->address());
|
||||
// The IPC handle will keep the buffer memory alive
|
||||
return cuda_buffer->ExportForIpc().Value(out_ipc_handle);
|
||||
}
|
||||
|
||||
Status PlasmaStore::FreeCudaMemory(int device_num, int64_t size, uint8_t* pointer) {
|
||||
Status PlasmaStore::FreeCudaMemory(int device_num, int64_t size, uint8_t *pointer) {
|
||||
ARROW_ASSIGN_OR_RAISE(auto context, manager_->GetContext(device_num - 1));
|
||||
RAY_RETURN_NOT_OK(context->Free(pointer, size));
|
||||
return Status::OK();
|
||||
}
|
||||
#endif
|
||||
|
||||
Status PlasmaStore::HandleCreateObjectRequest(const std::shared_ptr<Client> &client, const std::vector<uint8_t> &message) {
|
||||
uint8_t* input = (uint8_t*)message.data();
|
||||
Status PlasmaStore::HandleCreateObjectRequest(const std::shared_ptr<Client> &client,
|
||||
const std::vector<uint8_t> &message) {
|
||||
uint8_t *input = (uint8_t *)message.data();
|
||||
size_t input_size = message.size();
|
||||
ObjectID object_id;
|
||||
PlasmaObject object = {};
|
||||
|
@ -282,22 +285,23 @@ Status PlasmaStore::HandleCreateObjectRequest(const std::shared_ptr<Client> &cli
|
|||
int64_t metadata_size;
|
||||
int device_num;
|
||||
RAY_RETURN_NOT_OK(ReadCreateRequest(
|
||||
input, input_size, &object_id, &owner_raylet_id, &owner_ip_address, &owner_port,
|
||||
&owner_worker_id, &evict_if_full, &data_size, &metadata_size, &device_num));
|
||||
PlasmaError error_code = CreateObject(object_id, owner_raylet_id, owner_ip_address,
|
||||
owner_port, owner_worker_id, evict_if_full,
|
||||
data_size, metadata_size, device_num, client,
|
||||
&object);
|
||||
input, input_size, &object_id, &owner_raylet_id, &owner_ip_address, &owner_port,
|
||||
&owner_worker_id, &evict_if_full, &data_size, &metadata_size, &device_num));
|
||||
PlasmaError error_code = CreateObject(
|
||||
object_id, owner_raylet_id, owner_ip_address, owner_port, owner_worker_id,
|
||||
evict_if_full, data_size, metadata_size, device_num, client, &object);
|
||||
Status status;
|
||||
if (error_code == PlasmaError::TransientOutOfMemory) {
|
||||
RAY_LOG(DEBUG) << "Create object " << object_id << " failed, waiting for object spill";
|
||||
status = Status::TransientObjectStoreFull("Object store full, queueing creation request");
|
||||
RAY_LOG(DEBUG) << "Create object " << object_id
|
||||
<< " failed, waiting for object spill";
|
||||
status =
|
||||
Status::TransientObjectStoreFull("Object store full, queueing creation request");
|
||||
} else if (error_code == PlasmaError::OutOfMemory) {
|
||||
RAY_LOG(ERROR) << "Not enough memory to create the object " << object_id
|
||||
<< ", data_size=" << data_size
|
||||
<< ", metadata_size=" << metadata_size
|
||||
<< ", will send a reply of PlasmaError::OutOfMemory";
|
||||
RAY_RETURN_NOT_OK(SendCreateReply(client, object_id, &object, error_code, /*mmap_size=*/0));
|
||||
<< ", data_size=" << data_size << ", metadata_size=" << metadata_size
|
||||
<< ", will send a reply of PlasmaError::OutOfMemory";
|
||||
RAY_RETURN_NOT_OK(
|
||||
SendCreateReply(client, object_id, &object, error_code, /*mmap_size=*/0));
|
||||
} else {
|
||||
int64_t mmap_size = 0;
|
||||
if (error_code == PlasmaError::OK && device_num == 0) {
|
||||
|
@ -313,14 +317,11 @@ Status PlasmaStore::HandleCreateObjectRequest(const std::shared_ptr<Client> &cli
|
|||
}
|
||||
|
||||
// Create a new object buffer in the hash table.
|
||||
PlasmaError PlasmaStore::CreateObject(const ObjectID& object_id,
|
||||
const NodeID& owner_raylet_id,
|
||||
const std::string& owner_ip_address,
|
||||
int owner_port, const WorkerID& owner_worker_id,
|
||||
bool evict_if_full, int64_t data_size,
|
||||
int64_t metadata_size, int device_num,
|
||||
const std::shared_ptr<Client> &client,
|
||||
PlasmaObject* result) {
|
||||
PlasmaError PlasmaStore::CreateObject(
|
||||
const ObjectID &object_id, const NodeID &owner_raylet_id,
|
||||
const std::string &owner_ip_address, int owner_port, const WorkerID &owner_worker_id,
|
||||
bool evict_if_full, int64_t data_size, int64_t metadata_size, int device_num,
|
||||
const std::shared_ptr<Client> &client, PlasmaObject *result) {
|
||||
RAY_LOG(DEBUG) << "creating object " << object_id.Hex() << " size " << data_size;
|
||||
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
|
@ -333,13 +334,13 @@ PlasmaError PlasmaStore::CreateObject(const ObjectID& object_id,
|
|||
MEMFD_TYPE fd = INVALID_FD;
|
||||
int64_t map_size = 0;
|
||||
ptrdiff_t offset = 0;
|
||||
uint8_t* pointer = nullptr;
|
||||
uint8_t *pointer = nullptr;
|
||||
auto total_size = data_size + metadata_size;
|
||||
|
||||
if (device_num == 0) {
|
||||
PlasmaError error = PlasmaError::OK;
|
||||
pointer =
|
||||
AllocateMemory(total_size, evict_if_full, &fd, &map_size, &offset, client, true, &error);
|
||||
pointer = AllocateMemory(total_size, evict_if_full, &fd, &map_size, &offset, client,
|
||||
true, &error);
|
||||
if (!pointer) {
|
||||
return error;
|
||||
}
|
||||
|
@ -396,7 +397,7 @@ PlasmaError PlasmaStore::CreateObject(const ObjectID& object_id,
|
|||
return PlasmaError::OK;
|
||||
}
|
||||
|
||||
void PlasmaObject_init(PlasmaObject* object, ObjectTableEntry* entry) {
|
||||
void PlasmaObject_init(PlasmaObject *object, ObjectTableEntry *entry) {
|
||||
RAY_DCHECK(object != nullptr);
|
||||
RAY_DCHECK(entry != nullptr);
|
||||
RAY_DCHECK(entry->state == ObjectState::PLASMA_SEALED);
|
||||
|
@ -413,14 +414,14 @@ void PlasmaObject_init(PlasmaObject* object, ObjectTableEntry* entry) {
|
|||
object->device_num = entry->device_num;
|
||||
}
|
||||
|
||||
void PlasmaStore::RemoveGetRequest(GetRequest* get_request) {
|
||||
void PlasmaStore::RemoveGetRequest(GetRequest *get_request) {
|
||||
// Remove the get request from each of the relevant object_get_requests hash
|
||||
// tables if it is present there. It should only be present there if the get
|
||||
// request timed out or if it was issued by a client that has disconnected.
|
||||
for (ObjectID& object_id : get_request->object_ids) {
|
||||
for (ObjectID &object_id : get_request->object_ids) {
|
||||
auto object_request_iter = object_get_requests_.find(object_id);
|
||||
if (object_request_iter != object_get_requests_.end()) {
|
||||
auto& get_requests = object_request_iter->second;
|
||||
auto &get_requests = object_request_iter->second;
|
||||
// Erase get_req from the vector.
|
||||
auto it = std::find(get_requests.begin(), get_requests.end(), get_request);
|
||||
if (it != get_requests.end()) {
|
||||
|
@ -438,9 +439,9 @@ void PlasmaStore::RemoveGetRequest(GetRequest* get_request) {
|
|||
}
|
||||
|
||||
void PlasmaStore::RemoveGetRequestsForClient(const std::shared_ptr<Client> &client) {
|
||||
std::unordered_set<GetRequest*> get_requests_to_remove;
|
||||
for (auto const& pair : object_get_requests_) {
|
||||
for (GetRequest* get_request : pair.second) {
|
||||
std::unordered_set<GetRequest *> get_requests_to_remove;
|
||||
for (auto const &pair : object_get_requests_) {
|
||||
for (GetRequest *get_request : pair.second) {
|
||||
if (get_request->client == client) {
|
||||
get_requests_to_remove.insert(get_request);
|
||||
}
|
||||
|
@ -450,18 +451,18 @@ void PlasmaStore::RemoveGetRequestsForClient(const std::shared_ptr<Client> &clie
|
|||
// It shouldn't be possible for a given client to be in the middle of multiple get
|
||||
// requests.
|
||||
RAY_CHECK(get_requests_to_remove.size() <= 1);
|
||||
for (GetRequest* get_request : get_requests_to_remove) {
|
||||
for (GetRequest *get_request : get_requests_to_remove) {
|
||||
RemoveGetRequest(get_request);
|
||||
}
|
||||
}
|
||||
|
||||
void PlasmaStore::ReturnFromGet(GetRequest* get_req) {
|
||||
void PlasmaStore::ReturnFromGet(GetRequest *get_req) {
|
||||
// Figure out how many file descriptors we need to send.
|
||||
std::unordered_set<MEMFD_TYPE> fds_to_send;
|
||||
std::vector<MEMFD_TYPE> store_fds;
|
||||
std::vector<int64_t> mmap_sizes;
|
||||
for (const auto& object_id : get_req->object_ids) {
|
||||
PlasmaObject& object = get_req->objects[object_id];
|
||||
for (const auto &object_id : get_req->object_ids) {
|
||||
PlasmaObject &object = get_req->objects[object_id];
|
||||
MEMFD_TYPE fd = object.store_fd;
|
||||
if (object.data_size != -1 && fds_to_send.count(fd) == 0 && fd != INVALID_FD) {
|
||||
fds_to_send.insert(fd);
|
||||
|
@ -479,7 +480,8 @@ void PlasmaStore::ReturnFromGet(GetRequest* get_req) {
|
|||
for (MEMFD_TYPE store_fd : store_fds) {
|
||||
Status send_fd_status = get_req->client->SendFd(store_fd);
|
||||
if (!send_fd_status.ok()) {
|
||||
RAY_LOG(ERROR) << "Failed to send mmap results to client on fd " << get_req->client;
|
||||
RAY_LOG(ERROR) << "Failed to send mmap results to client on fd "
|
||||
<< get_req->client;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -492,14 +494,14 @@ void PlasmaStore::ReturnFromGet(GetRequest* get_req) {
|
|||
RemoveGetRequest(get_req);
|
||||
}
|
||||
|
||||
void PlasmaStore::UpdateObjectGetRequests(const ObjectID& object_id) {
|
||||
void PlasmaStore::UpdateObjectGetRequests(const ObjectID &object_id) {
|
||||
auto it = object_get_requests_.find(object_id);
|
||||
// If there are no get requests involving this object, then return.
|
||||
if (it == object_get_requests_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& get_requests = it->second;
|
||||
auto &get_requests = it->second;
|
||||
|
||||
// After finishing the loop below, get_requests and it will have been
|
||||
// invalidated by the removal of object_id from object_get_requests_.
|
||||
|
@ -537,12 +539,12 @@ void PlasmaStore::UpdateObjectGetRequests(const ObjectID& object_id) {
|
|||
}
|
||||
|
||||
void PlasmaStore::ProcessGetRequest(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID>& object_ids,
|
||||
const std::vector<ObjectID> &object_ids,
|
||||
int64_t timeout_ms) {
|
||||
// Create a get request for this object.
|
||||
auto get_req = new GetRequest(io_context_, client, object_ids);
|
||||
std::vector<ObjectID> evicted_ids;
|
||||
std::vector<ObjectTableEntry*> evicted_entries;
|
||||
std::vector<ObjectTableEntry *> evicted_entries;
|
||||
for (auto object_id : object_ids) {
|
||||
// Check if this object is already present locally. If so, record that the
|
||||
// object is being used and mark it as accounted for.
|
||||
|
@ -559,10 +561,9 @@ void PlasmaStore::ProcessGetRequest(const std::shared_ptr<Client> &client,
|
|||
RAY_CHECK(!entry->pointer);
|
||||
|
||||
PlasmaError error = PlasmaError::OK;
|
||||
entry->pointer =
|
||||
AllocateMemory(entry->data_size + entry->metadata_size, /*evict=*/true,
|
||||
&entry->fd, &entry->map_size, &entry->offset, client,
|
||||
false, &error);
|
||||
entry->pointer = AllocateMemory(entry->data_size + entry->metadata_size,
|
||||
/*evict=*/true, &entry->fd, &entry->map_size,
|
||||
&entry->offset, client, false, &error);
|
||||
if (entry->pointer) {
|
||||
entry->state = ObjectState::PLASMA_CREATED;
|
||||
entry->create_time = std::time(nullptr);
|
||||
|
@ -618,7 +619,7 @@ void PlasmaStore::ProcessGetRequest(const std::shared_ptr<Client> &client,
|
|||
} else if (timeout_ms != -1) {
|
||||
// Set a timer that will cause the get request to return to the client. Note
|
||||
// that a timeout of -1 is used to indicate that no timer should be set.
|
||||
get_req->AsyncWait(timeout_ms, [this, get_req](const boost::system::error_code& ec) {
|
||||
get_req->AsyncWait(timeout_ms, [this, get_req](const boost::system::error_code &ec) {
|
||||
if (ec != boost::asio::error::operation_aborted) {
|
||||
// Timer was not cancelled, take necessary action.
|
||||
ReturnFromGet(get_req);
|
||||
|
@ -627,8 +628,9 @@ void PlasmaStore::ProcessGetRequest(const std::shared_ptr<Client> &client,
|
|||
}
|
||||
}
|
||||
|
||||
int PlasmaStore::RemoveFromClientObjectIds(const ObjectID& object_id,
|
||||
ObjectTableEntry* entry, const std::shared_ptr<Client> &client) {
|
||||
int PlasmaStore::RemoveFromClientObjectIds(const ObjectID &object_id,
|
||||
ObjectTableEntry *entry,
|
||||
const std::shared_ptr<Client> &client) {
|
||||
auto it = client->object_ids.find(object_id);
|
||||
if (it != client->object_ids.end()) {
|
||||
client->object_ids.erase(it);
|
||||
|
@ -657,8 +659,8 @@ int PlasmaStore::RemoveFromClientObjectIds(const ObjectID& object_id,
|
|||
}
|
||||
}
|
||||
|
||||
void PlasmaStore::EraseFromObjectTable(const ObjectID& object_id) {
|
||||
auto& object = store_info_.objects[object_id];
|
||||
void PlasmaStore::EraseFromObjectTable(const ObjectID &object_id) {
|
||||
auto &object = store_info_.objects[object_id];
|
||||
auto buff_size = object->data_size + object->metadata_size;
|
||||
if (object->device_num == 0) {
|
||||
PlasmaAllocator::Free(object->pointer, buff_size);
|
||||
|
@ -670,7 +672,8 @@ void PlasmaStore::EraseFromObjectTable(const ObjectID& object_id) {
|
|||
store_info_.objects.erase(object_id);
|
||||
}
|
||||
|
||||
void PlasmaStore::ReleaseObject(const ObjectID& object_id, const std::shared_ptr<Client> &client) {
|
||||
void PlasmaStore::ReleaseObject(const ObjectID &object_id,
|
||||
const std::shared_ptr<Client> &client) {
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
RAY_CHECK(entry != nullptr);
|
||||
// Remove the client from the object's array of clients.
|
||||
|
@ -678,7 +681,7 @@ void PlasmaStore::ReleaseObject(const ObjectID& object_id, const std::shared_ptr
|
|||
}
|
||||
|
||||
// Check if an object is present.
|
||||
ObjectStatus PlasmaStore::ContainsObject(const ObjectID& object_id) {
|
||||
ObjectStatus PlasmaStore::ContainsObject(const ObjectID &object_id) {
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
return entry && (entry->state == ObjectState::PLASMA_SEALED ||
|
||||
entry->state == ObjectState::PLASMA_EVICTED)
|
||||
|
@ -686,7 +689,7 @@ ObjectStatus PlasmaStore::ContainsObject(const ObjectID& object_id) {
|
|||
: ObjectStatus::OBJECT_NOT_FOUND;
|
||||
}
|
||||
|
||||
void PlasmaStore::SealObjects(const std::vector<ObjectID>& object_ids) {
|
||||
void PlasmaStore::SealObjects(const std::vector<ObjectID> &object_ids) {
|
||||
std::vector<ObjectInfoT> infos;
|
||||
|
||||
for (size_t i = 0; i < object_ids.size(); ++i) {
|
||||
|
@ -717,7 +720,8 @@ void PlasmaStore::SealObjects(const std::vector<ObjectID>& object_ids) {
|
|||
}
|
||||
}
|
||||
|
||||
int PlasmaStore::AbortObject(const ObjectID& object_id, const std::shared_ptr<Client> &client) {
|
||||
int PlasmaStore::AbortObject(const ObjectID &object_id,
|
||||
const std::shared_ptr<Client> &client) {
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
RAY_CHECK(entry != nullptr) << "To abort an object it must be in the object table.";
|
||||
RAY_CHECK(entry->state != ObjectState::PLASMA_SEALED)
|
||||
|
@ -735,7 +739,7 @@ int PlasmaStore::AbortObject(const ObjectID& object_id, const std::shared_ptr<Cl
|
|||
}
|
||||
}
|
||||
|
||||
PlasmaError PlasmaStore::DeleteObject(ObjectID& object_id) {
|
||||
PlasmaError PlasmaStore::DeleteObject(ObjectID &object_id) {
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
// TODO(rkn): This should probably not fail, but should instead throw an
|
||||
// error. Maybe we should also support deleting objects that have been
|
||||
|
@ -775,14 +779,14 @@ PlasmaError PlasmaStore::DeleteObject(ObjectID& object_id) {
|
|||
return PlasmaError::OK;
|
||||
}
|
||||
|
||||
void PlasmaStore::EvictObjects(const std::vector<ObjectID>& object_ids) {
|
||||
void PlasmaStore::EvictObjects(const std::vector<ObjectID> &object_ids) {
|
||||
if (object_ids.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<arrow::Buffer>> evicted_object_data;
|
||||
std::vector<ObjectTableEntry*> evicted_entries;
|
||||
for (const auto& object_id : object_ids) {
|
||||
std::vector<ObjectTableEntry *> evicted_entries;
|
||||
for (const auto &object_id : object_ids) {
|
||||
RAY_LOG(DEBUG) << "evicting object " << object_id.Hex();
|
||||
auto entry = GetObjectTableEntry(&store_info_, object_id);
|
||||
// TODO(rkn): This should probably not fail, but should instead throw an
|
||||
|
@ -831,9 +835,8 @@ void PlasmaStore::EvictObjects(const std::vector<ObjectID>& object_ids) {
|
|||
void PlasmaStore::ConnectClient(const boost::system::error_code &error) {
|
||||
if (!error) {
|
||||
// Accept a new local client and dispatch it to the node manager.
|
||||
auto new_connection = Client::Create(boost::bind(
|
||||
&PlasmaStore::ProcessMessage, this, _1, _2, _3
|
||||
), std::move(socket_));
|
||||
auto new_connection = Client::Create(
|
||||
boost::bind(&PlasmaStore::ProcessMessage, this, _1, _2, _3), std::move(socket_));
|
||||
}
|
||||
// We're ready to accept another client.
|
||||
DoAccept();
|
||||
|
@ -844,8 +847,8 @@ void PlasmaStore::DisconnectClient(const std::shared_ptr<Client> &client) {
|
|||
RAY_LOG(DEBUG) << "Disconnecting client on fd " << client;
|
||||
// Release all the objects that the client was using.
|
||||
eviction_policy_.ClientDisconnected(client.get());
|
||||
std::unordered_map<ObjectID, ObjectTableEntry*> sealed_objects;
|
||||
for (const auto& object_id : client->object_ids) {
|
||||
std::unordered_map<ObjectID, ObjectTableEntry *> sealed_objects;
|
||||
for (const auto &object_id : client->object_ids) {
|
||||
auto it = store_info_.objects.find(object_id);
|
||||
if (it == store_info_.objects.end()) {
|
||||
continue;
|
||||
|
@ -865,7 +868,7 @@ void PlasmaStore::DisconnectClient(const std::shared_ptr<Client> &client) {
|
|||
/// Remove all of the client's GetRequests.
|
||||
RemoveGetRequestsForClient(client);
|
||||
|
||||
for (const auto& entry : sealed_objects) {
|
||||
for (const auto &entry : sealed_objects) {
|
||||
RemoveFromClientObjectIds(entry.first, entry.second, client);
|
||||
}
|
||||
|
||||
|
@ -883,8 +886,8 @@ void PlasmaStore::DisconnectClient(const std::shared_ptr<Client> &client) {
|
|||
///
|
||||
/// \param client The client to push notifications to.
|
||||
/// \param object_info The notifications.
|
||||
void PlasmaStore::SendNotifications(
|
||||
const std::shared_ptr<Client> &client, const std::vector<ObjectInfoT> &object_info) {
|
||||
void PlasmaStore::SendNotifications(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectInfoT> &object_info) {
|
||||
namespace protocol = ray::object_manager::protocol;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
std::vector<flatbuffers::Offset<protocol::ObjectInfo>> info;
|
||||
|
@ -902,10 +905,10 @@ void PlasmaStore::SendNotifications(
|
|||
std::memcpy(data, fbb.GetBufferPointer(), fbb.GetSize());
|
||||
|
||||
std::vector<boost::asio::const_buffer> buffers{
|
||||
boost::asio::const_buffer(size, sizeof(*size)),
|
||||
boost::asio::const_buffer(data, fbb.GetSize()),
|
||||
boost::asio::const_buffer(size, sizeof(*size)),
|
||||
boost::asio::const_buffer(data, fbb.GetSize()),
|
||||
};
|
||||
client->WriteBufferAsync(buffers, [this, client, size, data](const Status& s) {
|
||||
client->WriteBufferAsync(buffers, [this, client, size, data](const Status &s) {
|
||||
if (!s.ok()) {
|
||||
RAY_LOG(WARNING) << "Failed to send notification to client on fd " << client;
|
||||
if (s.IsIOError()) {
|
||||
|
@ -918,13 +921,13 @@ void PlasmaStore::SendNotifications(
|
|||
});
|
||||
}
|
||||
|
||||
void PlasmaStore::PushNotification(ObjectInfoT* object_info) {
|
||||
void PlasmaStore::PushNotification(ObjectInfoT *object_info) {
|
||||
PushNotifications({*object_info});
|
||||
}
|
||||
|
||||
void PlasmaStore::PushNotifications(const std::vector<ObjectInfoT>& object_info) {
|
||||
void PlasmaStore::PushNotifications(const std::vector<ObjectInfoT> &object_info) {
|
||||
if (notification_listener_) {
|
||||
for (const auto& info : object_info) {
|
||||
for (const auto &info : object_info) {
|
||||
if (!info.is_deletion) {
|
||||
notification_listener_->ProcessStoreAdd(info);
|
||||
} else {
|
||||
|
@ -933,7 +936,7 @@ void PlasmaStore::PushNotifications(const std::vector<ObjectInfoT>& object_info)
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto& client : notification_clients_) {
|
||||
for (const auto &client : notification_clients_) {
|
||||
SendNotifications(client, object_info);
|
||||
}
|
||||
}
|
||||
|
@ -945,7 +948,7 @@ void PlasmaStore::SubscribeToUpdates(const std::shared_ptr<Client> &client) {
|
|||
|
||||
std::vector<ObjectInfoT> infos;
|
||||
// Push notifications to the new subscriber about existing sealed objects.
|
||||
for (const auto& entry : store_info_.objects) {
|
||||
for (const auto &entry : store_info_.objects) {
|
||||
if (entry.second->state == ObjectState::PLASMA_SEALED) {
|
||||
ObjectInfoT info;
|
||||
info.object_id = entry.first.Binary();
|
||||
|
@ -965,102 +968,103 @@ Status PlasmaStore::ProcessMessage(const std::shared_ptr<Client> &client,
|
|||
fb::MessageType type,
|
||||
const std::vector<uint8_t> &message) {
|
||||
// TODO(suquark): We should convert these interfaces to const later.
|
||||
uint8_t* input = (uint8_t*)message.data();
|
||||
uint8_t *input = (uint8_t *)message.data();
|
||||
size_t input_size = message.size();
|
||||
ObjectID object_id;
|
||||
|
||||
// Process the different types of requests.
|
||||
switch (type) {
|
||||
case fb::MessageType::PlasmaCreateRequest: {
|
||||
RAY_LOG(DEBUG) << "Received create request for object " << GetCreateRequestObjectId(message);
|
||||
create_request_queue_.AddRequest(client, [this, client, message]() {
|
||||
return HandleCreateObjectRequest(client, message);
|
||||
});
|
||||
ProcessCreateRequests();
|
||||
} break;
|
||||
case fb::MessageType::PlasmaAbortRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadAbortRequest(input, input_size, &object_id));
|
||||
RAY_CHECK(AbortObject(object_id, client) == 1) << "To abort an object, the only "
|
||||
"client currently using it "
|
||||
"must be the creator.";
|
||||
RAY_RETURN_NOT_OK(SendAbortReply(client, object_id));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaGetRequest: {
|
||||
std::vector<ObjectID> object_ids_to_get;
|
||||
int64_t timeout_ms;
|
||||
RAY_RETURN_NOT_OK(ReadGetRequest(input, input_size, object_ids_to_get, &timeout_ms));
|
||||
ProcessGetRequest(client, object_ids_to_get, timeout_ms);
|
||||
} break;
|
||||
case fb::MessageType::PlasmaReleaseRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadReleaseRequest(input, input_size, &object_id));
|
||||
ReleaseObject(object_id, client);
|
||||
} break;
|
||||
case fb::MessageType::PlasmaDeleteRequest: {
|
||||
std::vector<ObjectID> object_ids;
|
||||
std::vector<PlasmaError> error_codes;
|
||||
RAY_RETURN_NOT_OK(ReadDeleteRequest(input, input_size, &object_ids));
|
||||
error_codes.reserve(object_ids.size());
|
||||
for (auto& object_id : object_ids) {
|
||||
error_codes.push_back(DeleteObject(object_id));
|
||||
}
|
||||
RAY_RETURN_NOT_OK(SendDeleteReply(client, object_ids, error_codes));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaContainsRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadContainsRequest(input, input_size, &object_id));
|
||||
if (ContainsObject(object_id) == ObjectStatus::OBJECT_FOUND) {
|
||||
RAY_RETURN_NOT_OK(SendContainsReply(client, object_id, 1));
|
||||
} else {
|
||||
RAY_RETURN_NOT_OK(SendContainsReply(client, object_id, 0));
|
||||
}
|
||||
} break;
|
||||
case fb::MessageType::PlasmaSealRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadSealRequest(input, input_size, &object_id));
|
||||
SealObjects({object_id});
|
||||
RAY_RETURN_NOT_OK(SendSealReply(client, object_id, PlasmaError::OK));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaEvictRequest: {
|
||||
// This code path should only be used for testing.
|
||||
int64_t num_bytes;
|
||||
RAY_RETURN_NOT_OK(ReadEvictRequest(input, input_size, &num_bytes));
|
||||
std::vector<ObjectID> objects_to_evict;
|
||||
int64_t num_bytes_evicted =
|
||||
eviction_policy_.ChooseObjectsToEvict(num_bytes, &objects_to_evict);
|
||||
EvictObjects(objects_to_evict);
|
||||
RAY_RETURN_NOT_OK(SendEvictReply(client, num_bytes_evicted));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaRefreshLRURequest: {
|
||||
std::vector<ObjectID> object_ids;
|
||||
RAY_RETURN_NOT_OK(ReadRefreshLRURequest(input, input_size, &object_ids));
|
||||
eviction_policy_.RefreshObjects(object_ids);
|
||||
RAY_RETURN_NOT_OK(SendRefreshLRUReply(client));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaSubscribeRequest:
|
||||
SubscribeToUpdates(client);
|
||||
break;
|
||||
case fb::MessageType::PlasmaConnectRequest: {
|
||||
RAY_RETURN_NOT_OK(SendConnectReply(client, PlasmaAllocator::GetFootprintLimit()));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaDisconnectClient:
|
||||
RAY_LOG(DEBUG) << "Disconnecting client on fd " << client;
|
||||
DisconnectClient(client);
|
||||
return Status::Disconnected("The Plasma Store client is disconnected.");
|
||||
break;
|
||||
case fb::MessageType::PlasmaSetOptionsRequest: {
|
||||
std::string client_name;
|
||||
int64_t output_memory_quota;
|
||||
RAY_RETURN_NOT_OK(
|
||||
ReadSetOptionsRequest(input, input_size, &client_name, &output_memory_quota));
|
||||
client->name = client_name;
|
||||
bool success = eviction_policy_.SetClientQuota(client.get(), output_memory_quota);
|
||||
RAY_RETURN_NOT_OK(SendSetOptionsReply(client, success ? PlasmaError::OK
|
||||
: PlasmaError::OutOfMemory));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaGetDebugStringRequest: {
|
||||
RAY_RETURN_NOT_OK(SendGetDebugStringReply(client, eviction_policy_.DebugString()));
|
||||
} break;
|
||||
default:
|
||||
// This code should be unreachable.
|
||||
RAY_CHECK(0);
|
||||
case fb::MessageType::PlasmaCreateRequest: {
|
||||
RAY_LOG(DEBUG) << "Received create request for object "
|
||||
<< GetCreateRequestObjectId(message);
|
||||
create_request_queue_.AddRequest(client, [this, client, message]() {
|
||||
return HandleCreateObjectRequest(client, message);
|
||||
});
|
||||
ProcessCreateRequests();
|
||||
} break;
|
||||
case fb::MessageType::PlasmaAbortRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadAbortRequest(input, input_size, &object_id));
|
||||
RAY_CHECK(AbortObject(object_id, client) == 1) << "To abort an object, the only "
|
||||
"client currently using it "
|
||||
"must be the creator.";
|
||||
RAY_RETURN_NOT_OK(SendAbortReply(client, object_id));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaGetRequest: {
|
||||
std::vector<ObjectID> object_ids_to_get;
|
||||
int64_t timeout_ms;
|
||||
RAY_RETURN_NOT_OK(ReadGetRequest(input, input_size, object_ids_to_get, &timeout_ms));
|
||||
ProcessGetRequest(client, object_ids_to_get, timeout_ms);
|
||||
} break;
|
||||
case fb::MessageType::PlasmaReleaseRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadReleaseRequest(input, input_size, &object_id));
|
||||
ReleaseObject(object_id, client);
|
||||
} break;
|
||||
case fb::MessageType::PlasmaDeleteRequest: {
|
||||
std::vector<ObjectID> object_ids;
|
||||
std::vector<PlasmaError> error_codes;
|
||||
RAY_RETURN_NOT_OK(ReadDeleteRequest(input, input_size, &object_ids));
|
||||
error_codes.reserve(object_ids.size());
|
||||
for (auto &object_id : object_ids) {
|
||||
error_codes.push_back(DeleteObject(object_id));
|
||||
}
|
||||
RAY_RETURN_NOT_OK(SendDeleteReply(client, object_ids, error_codes));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaContainsRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadContainsRequest(input, input_size, &object_id));
|
||||
if (ContainsObject(object_id) == ObjectStatus::OBJECT_FOUND) {
|
||||
RAY_RETURN_NOT_OK(SendContainsReply(client, object_id, 1));
|
||||
} else {
|
||||
RAY_RETURN_NOT_OK(SendContainsReply(client, object_id, 0));
|
||||
}
|
||||
} break;
|
||||
case fb::MessageType::PlasmaSealRequest: {
|
||||
RAY_RETURN_NOT_OK(ReadSealRequest(input, input_size, &object_id));
|
||||
SealObjects({object_id});
|
||||
RAY_RETURN_NOT_OK(SendSealReply(client, object_id, PlasmaError::OK));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaEvictRequest: {
|
||||
// This code path should only be used for testing.
|
||||
int64_t num_bytes;
|
||||
RAY_RETURN_NOT_OK(ReadEvictRequest(input, input_size, &num_bytes));
|
||||
std::vector<ObjectID> objects_to_evict;
|
||||
int64_t num_bytes_evicted =
|
||||
eviction_policy_.ChooseObjectsToEvict(num_bytes, &objects_to_evict);
|
||||
EvictObjects(objects_to_evict);
|
||||
RAY_RETURN_NOT_OK(SendEvictReply(client, num_bytes_evicted));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaRefreshLRURequest: {
|
||||
std::vector<ObjectID> object_ids;
|
||||
RAY_RETURN_NOT_OK(ReadRefreshLRURequest(input, input_size, &object_ids));
|
||||
eviction_policy_.RefreshObjects(object_ids);
|
||||
RAY_RETURN_NOT_OK(SendRefreshLRUReply(client));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaSubscribeRequest:
|
||||
SubscribeToUpdates(client);
|
||||
break;
|
||||
case fb::MessageType::PlasmaConnectRequest: {
|
||||
RAY_RETURN_NOT_OK(SendConnectReply(client, PlasmaAllocator::GetFootprintLimit()));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaDisconnectClient:
|
||||
RAY_LOG(DEBUG) << "Disconnecting client on fd " << client;
|
||||
DisconnectClient(client);
|
||||
return Status::Disconnected("The Plasma Store client is disconnected.");
|
||||
break;
|
||||
case fb::MessageType::PlasmaSetOptionsRequest: {
|
||||
std::string client_name;
|
||||
int64_t output_memory_quota;
|
||||
RAY_RETURN_NOT_OK(
|
||||
ReadSetOptionsRequest(input, input_size, &client_name, &output_memory_quota));
|
||||
client->name = client_name;
|
||||
bool success = eviction_policy_.SetClientQuota(client.get(), output_memory_quota);
|
||||
RAY_RETURN_NOT_OK(SendSetOptionsReply(
|
||||
client, success ? PlasmaError::OK : PlasmaError::OutOfMemory));
|
||||
} break;
|
||||
case fb::MessageType::PlasmaGetDebugStringRequest: {
|
||||
RAY_RETURN_NOT_OK(SendGetDebugStringReply(client, eviction_policy_.DebugString()));
|
||||
} break;
|
||||
default:
|
||||
// This code should be unreachable.
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
@ -1082,11 +1086,14 @@ void PlasmaStore::ProcessCreateRequests() {
|
|||
auto status = create_request_queue_.ProcessRequests();
|
||||
if (status.IsTransientObjectStoreFull()) {
|
||||
// Try to process requests later, after space has been made.
|
||||
create_timer_ = execute_after(io_context_, [this]() {
|
||||
RAY_LOG(DEBUG) << "OOM timer finished, retrying create requests";
|
||||
create_timer_ = nullptr;
|
||||
ProcessCreateRequests();
|
||||
}, delay_on_transient_oom_ms_);
|
||||
create_timer_ = execute_after(io_context_,
|
||||
[this]() {
|
||||
RAY_LOG(DEBUG)
|
||||
<< "OOM timer finished, retrying create requests";
|
||||
create_timer_ = nullptr;
|
||||
ProcessCreateRequests();
|
||||
},
|
||||
delay_on_transient_oom_ms_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,16 +45,16 @@ namespace flatbuf {
|
|||
enum class PlasmaError;
|
||||
} // namespace flatbuf
|
||||
|
||||
using ray::object_manager::protocol::ObjectInfoT;
|
||||
using flatbuf::PlasmaError;
|
||||
using ray::object_manager::protocol::ObjectInfoT;
|
||||
|
||||
struct GetRequest;
|
||||
|
||||
class PlasmaStore {
|
||||
public:
|
||||
// TODO: PascalCase PlasmaStore methods.
|
||||
PlasmaStore(boost::asio::io_service &main_service, std::string directory, bool hugepages_enabled,
|
||||
const std::string& socket_name,
|
||||
PlasmaStore(boost::asio::io_service &main_service, std::string directory,
|
||||
bool hugepages_enabled, const std::string &socket_name,
|
||||
std::shared_ptr<ExternalStore> external_store,
|
||||
ray::SpillObjectsCallback spill_objects_callback);
|
||||
|
||||
|
@ -67,7 +67,7 @@ class PlasmaStore {
|
|||
void Stop();
|
||||
|
||||
/// Get a const pointer to the internal PlasmaStoreInfo object.
|
||||
const PlasmaStoreInfo* GetPlasmaStoreInfo();
|
||||
const PlasmaStoreInfo *GetPlasmaStoreInfo();
|
||||
|
||||
/// Create a new object. The client must do a call to release_object to tell
|
||||
/// the store when it is done with the object.
|
||||
|
@ -101,14 +101,11 @@ class PlasmaStore {
|
|||
/// - PlasmaError::TransientOutOfMemory, if the store is temporarily out of
|
||||
/// memory but there may be space soon to create the object. In this
|
||||
/// case, the client should not call plasma_release.
|
||||
PlasmaError CreateObject(const ObjectID& object_id,
|
||||
const NodeID& owner_raylet_id,
|
||||
const std::string& owner_ip_address,
|
||||
int owner_port, const WorkerID& owner_worker_id,
|
||||
bool evict_if_full, int64_t data_size,
|
||||
int64_t metadata_size, int device_num,
|
||||
const std::shared_ptr<Client> &client,
|
||||
PlasmaObject* result);
|
||||
PlasmaError CreateObject(const ObjectID &object_id, const NodeID &owner_raylet_id,
|
||||
const std::string &owner_ip_address, int owner_port,
|
||||
const WorkerID &owner_worker_id, bool evict_if_full,
|
||||
int64_t data_size, int64_t metadata_size, int device_num,
|
||||
const std::shared_ptr<Client> &client, PlasmaObject *result);
|
||||
|
||||
/// Abort a created but unsealed object. If the client is not the
|
||||
/// creator, then the abort will fail.
|
||||
|
@ -117,7 +114,7 @@ class PlasmaStore {
|
|||
/// \param client The client who created the object. If this does not
|
||||
/// match the creator of the object, then the abort will fail.
|
||||
/// \return 1 if the abort succeeds, else 0.
|
||||
int AbortObject(const ObjectID& object_id, const std::shared_ptr<Client> &client);
|
||||
int AbortObject(const ObjectID &object_id, const std::shared_ptr<Client> &client);
|
||||
|
||||
/// Delete a specific object by object_id that have been created in the hash table.
|
||||
///
|
||||
|
@ -126,12 +123,12 @@ class PlasmaStore {
|
|||
/// - PlasmaError::OK, if the object was delete successfully.
|
||||
/// - PlasmaError::ObjectNonexistent, if ths object isn't existed.
|
||||
/// - PlasmaError::ObjectInUse, if the object is in use.
|
||||
PlasmaError DeleteObject(ObjectID& object_id);
|
||||
PlasmaError DeleteObject(ObjectID &object_id);
|
||||
|
||||
/// Evict objects returned by the eviction policy.
|
||||
///
|
||||
/// \param object_ids Object IDs of the objects to be evicted.
|
||||
void EvictObjects(const std::vector<ObjectID>& object_ids);
|
||||
void EvictObjects(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
/// Process a get request from a client. This method assumes that we will
|
||||
/// eventually have these objects sealed. If one of the objects has not yet
|
||||
|
@ -144,27 +141,27 @@ class PlasmaStore {
|
|||
/// \param client The client making this request.
|
||||
/// \param object_ids Object IDs of the objects to be gotten.
|
||||
/// \param timeout_ms The timeout for the get request in milliseconds.
|
||||
void ProcessGetRequest(const std::shared_ptr<Client> &client, const std::vector<ObjectID>& object_ids,
|
||||
int64_t timeout_ms);
|
||||
void ProcessGetRequest(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectID> &object_ids, int64_t timeout_ms);
|
||||
|
||||
/// Seal a vector of objects. The objects are now immutable and can be accessed with
|
||||
/// get.
|
||||
///
|
||||
/// \param object_ids The vector of Object IDs of the objects to be sealed.
|
||||
void SealObjects(const std::vector<ObjectID>& object_ids);
|
||||
void SealObjects(const std::vector<ObjectID> &object_ids);
|
||||
|
||||
/// Check if the plasma store contains an object:
|
||||
///
|
||||
/// \param object_id Object ID that will be checked.
|
||||
/// \return OBJECT_FOUND if the object is in the store, OBJECT_NOT_FOUND if
|
||||
/// not
|
||||
ObjectStatus ContainsObject(const ObjectID& object_id);
|
||||
ObjectStatus ContainsObject(const ObjectID &object_id);
|
||||
|
||||
/// Record the fact that a particular client is no longer using an object.
|
||||
///
|
||||
/// \param object_id The object ID of the object that is being released.
|
||||
/// \param client The client making this request.
|
||||
void ReleaseObject(const ObjectID& object_id, const std::shared_ptr<Client> &client);
|
||||
void ReleaseObject(const ObjectID &object_id, const std::shared_ptr<Client> &client);
|
||||
|
||||
/// Subscribe a file descriptor to updates about new sealed objects.
|
||||
///
|
||||
|
@ -181,10 +178,11 @@ class PlasmaStore {
|
|||
/// \param client The client that is disconnected.
|
||||
void DisconnectClient(const std::shared_ptr<Client> &client);
|
||||
|
||||
void SendNotifications(
|
||||
const std::shared_ptr<Client> &client, const std::vector<ObjectInfoT> &object_info);
|
||||
void SendNotifications(const std::shared_ptr<Client> &client,
|
||||
const std::vector<ObjectInfoT> &object_info);
|
||||
|
||||
Status ProcessMessage(const std::shared_ptr<Client> &client, plasma::flatbuf::MessageType type,
|
||||
Status ProcessMessage(const std::shared_ptr<Client> &client,
|
||||
plasma::flatbuf::MessageType type,
|
||||
const std::vector<uint8_t> &message);
|
||||
|
||||
void SetNotificationListener(
|
||||
|
@ -192,7 +190,7 @@ class PlasmaStore {
|
|||
notification_listener_ = notification_listener;
|
||||
if (notification_listener_) {
|
||||
// Push notifications to the new subscriber about existing sealed objects.
|
||||
for (const auto& entry : store_info_.objects) {
|
||||
for (const auto &entry : store_info_.objects) {
|
||||
if (entry.second->state == ObjectState::PLASMA_SEALED) {
|
||||
ObjectInfoT info;
|
||||
info.object_id = entry.first.Binary();
|
||||
|
@ -208,49 +206,51 @@ class PlasmaStore {
|
|||
void ProcessCreateRequests();
|
||||
|
||||
private:
|
||||
Status HandleCreateObjectRequest(const std::shared_ptr<Client> &client, const std::vector<uint8_t> &message);
|
||||
Status HandleCreateObjectRequest(const std::shared_ptr<Client> &client,
|
||||
const std::vector<uint8_t> &message);
|
||||
|
||||
void PushNotification(ObjectInfoT* object_notification);
|
||||
void PushNotification(ObjectInfoT *object_notification);
|
||||
|
||||
void PushNotifications(const std::vector<ObjectInfoT>& object_notifications);
|
||||
void PushNotifications(const std::vector<ObjectInfoT> &object_notifications);
|
||||
|
||||
void AddToClientObjectIds(const ObjectID& object_id, ObjectTableEntry* entry,
|
||||
void AddToClientObjectIds(const ObjectID &object_id, ObjectTableEntry *entry,
|
||||
const std::shared_ptr<Client> &client);
|
||||
|
||||
/// Remove a GetRequest and clean up the relevant data structures.
|
||||
///
|
||||
/// \param get_request The GetRequest to remove.
|
||||
void RemoveGetRequest(GetRequest* get_request);
|
||||
void RemoveGetRequest(GetRequest *get_request);
|
||||
|
||||
/// Remove all of the GetRequests for a given client.
|
||||
///
|
||||
/// \param client The client whose GetRequests should be removed.
|
||||
void RemoveGetRequestsForClient(const std::shared_ptr<Client> &client);
|
||||
|
||||
void ReturnFromGet(GetRequest* get_req);
|
||||
void ReturnFromGet(GetRequest *get_req);
|
||||
|
||||
void UpdateObjectGetRequests(const ObjectID& object_id);
|
||||
void UpdateObjectGetRequests(const ObjectID &object_id);
|
||||
|
||||
int RemoveFromClientObjectIds(const ObjectID& object_id, ObjectTableEntry* entry,
|
||||
int RemoveFromClientObjectIds(const ObjectID &object_id, ObjectTableEntry *entry,
|
||||
const std::shared_ptr<Client> &client);
|
||||
|
||||
void EraseFromObjectTable(const ObjectID& object_id);
|
||||
void EraseFromObjectTable(const ObjectID &object_id);
|
||||
|
||||
uint8_t* AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE* fd, int64_t* map_size,
|
||||
ptrdiff_t* offset, const std::shared_ptr<Client> &client, bool is_create,
|
||||
uint8_t *AllocateMemory(size_t size, bool evict_if_full, MEMFD_TYPE *fd,
|
||||
int64_t *map_size, ptrdiff_t *offset,
|
||||
const std::shared_ptr<Client> &client, bool is_create,
|
||||
PlasmaError *error);
|
||||
#ifdef PLASMA_CUDA
|
||||
Status AllocateCudaMemory(int device_num, int64_t size, uint8_t** out_pointer,
|
||||
std::shared_ptr<CudaIpcMemHandle>* out_ipc_handle);
|
||||
Status AllocateCudaMemory(int device_num, int64_t size, uint8_t **out_pointer,
|
||||
std::shared_ptr<CudaIpcMemHandle> *out_ipc_handle);
|
||||
|
||||
Status FreeCudaMemory(int device_num, int64_t size, uint8_t* out_pointer);
|
||||
Status FreeCudaMemory(int device_num, int64_t size, uint8_t *out_pointer);
|
||||
#endif
|
||||
|
||||
// Start listening for clients.
|
||||
void DoAccept();
|
||||
|
||||
// A reference to the asio io context.
|
||||
boost::asio::io_service& io_context_;
|
||||
boost::asio::io_service &io_context_;
|
||||
/// The name of the socket this object store listens on.
|
||||
std::string socket_name_;
|
||||
/// An acceptor for new clients.
|
||||
|
@ -265,7 +265,7 @@ class PlasmaStore {
|
|||
QuotaAwarePolicy eviction_policy_;
|
||||
/// A hash table mapping object IDs to a vector of the get requests that are
|
||||
/// waiting for the object to arrive.
|
||||
std::unordered_map<ObjectID, std::vector<GetRequest*>> object_get_requests_;
|
||||
std::unordered_map<ObjectID, std::vector<GetRequest *>> object_get_requests_;
|
||||
/// The registered client for receiving notifications.
|
||||
std::unordered_set<std::shared_ptr<Client>> notification_clients_;
|
||||
|
||||
|
@ -275,7 +275,7 @@ class PlasmaStore {
|
|||
/// for reading/writing data to/from external store.
|
||||
std::shared_ptr<ExternalStore> external_store_;
|
||||
#ifdef PLASMA_CUDA
|
||||
arrow::cuda::CudaDeviceManager* manager_;
|
||||
arrow::cuda::CudaDeviceManager *manager_;
|
||||
#endif
|
||||
std::shared_ptr<ray::ObjectStoreNotificationManager> notification_listener_;
|
||||
/// A callback to asynchronously spill objects when space is needed. The
|
||||
|
|
|
@ -14,9 +14,10 @@ namespace plasma {
|
|||
void SetMallocGranularity(int value);
|
||||
|
||||
PlasmaStoreRunner::PlasmaStoreRunner(std::string socket_name, int64_t system_memory,
|
||||
bool hugepages_enabled, std::string plasma_directory,
|
||||
const std::string external_store_endpoint):
|
||||
hugepages_enabled_(hugepages_enabled), external_store_endpoint_(external_store_endpoint) {
|
||||
bool hugepages_enabled, std::string plasma_directory,
|
||||
const std::string external_store_endpoint)
|
||||
: hugepages_enabled_(hugepages_enabled),
|
||||
external_store_endpoint_(external_store_endpoint) {
|
||||
// Sanity check.
|
||||
if (socket_name.empty()) {
|
||||
RAY_LOG(FATAL) << "please specify socket for incoming connections with -s switch";
|
||||
|
@ -28,11 +29,10 @@ PlasmaStoreRunner::PlasmaStoreRunner(std::string socket_name, int64_t system_mem
|
|||
// Set system memory capacity
|
||||
PlasmaAllocator::SetFootprintLimit(static_cast<size_t>(system_memory));
|
||||
RAY_LOG(INFO) << "Allowing the Plasma store to use up to "
|
||||
<< static_cast<double>(system_memory) / 1000000000
|
||||
<< "GB of memory.";
|
||||
<< static_cast<double>(system_memory) / 1000000000 << "GB of memory.";
|
||||
if (hugepages_enabled && plasma_directory.empty()) {
|
||||
RAY_LOG(FATAL) << "if you want to use hugepages, please specify path to huge pages "
|
||||
"filesystem with -d";
|
||||
"filesystem with -d";
|
||||
}
|
||||
if (plasma_directory.empty()) {
|
||||
#ifdef __linux__
|
||||
|
@ -42,8 +42,8 @@ PlasmaStoreRunner::PlasmaStoreRunner(std::string socket_name, int64_t system_mem
|
|||
#endif
|
||||
}
|
||||
RAY_LOG(INFO) << "Starting object store with directory " << plasma_directory
|
||||
<< " and huge page support "
|
||||
<< (hugepages_enabled ? "enabled" : "disabled");
|
||||
<< " and huge page support "
|
||||
<< (hugepages_enabled ? "enabled" : "disabled");
|
||||
#ifdef __linux__
|
||||
if (!hugepages_enabled) {
|
||||
// On Linux, check that the amount of memory available in /dev/shm is large
|
||||
|
@ -76,7 +76,7 @@ PlasmaStoreRunner::PlasmaStoreRunner(std::string socket_name, int64_t system_mem
|
|||
}
|
||||
|
||||
void PlasmaStoreRunner::Start(ray::SpillObjectsCallback spill_objects_callback) {
|
||||
// Get external store
|
||||
// Get external store
|
||||
std::shared_ptr<plasma::ExternalStore> external_store{nullptr};
|
||||
if (!external_store_endpoint_.empty()) {
|
||||
std::string name;
|
||||
|
@ -94,21 +94,20 @@ void PlasmaStoreRunner::Start(ray::SpillObjectsCallback spill_objects_callback)
|
|||
{
|
||||
absl::MutexLock lock(&store_runner_mutex_);
|
||||
store_.reset(new PlasmaStore(main_service_, plasma_directory_, hugepages_enabled_,
|
||||
socket_name_, external_store,
|
||||
spill_objects_callback));
|
||||
socket_name_, external_store, spill_objects_callback));
|
||||
plasma_config = store_->GetPlasmaStoreInfo();
|
||||
|
||||
// We are using a single memory-mapped file by mallocing and freeing a single
|
||||
// large amount of space up front. According to the documentation,
|
||||
// dlmalloc might need up to 128*sizeof(size_t) bytes for internal
|
||||
// bookkeeping.
|
||||
void* pointer = PlasmaAllocator::Memalign(
|
||||
void *pointer = PlasmaAllocator::Memalign(
|
||||
kBlockSize, PlasmaAllocator::GetFootprintLimit() - 256 * sizeof(size_t));
|
||||
RAY_CHECK(pointer != nullptr);
|
||||
// This will unmap the file, but the next one created will be as large
|
||||
// as this one (this is an implementation detail of dlmalloc).
|
||||
PlasmaAllocator::Free(
|
||||
pointer, PlasmaAllocator::GetFootprintLimit() - 256 * sizeof(size_t));
|
||||
PlasmaAllocator::Free(pointer,
|
||||
PlasmaAllocator::GetFootprintLimit() - 256 * sizeof(size_t));
|
||||
|
||||
store_->Start();
|
||||
}
|
||||
|
|
|
@ -23,11 +23,8 @@ class PlasmaStoreRunner {
|
|||
}
|
||||
|
||||
ray::SpaceReleasedCallback OnSpaceReleased() {
|
||||
return [this]() {
|
||||
main_service_.post([this]() {
|
||||
store_->ProcessCreateRequests();
|
||||
});
|
||||
};
|
||||
return
|
||||
[this]() { main_service_.post([this]() { store_->ProcessCreateRequests(); }); };
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue