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] Fix profile_events use after move #49776

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dayshah
Copy link
Contributor

@dayshah dayshah commented Jan 11, 2025

Why are these changes needed?

Fix use after move

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: dayshah <dhyey2019@gmail.com>
@dayshah dayshah requested a review from jjyao January 11, 2025 01:27
@dayshah dayshah added the go add ONLY when ready to merge, run all tests label Jan 11, 2025
Signed-off-by: dayshah <dhyey2019@gmail.com>
if (export_event_write_enabled_) {
WriteExportData(std::move(status_events_to_write_for_export),
std::vector{profile_events_to_send});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reordered because this is an env variable which is false by default, so we should only copy in the rare case that a user has changed it to true

Signed-off-by: dayshah <dhyey2019@gmail.com>
@dayshah
Copy link
Contributor Author

dayshah commented Jan 11, 2025

wait this will still actually never work in the current state, I'm assuming nobody ever turned on export_event_write

They were taking by vectors by rvalue and not actually doing moves on the shared ptrs inside. Instead what's actually hapening is that ToRpcTaskEvents and ToRpcTaskExportEvents actually move the underlying instance variables. So even if we copy the vector we're just copying the shared pointers pointing to the same objects and still moving out the underlying strings.

3 options:

  1. Easy - Just copy the underlying instance variables and pass vecs by const lvalue which I'm doing in this pr
  2. Remove export_event_write if not used, keep the moves, and fix to be 'correct' C++ in the future
  3. Refactor to correctly copy and move in the right places and rvalue qualify the member functions and stop boxing the TaskEvents in shared ptrs. I can do when I have free time or @dentiny for fun lol

@dayshah
Copy link
Contributor Author

dayshah commented Jan 11, 2025

to clarify the issue is that CreateDataToSend calls ToRpcTaskEvents on the TaskEvents inside profile_events and WriteExportData calls ToRpcTaskExportEvents also on the TaskEvents inside profile_events. And they both move the same instance variables in TaskProfileEvent

Signed-off-by: dayshah <dhyey2019@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants