[core] Lint cpp files in core_worker#48789
Conversation
Signed-off-by: dayshah <dhyey2019@gmail.com>
|
These changes looks valid and great, do we plan to merge this PR? Let me know if there's anything I could help! |
Signed-off-by: dayshah <dhyey2019@gmail.com>
Signed-off-by: dayshah <dhyey2019@gmail.com>
ya just needed it to go through headers separately and do some manual stuff |
Signed-off-by: dayshah <dhyey2019@gmail.com>
Signed-off-by: dayshah <dhyey2019@gmail.com>
|
|
||
| void ActorManager::MarkActorKilledOrOutOfScope( | ||
| std::shared_ptr<ActorHandle> actor_handle) { | ||
| const std::shared_ptr<ActorHandle> &actor_handle) { |
There was a problem hiding this comment.
If the ownership is not transferred, what about const ActorHandle&?
Reasons:
- Const reference ensures immutability and non-nullability;
- From my limited programming experience, I almost never see people using
const std::shared_ptr<>.
There was a problem hiding this comment.
agree I think const ActorHandle& makes sense, and shared ptr copy avoidance makes basically no effect
But it was just a clang-tidy fix where it's copied and not moved so can be ref, and linters don't consider it to be trivially copyable, i assume because copy means you're still accessing ref counter and doing the atomic increment which can be a little bit of a hit on heavily threaded code (which we don't really have), but still just for the linter.
Later I think it could also make things easier to review to cut down on # of shared ptrs if we see paths where there's no real copies being made, cutting down on # of shared ptrs will make a diff
There was a problem hiding this comment.
But it was just a clang-tidy fix where it's copied and not moved so can be ref
I'm sure using ref instead of shared pointer is better, and clang tidy will not complain about it.
My take on clang-tidy is, it's useful to provide good-enough feedbacks, but not perfect; that's why we need NOLINT.
There was a problem hiding this comment.
I'll make a follow-up pr off of this to change all const shared_ptr& that were changed on this to const &, but want to minimize more manual changes on this
There was a problem hiding this comment.
Feel free to leave a TODO if you plan to followup (just in case we forget :) )
dentiny
left a comment
There was a problem hiding this comment.
Would be nice to document the linting command (step-by-step) in the PR descriptor, or somewhere more formal for better visibility and educational purpose :)
| // instance, the sem_unlink() calls below will both fail with ENOENT. | ||
| int ret = sem_unlink(GetSemaphoreHeaderName(name).c_str()); | ||
| if (ret) { | ||
| if (ret != 0) { |
There was a problem hiding this comment.
I feel like we should have macros to handle syscall errors.
There was a problem hiding this comment.
added todo comment for follow-up, wanna keep changes minimal to clang-tidy stuff here, ruiyang's comment mentioned trying to keep this limited for review purposes
There was a problem hiding this comment.
a nit on comment, I really prefer to have a macro for syscall, since I think we heavily do syscall in our codebase.
installed llvm i also tried various --header-filter but didn't get great results, i found putting extra .clang-tidy file with just -* in directories you don't want to lint can be a potential solution to speed it up And then I go through manually, have clangd setup locally from https://github.com/ray-project/ray/blob/master/BUILD.bazel#L102-L108. And then manually fix things it highlights / related things i see I'm also trying to add this (https://github.com/lljbash/clangd-tidy) as a pre-commit hook or in ci and will put these directions on fixing there |
| : spec(std::move(spec_arg)), | ||
| num_retries_left(num_retries_left_arg), | ||
| counter(counter), | ||
| counter(&counter), |
There was a problem hiding this comment.
Bad naming... Avoid naming ctor argument and data member the same.
There was a problem hiding this comment.
can do in a follow-up want to minimize more changes here
dentiny
left a comment
There was a problem hiding this comment.
Thanks for the effort! Just a few suggestions/comments, happy to discuss.
Signed-off-by: Dhyey Shah <dhyey2019@gmail.com>
|
Whoa this is impressive. I took a glance and generally LGTM, though I did not read every line. Can you do a Is the .clang-tidy change affecting CI? Lint failure in microcheck |
Signed-off-by: dayshah <dhyey2019@gmail.com>
Signed-off-by: dayshah <dhyey2019@gmail.com>
|
Signed-off-by: Dhyey Shah <dhyey2019@gmail.com>
Signed-off-by: dayshah <dhyey2019@gmail.com>
|
merge conflict |
Signed-off-by: Dhyey Shah <dhyey2019@gmail.com>
dentiny
left a comment
There was a problem hiding this comment.
Thanks for the effort!
If you don't mind, when you have some time, could you please have a short doc how to play with clang tidy and do some education? playing clang-tidy with bazel requires some setup, for example, the compilation server.
Signed-off-by: dayshah <dhyey2019@gmail.com>
|
merge conflict |
updated |
Why are these changes needed?
Running clang-tidy on files in core-worker, mostly auto-fixes from clang-tidy, some manual fixes. Want it to be part of ci or pre-commit hook once we lint the core src codebase.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.