-
Notifications
You must be signed in to change notification settings - Fork 6k
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] [no-op] Cleanup utils folder bazel dependency #49938
Changes from all commits
439d307
e794acd
8ba3ffa
43808ba
8755a5f
10ab8b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,44 +1,213 @@ | ||||||||||||||
load("//bazel:ray.bzl", "ray_cc_library") | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "util", | ||||||||||||||
srcs = glob( | ||||||||||||||
[ | ||||||||||||||
"*.cc", | ||||||||||||||
], | ||||||||||||||
exclude = [ | ||||||||||||||
"*_test.cc", | ||||||||||||||
], | ||||||||||||||
), | ||||||||||||||
hdrs = glob([ | ||||||||||||||
"*.h", | ||||||||||||||
]), | ||||||||||||||
linkopts = select({ | ||||||||||||||
"@platforms//os:windows": [], | ||||||||||||||
"//conditions:default": ["-lpthread"], | ||||||||||||||
}), | ||||||||||||||
name = "visibility", | ||||||||||||||
hdrs = ["visibility.h"], | ||||||||||||||
) | ||||||||||||||
Comment on lines
3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are these single header libraries? are they actually just header-only libraries? this will not even generate object files. I think there are also bazel rules that are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand, but it's common to have header-only targets. |
||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "macros", | ||||||||||||||
hdrs = ["macros.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "event_label", | ||||||||||||||
hdrs = ["event_label.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "array", | ||||||||||||||
hdrs = ["array.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "thread_utils", | ||||||||||||||
hdrs = ["thread_utils.h"], | ||||||||||||||
deps = [ | ||||||||||||||
":thread_checker", | ||||||||||||||
"//:aligned_alloc", | ||||||||||||||
"//:sha256", | ||||||||||||||
], | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines 216 to 221 in 8ba3ffa
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well for missing dependency issue, we should trust the compiler and CI |
||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "exponential_backoff", | ||||||||||||||
hdrs = ["exponential_backoff.h"], | ||||||||||||||
srcs = ["exponential_backoff.cc"], | ||||||||||||||
deps = [ | ||||||||||||||
":logging", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
# TODO(hjiang): filesystem and logging has interdependency, we should split them into three targets: filesystem, logging, ray_check_macros. | ||||||||||||||
ray_cc_library( | ||||||||||||||
name = "logging", | ||||||||||||||
hdrs = [ | ||||||||||||||
"filesystem.h", | ||||||||||||||
"logging.h", | ||||||||||||||
], | ||||||||||||||
srcs = [ | ||||||||||||||
"filesystem.cc", | ||||||||||||||
"logging.cc", | ||||||||||||||
], | ||||||||||||||
deps = [ | ||||||||||||||
":event_label", | ||||||||||||||
":macros", | ||||||||||||||
":thread_utils", | ||||||||||||||
"@com_github_spdlog//:spdlog", | ||||||||||||||
"@com_google_absl//absl/debugging:failure_signal_handler", | ||||||||||||||
"@com_google_absl//absl/strings:str_format", | ||||||||||||||
"@com_google_googletest//:gtest_main", | ||||||||||||||
"@nlohmann_json", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "container_util", | ||||||||||||||
hdrs = ["container_util.h"], | ||||||||||||||
deps = [ | ||||||||||||||
":logging", | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_map", | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_set", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "process", | ||||||||||||||
hdrs = [ | ||||||||||||||
"process.h", | ||||||||||||||
"subreaper.h", | ||||||||||||||
], | ||||||||||||||
srcs = [ | ||||||||||||||
"process.cc", | ||||||||||||||
"subreaper.cc", | ||||||||||||||
], | ||||||||||||||
deps = [ | ||||||||||||||
":logging", | ||||||||||||||
":macros", | ||||||||||||||
"@boost//:asio", | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_set", | ||||||||||||||
"@com_google_absl//absl/synchronization", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "function_traits", | ||||||||||||||
hdrs = ["function_traits.h"], | ||||||||||||||
deps = [ | ||||||||||||||
"@boost//:functional", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "counter_map", | ||||||||||||||
hdrs = ["counter_map.h"], | ||||||||||||||
deps = [ | ||||||||||||||
":logging", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "event", | ||||||||||||||
hdrs = ["event.h"], | ||||||||||||||
srcs = ["event.cc"], | ||||||||||||||
deps = [ | ||||||||||||||
":logging", | ||||||||||||||
":random", | ||||||||||||||
":string_utils", | ||||||||||||||
":timestamp_utils", | ||||||||||||||
"//src/ray/protobuf:event_cc_proto", | ||||||||||||||
"//src/ray/protobuf:export_event_cc_proto", | ||||||||||||||
"@boost//:asio", | ||||||||||||||
"@com_github_spdlog//:spdlog", | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_map", | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_set", | ||||||||||||||
"@com_google_absl//absl/debugging:failure_signal_handler", | ||||||||||||||
"@com_google_absl//absl/debugging:stacktrace", | ||||||||||||||
"@com_google_absl//absl/debugging:symbolize", | ||||||||||||||
"@com_google_absl//absl/random", | ||||||||||||||
"@com_google_absl//absl/synchronization", | ||||||||||||||
"@com_google_absl//absl/time", | ||||||||||||||
"@com_google_googletest//:gtest_main", | ||||||||||||||
"@com_google_googletest//:gtest_prod", | ||||||||||||||
"@com_google_protobuf//:protobuf", | ||||||||||||||
"@nlohmann_json", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "timestamp_utils", | ||||||||||||||
hdrs = ["timestamp_utils.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "random", | ||||||||||||||
hdrs = ["random.h"], | ||||||||||||||
deps = [ | ||||||||||||||
"@com_google_absl//absl/random", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "string_utils", | ||||||||||||||
hdrs = ["string_utils.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "memory", | ||||||||||||||
hdrs = ["memory.h"], | ||||||||||||||
srcs = ["memory.cc"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "type_traits", | ||||||||||||||
hdrs = ["type_traits.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "throttler", | ||||||||||||||
hdrs = ["throttler.h"], | ||||||||||||||
deps = [ | ||||||||||||||
"@com_google_absl//absl/time", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "sequencer", | ||||||||||||||
hdrs = ["sequencer.h"], | ||||||||||||||
deps = [ | ||||||||||||||
"@com_google_absl//absl/container:flat_hash_map", | ||||||||||||||
"@com_google_absl//absl/synchronization", | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "sample", | ||||||||||||||
hdrs = ["sample.h"], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
# A giant 'util' target is split since PR https://github.com/ray-project/ray/pull/49938, here we keep the 'util' target for API compatibility. | ||||||||||||||
# | ||||||||||||||
# TODO(hjiang): We include a bunch of misc util function/class inside of the class, should split into multiple files and build targets. | ||||||||||||||
ray_cc_library( | ||||||||||||||
name = "util", | ||||||||||||||
hdrs = ["util.h"], | ||||||||||||||
srcs = ["util.cc"], | ||||||||||||||
deps = [ | ||||||||||||||
":array", | ||||||||||||||
":container_util", | ||||||||||||||
":counter_map", | ||||||||||||||
":event", | ||||||||||||||
":event_label", | ||||||||||||||
":exponential_backoff", | ||||||||||||||
":function_traits", | ||||||||||||||
":logging", | ||||||||||||||
":macros", | ||||||||||||||
":memory", | ||||||||||||||
":process", | ||||||||||||||
":random", | ||||||||||||||
":sample", | ||||||||||||||
":sequencer", | ||||||||||||||
":string_utils", | ||||||||||||||
":timestamp_utils", | ||||||||||||||
":throttler", | ||||||||||||||
":thread_utils", | ||||||||||||||
":type_traits", | ||||||||||||||
":visibility", | ||||||||||||||
"//:sha256", | ||||||||||||||
Comment on lines
+186
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah.. this feels a bit wrong.. that a util library depends on so many other libs here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's written this way for target compatibility, otherwise I have to manually update a thousand files. As I mentioned here, it's worth another PR to further cleanup the util target dependency. |
||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
ray_cc_library( | ||||||||||||||
name = "size_literals", | ||||||||||||||
hdrs = ["size_literals.h"], | ||||||||||||||
|
@@ -82,6 +251,8 @@ ray_cc_library( | |||||||||||||
srcs = ["pipe_logger.cc"], | ||||||||||||||
deps = [ | ||||||||||||||
":compat", | ||||||||||||||
":stream_redirection_options", | ||||||||||||||
":thread_utils", | ||||||||||||||
":util", | ||||||||||||||
"@com_github_spdlog//:spdlog", | ||||||||||||||
"@com_google_absl//absl/strings", | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <cstdint> | ||
|
||
namespace 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.
@aslonnie is this file now follows bazel best practice? Need your expertise here :)
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.
Not yet, the followup PR is:
utils
bazel target and depend what we use;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.
overall seems fine. probably will be non-trivial to maintain this manually though.
it is the right thing to do to have fine-grained bazel build rules to have the best build performance. in the long run, we will need tools to auto maintain this build file based on static analysis of source files.
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 agree, in Nuro we have BUILD file auto-generation so I never need to hand-write bazel file;
I checked some open source tools like gazelle, but none of them seem to support C++; if you could help me with that I would be much grateful!