Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/ray/raylet/runtime_env_agent_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Session : public std::enable_shared_from_this<Session> {
//
// This method should only be called once.
void run(FinishedCallback finished_callback) {
finished_callback_ = finished_callback;
finished_callback_ = std::move(finished_callback);
// Starts the state machine by looking up the domain name.
resolver_.async_resolve(
host_,
Expand Down Expand Up @@ -151,7 +151,7 @@ class Session : public std::enable_shared_from_this<Session> {

void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type) {
if (ec) {
Failed(ray::Status::NotFound("on_connect " + ec.message()));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation creates multiple temporary strings, absl::StrCat only creates one.

Failed(ray::Status::NotFound(absl::StrCat("on_connect ", ec.message())));
return;
}

Expand All @@ -163,9 +163,8 @@ class Session : public std::enable_shared_from_this<Session> {

void on_write(beast::error_code ec, std::size_t bytes_transferred) {
if (ec) {
Failed(ray::Status::Disconnected("on_write " + ec.message() +
", bytes_transferred " +
std::to_string(bytes_transferred)));
Failed(ray::Status::Disconnected(absl::StrCat(
"on_write ", ec.message(), ", bytes_transferred ", bytes_transferred)));
return;
}
stream_.expires_never();
Expand All @@ -178,9 +177,8 @@ class Session : public std::enable_shared_from_this<Session> {

void on_read(beast::error_code ec, std::size_t bytes_transferred) {
if (ec) {
Failed(ray::Status::Disconnected("on_read " + ec.message() +
", bytes_transferred " +
std::to_string(bytes_transferred)));
Failed(ray::Status::Disconnected(absl::StrCat(
"on_read ", ec.message(), ", bytes_transferred ", bytes_transferred)));
return;
}

Expand Down Expand Up @@ -276,7 +274,7 @@ class HttpRuntimeEnvAgentClient : public RuntimeEnvAgentClient {
: io_context_(io_context),
session_pool_(session_pool_size),
address_(address),
port_str_(std::to_string(port)),
Copy link
Contributor Author

@dentiny dentiny Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::to_string is known to suffer hidden performance issue, with a global lock for timezone.

Copy from doc:

std::to_string relies on the current C locale for formatting purposes, and therefore 
concurrent calls to std::to_string from multiple threads may result in partial 
serialization of calls.

port_str_(absl::StrFormat("%d", port)),
delay_executor_(delay_executor),
shutdown_raylet_gracefully_(shutdown_raylet_gracefully),
agent_register_timeout_ms_(agent_register_timeout_ms),
Expand Down