Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[core] Small optimizations from accelerated DAG experiment #41418

Merged
merged 12 commits into from
Nov 30, 2023
Prev Previous commit
Next Next commit
switch to static const
Signed-off-by: Eric Liang <ekhliang@gmail.com>
  • Loading branch information
ericl committed Nov 29, 2023
commit a019d22af09e0425adf2491dcdfc001b49b9b3b7
12 changes: 6 additions & 6 deletions src/ray/common/ray_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "msgpack.hpp"

namespace {

static const std::string kObjectInPlasmaStr =
std::to_string(ray::rpc::ErrorType::OBJECT_IN_PLASMA);

std::shared_ptr<ray::LocalMemoryBuffer> MakeBufferFromString(const uint8_t *data,
size_t data_size) {
auto metadata = const_cast<uint8_t *>(data);
Expand Down Expand Up @@ -110,9 +114,7 @@ bool RayObject::IsException(rpc::ErrorType *error_type) const {
// TODO (kfstorm): metadata should be structured.
const std::string_view metadata(reinterpret_cast<const char *>(metadata_->Data()),
metadata_->Size());
// Keep in sync with common.proto.
static_assert(ray::rpc::ErrorType::OBJECT_IN_PLASMA == 4);
if (metadata == "4") {
if (metadata == kObjectInPlasmaStr) {
if (error_type) {
*error_type = rpc::ErrorType::OBJECT_IN_PLASMA;
}
Expand All @@ -137,9 +139,7 @@ bool RayObject::IsInPlasmaError() const {
}
const std::string_view metadata(reinterpret_cast<const char *>(metadata_->Data()),
metadata_->Size());
// Keep in sync with common.proto.
static_assert(ray::rpc::ErrorType::OBJECT_IN_PLASMA == 4);
return metadata == "4";
return metadata == kObjectInPlasmaStr;
}

} // namespace ray