-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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] Fix gcs logging #48952
base: master
Are you sure you want to change the base?
[core] Fix gcs logging #48952
Conversation
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
79144b4
to
7c1c266
Compare
@@ -38,17 +41,40 @@ DEFINE_string(session_name, | |||
"session_name: The session name (ClusterID) of the cluster."); | |||
DEFINE_string(ray_commit, "", "The commit hash of Ray."); | |||
|
|||
namespace { | |||
// GCS server output filename. | |||
constexpr std::string_view kGcsServerLog = "gcs_server.out"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_log_file_handles can create names like gcs_server.2.out
if gcs_server.out
and gcs_server.1.out
both exists. Do we have such thing in spdlog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All rotated logs are suffixed with id, similar to what you're described.
? std::numeric_limits<int64_t>::max() | ||
: FLAGS_log_rotation_size; | ||
RAY_CHECK_EQ(setenv( | ||
"RAY_ROTATION_MAX_BYTES", std::to_string(log_rotation_max_size), /*overwrite=*/1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain diff of RAY_ROTATION_MAX_BYTES vs FLAGS_log_rotation_size ? If we already have the former, then we only need to fix existing behavior? I see gcs_server_main.cc already call ray::RayLog::StartRayLog and why does the log rotations in it do not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't do anything in this PR, instead only do 2 things:
- remove python stdout/stderr redirection
- change ray_log_shutdown_raii from
/*log_dir=*/""
to/*log_dir=*/FLAGS_log_dir
will the rotations automatically work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but the file name will be changed. We want to keep the existing gcs_server.out filename for backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will the rotations automatically work?
To answer your question, passing the log directory works for log rotation.
But one motivation would be backward compatibility, namely keep the gcs_server.out
filename.
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Now we have 2 ways to specify a RayLog storage:
and log_file has higher priority than log_dir. This setup is a bit nuanced and instead can we do something simpler like this:
so that:
|
Signed-off-by: hjiang <[email protected]>
Updated, let me know if I understand correctly. |
@@ -312,14 +311,45 @@ void RayLog::InitLogFormat() { | |||
} | |||
} | |||
|
|||
/*static*/ std::string RayLog::GetLogOutputFilename(const std::string &log_dir, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have a commented out static
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's a static
function.
/*static*/ std::string RayLog::GetLogOutputFilename(const std::string &log_dir, | ||
const std::string &log_file, | ||
const std::string &app_name) { | ||
// Case-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these Case-n are not informative. We can write a prologue like:
We combine log_dir and (log_file or app_name) into a final output file name. Rules:
1. both log_dir and log_file are empty: return "" meaning no log outputs.
1. both log_dir and log_file are NON empty: return f"{log_dir}/{log_name}".
2. log_dir is NON empty, log_file is empty: return f"{log_dir}/{app_name}_{pid}.log".
3. log_dir is empty, log_file is NON empty: check failure.
Then the "Case-n" comments would become meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case-n corresponds to header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code reference here:
Lines 268 to 273 in c49bae6
/// A few cases: | |
/// 1. If both folder and filename are empty, logging will be displayed to stdout. | |
/// 2. If both folder and filename specified, `folder/filename` will be used as output | |
/// file. | |
/// 3. If only folder filled, default filename by folder is used. | |
/// 4. It's illegal to only provide filename. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/ray/util/logging.h
Outdated
/// \param log_dir Logging output directory name. | ||
/// \param log_file Logging output file name. | ||
/// | ||
/// Both [log_dir] and [log_file] are used to determine the output logging file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use backticks, not brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering do we have any code style recommendation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or it's the grammar for documentation generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment, but still want to know about the coding standing / documentation style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no specific style rules, but I often use backticks and never saw brackets in Ray.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's coding consistency I'm fine with it, but backtick is usually used in bash script for execution (i.e. make -jnproc
). To reduce mixed usage, I usually use []
for function arguments and referenced function names.
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Signed-off-by: hjiang <[email protected]>
Same motivation as #48931, but different implementation.
TLDR for the problem: