Repository navigation
[core] (FreeObjects 2/n) Remove original FreeObjects RPC and original ObjectEviction pubsub - #63181
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the pubsub-based object eviction mechanism with a direct RPC-based approach using FreeLocalObjects and renames related configuration parameters. Feedback identifies high-severity issues regarding breaking wire compatibility by renumbering the ChannelType enum and breaking user configurations by renaming parameters. Additionally, optimizations were suggested for the SpreadFreeLocalObjects logic and the construction of the locations vector in the ReferenceCounter to avoid unnecessary copies and overhead.
cef2274 to
3155aa4
Compare
dd1e250 to
5f7057f
Compare
5f7057f to
cb13b9a
Compare
cb13b9a to
7de6f5c
Compare
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
7de6f5c to
6b132e1
Compare
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
6b132e1 to
ddcdd90
Compare
| @@ -40,7 +40,7 @@ class PublisherTest : public ::testing::Test { | |||
| publisher_ = std::make_shared<Publisher>( | |||
| /*channels=*/ | |||
| std::vector<rpc::ChannelType>{ | |||
| rpc::ChannelType::WORKER_OBJECT_EVICTION, | |||
| rpc::ChannelType::WORKER_OBJECT_LOCATIONS_CHANNEL, | |||
There was a problem hiding this comment.
Duplicate channel type in publisher test setup
Low Severity
WORKER_OBJECT_LOCATIONS_CHANNEL appears twice in the publisher's channel list (lines 43 and 45). When replacing the removed WORKER_OBJECT_EVICTION channel, the developer accidentally substituted WORKER_OBJECT_LOCATIONS_CHANNEL which was already present in the list. This duplicate registration may cause unexpected behavior depending on how the Publisher initializes channel state internally.
Reviewed by Cursor Bugbot for commit ddcdd9096075107a675903b2c484b8c32216d66b. Configure here.
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]> # Conflicts: # src/ray/raylet/local_object_manager.cc
Signed-off-by: aaron.li <[email protected]>
… free mechanism (#63218) ## Motivation Within this multi-step PR process, our goal is to change our current **FreeObjects** implementation to an owner driven process. Current design of FreeObjects involves spraying the entire cluster with FreeObjects RPCs. This introduces many caveats: bloating observability with FreeObjects RPC counts, sending excessive RPCs, and worse mental model from owner-driven reference counting. This is a continuation from #63117. Due to the race condition detailed in the testing section of the PR, we decided to merge both changes for a complete PR. Our current design for **FreeObjects** involves the following steps: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner finds out, and sends a pubsub message (initialized when pinning the primary copy) to the primary copy raylet. 3. The primary copy raylet frees its primary copy, and then broadcasts free secondary copies to all nodes within the cluster. (This is batched and sent periodically). The reason the primary copy raylet needs to broadcast secondary copies is because it doesn't store object locations for its primary copy, this is only stored on the owner. Thus, in order to ensure all secondary copies are freed, there is a need to broadcast to all nodes. ## Design As noted above, the owner stores the locations of all copies of the objects, where `pinned_at_node_id_` represents the primary copy location and the `locations` vector demonstrates all secondary object locations. We now move towards a new design **FreeObjects**. We will get rid of the pubsub between owner -> primary copy raylet. Instead: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner sends RPCs to primary and secondary copy holders to free their objects. (Since it has all of its locations) However, this doesn't easily solve our issue since the pubsub also has an `owner_dead_callback`, which fires when the owner has died. This will help clean up the primary object and ensure there are no memory leaks in this case. To continue supporting this functionality, if the owner dies, this information is propagated by the GCS, and thus each raylet just listens to the GCS events and updates their states accordingly. Originally, the design was that: - the pubsub connection fails / ends for some unexpected reason - the owner is thought to be dead, so the primary copy raylet then frees its primary copy and queues up **FreeObjects** to broadcast to all secondary copies The new design: - The GCS already publishes WorkerFailure and NodeRemoved announcements to all raylets. This is so that raylets know to release worker leases of dead nodes / workers - With this new design, the raylets will listen and additionally clear any objects that had their owner on the failed worker / node - Something to consider is how exactly GCS gets these notifications, and if there would be any slowness in these notifications. 1.) When the worker process dies (but the node remains alive), the raylet picks up the worker death relatively quickly via the broken IPC connection and sends the worker death up to the GCS, and GCS broadcasts it. 2.) On node death, similar story. However, in old implementation, the long poll connection would be sitting the retryable grpc client queue waiting for either the connection to come back up or the GCS to get a worker death notification. Hence all in all, there really shouldn't be a significant change in behavior. ## Description This PR covers the first and second part of the **FreeObjects** change. The first part is strictly adding functionality for the owner to be in charge of freeing objects. We make the first step away from this design such that the owner calls a new **FreeLocalObjects** RPC to all primary and secondary copy locations when **OnObjectsOutOfScopeOrFreed**. The second part amends the functionality of the current owner dead pubsub callback to be moved from an eager pubsub death callback to a more passive listener callback. ## Considerations ### NodeManager RPC vs. ObjectManager RPC For this PR, I considered either 1) Adding a new RPC to **NodeManager** or 2) Adding new route that calls into existing **ObjectManager** FreeObjects. Ultimately, I decided to go with 1). A design consideration here is that workers currently only call into raylets' **NodeManager**, so part of this is to keep with existing implementation. Another reason is that our new **HandleFreeLocalObjects** would be responsible for 2 things: 1) if primary copy, delete metadata from **LocalObjectManager** (manages spilled and primary copies) and 2) if any copy, queue up within **FreeObjects**. Thus, **NodeManager** currently has functionality that calls into **LocalObjectManager**. Furthermore, I find that directly interfacing with **ObjectManager** is not as intuitive, and creating a new path just for **ObjectManager** does not seem ideal. ### Moving Around ReferenceCounter Variables For this PR, I decided to follow similar formats in the codebase, and have all the lambdas within the constructor shifted to the end. In this case, they can be considered optional arguments and can be defaulted to null if not specified. This leads to easier testing implementations. A tricky part is to ensure these functions generate no-op if they are not specified. ### Only Owner Frees An important consideration is that now that we are sending from the worker side, only if the object is freed is owned by the current worker should the worker send RPC requests to the object locations. Otherwise, the worker should just keep quiet. ### Dead Code Deleted in Future For this PR, I kept **FreeObjects**'s `local_only=false` case still alive, even though this case is essentially never called again. In the future, I will delete this dead code. ### Testing Changes and ReferenceCounter Changes For this PR, there were many testing changes that are needed because of this new path that is different from the first one. For now, many of these tests are just hardcoded to match correct behavior, but in the future some unnecessary tests might be deleted or shuffled around to match the new implementation. ### Pass Over All Objects This new design introduces a pass over all objects within the current node every announcement. However, failed nodes and worker announcements should not be too common and if the object is not owned by the failed worker / node it would be a no-op; thus this should not lead to any latency issues. ### Owner is Less Eager This new design will be a less eager free, especially for the primary copy of the node. This is definitely an important part to consider, however since it is similar a pubsub for node information, the latency should not be that big of a deal. Furthermore, the pubsub interface already keeps track of network failures etc. to some extent, and if there are further failures / GCS failures there are probably worse problems to deal with. ### LocalObjectManager local_objects_ vs. ObjectManager local_objects_ An important distinction is needed between both classes' local objects, where we need to aggregate and free any objects within both classes. LocalObjectManager in this case keeps track of primary copies as well as spilled copies. ObjectManager keeps track of anything in plasma such as primary copies / secondary copies. Thus, we need to get the union of both objects to get the objects that we want to free. ## Testing Ran python tests and C++ tests adjacent to these changes to ensure no regressions. Future e2e testing in #63181 We will fix this race condition in the immediate next PR, which uses the GCS to broadcast deaths and have the raylets free accordingly. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]>
Signed-off-by: aaronscalene <[email protected]>
… free mechanism (ray-project#63218) ## Motivation Within this multi-step PR process, our goal is to change our current **FreeObjects** implementation to an owner driven process. Current design of FreeObjects involves spraying the entire cluster with FreeObjects RPCs. This introduces many caveats: bloating observability with FreeObjects RPC counts, sending excessive RPCs, and worse mental model from owner-driven reference counting. This is a continuation from ray-project#63117. Due to the race condition detailed in the testing section of the PR, we decided to merge both changes for a complete PR. Our current design for **FreeObjects** involves the following steps: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner finds out, and sends a pubsub message (initialized when pinning the primary copy) to the primary copy raylet. 3. The primary copy raylet frees its primary copy, and then broadcasts free secondary copies to all nodes within the cluster. (This is batched and sent periodically). The reason the primary copy raylet needs to broadcast secondary copies is because it doesn't store object locations for its primary copy, this is only stored on the owner. Thus, in order to ensure all secondary copies are freed, there is a need to broadcast to all nodes. ## Design As noted above, the owner stores the locations of all copies of the objects, where `pinned_at_node_id_` represents the primary copy location and the `locations` vector demonstrates all secondary object locations. We now move towards a new design **FreeObjects**. We will get rid of the pubsub between owner -> primary copy raylet. Instead: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner sends RPCs to primary and secondary copy holders to free their objects. (Since it has all of its locations) However, this doesn't easily solve our issue since the pubsub also has an `owner_dead_callback`, which fires when the owner has died. This will help clean up the primary object and ensure there are no memory leaks in this case. To continue supporting this functionality, if the owner dies, this information is propagated by the GCS, and thus each raylet just listens to the GCS events and updates their states accordingly. Originally, the design was that: - the pubsub connection fails / ends for some unexpected reason - the owner is thought to be dead, so the primary copy raylet then frees its primary copy and queues up **FreeObjects** to broadcast to all secondary copies The new design: - The GCS already publishes WorkerFailure and NodeRemoved announcements to all raylets. This is so that raylets know to release worker leases of dead nodes / workers - With this new design, the raylets will listen and additionally clear any objects that had their owner on the failed worker / node - Something to consider is how exactly GCS gets these notifications, and if there would be any slowness in these notifications. 1.) When the worker process dies (but the node remains alive), the raylet picks up the worker death relatively quickly via the broken IPC connection and sends the worker death up to the GCS, and GCS broadcasts it. 2.) On node death, similar story. However, in old implementation, the long poll connection would be sitting the retryable grpc client queue waiting for either the connection to come back up or the GCS to get a worker death notification. Hence all in all, there really shouldn't be a significant change in behavior. ## Description This PR covers the first and second part of the **FreeObjects** change. The first part is strictly adding functionality for the owner to be in charge of freeing objects. We make the first step away from this design such that the owner calls a new **FreeLocalObjects** RPC to all primary and secondary copy locations when **OnObjectsOutOfScopeOrFreed**. The second part amends the functionality of the current owner dead pubsub callback to be moved from an eager pubsub death callback to a more passive listener callback. ## Considerations ### NodeManager RPC vs. ObjectManager RPC For this PR, I considered either 1) Adding a new RPC to **NodeManager** or 2) Adding new route that calls into existing **ObjectManager** FreeObjects. Ultimately, I decided to go with 1). A design consideration here is that workers currently only call into raylets' **NodeManager**, so part of this is to keep with existing implementation. Another reason is that our new **HandleFreeLocalObjects** would be responsible for 2 things: 1) if primary copy, delete metadata from **LocalObjectManager** (manages spilled and primary copies) and 2) if any copy, queue up within **FreeObjects**. Thus, **NodeManager** currently has functionality that calls into **LocalObjectManager**. Furthermore, I find that directly interfacing with **ObjectManager** is not as intuitive, and creating a new path just for **ObjectManager** does not seem ideal. ### Moving Around ReferenceCounter Variables For this PR, I decided to follow similar formats in the codebase, and have all the lambdas within the constructor shifted to the end. In this case, they can be considered optional arguments and can be defaulted to null if not specified. This leads to easier testing implementations. A tricky part is to ensure these functions generate no-op if they are not specified. ### Only Owner Frees An important consideration is that now that we are sending from the worker side, only if the object is freed is owned by the current worker should the worker send RPC requests to the object locations. Otherwise, the worker should just keep quiet. ### Dead Code Deleted in Future For this PR, I kept **FreeObjects**'s `local_only=false` case still alive, even though this case is essentially never called again. In the future, I will delete this dead code. ### Testing Changes and ReferenceCounter Changes For this PR, there were many testing changes that are needed because of this new path that is different from the first one. For now, many of these tests are just hardcoded to match correct behavior, but in the future some unnecessary tests might be deleted or shuffled around to match the new implementation. ### Pass Over All Objects This new design introduces a pass over all objects within the current node every announcement. However, failed nodes and worker announcements should not be too common and if the object is not owned by the failed worker / node it would be a no-op; thus this should not lead to any latency issues. ### Owner is Less Eager This new design will be a less eager free, especially for the primary copy of the node. This is definitely an important part to consider, however since it is similar a pubsub for node information, the latency should not be that big of a deal. Furthermore, the pubsub interface already keeps track of network failures etc. to some extent, and if there are further failures / GCS failures there are probably worse problems to deal with. ### LocalObjectManager local_objects_ vs. ObjectManager local_objects_ An important distinction is needed between both classes' local objects, where we need to aggregate and free any objects within both classes. LocalObjectManager in this case keeps track of primary copies as well as spilled copies. ObjectManager keeps track of anything in plasma such as primary copies / secondary copies. Thus, we need to get the union of both objects to get the objects that we want to free. ## Testing Ran python tests and C++ tests adjacent to these changes to ensure no regressions. Future e2e testing in ray-project#63181 We will fix this race condition in the immediate next PR, which uses the GCS to broadcast deaths and have the raylets free accordingly. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
unstale |
| /// At least one message must be set. | ||
| oneof inner_message { | ||
| WorkerObjectEvictionMessage worker_object_eviction_message = 3; | ||
| WorkerRefRemovedMessage worker_ref_removed_message = 4; |
There was a problem hiding this comment.
should start from 3 here
| /*channels=*/ | ||
| std::vector<rpc::ChannelType>{ | ||
| rpc::ChannelType::WORKER_OBJECT_EVICTION, | ||
| rpc::ChannelType::WORKER_OBJECT_LOCATIONS_CHANNEL, |
There was a problem hiding this comment.
You're right, good catch.
| pubsub::SubscriptionItemCallback subscription_callback, | ||
| pubsub::SubscriptionFailureCallback subscription_failure_callback) override { | ||
| auto worker_id = WorkerID::FromBinary(owner_address.worker_id()); | ||
| callbacks[worker_id].push_back( |
There was a problem hiding this comment.
are we deleting callbacks since it was only used for worker object evictions?
There was a problem hiding this comment.
Yes, we should just have no more testing for pubsub within this local_object_manager_test file. Decided to just replace it with FakePubsub.
Sparks0219
left a comment
There was a problem hiding this comment.
LGTM, just had a couple nits. Once those are addressed + merge conflicts should be good to go
…eviction-pubsub # Conflicts: # src/ray/core_worker/core_worker_process.cc # src/ray/core_worker/tests/core_worker_test.cc
Sparks0219
left a comment
There was a problem hiding this comment.
LGTM, thanks for wrapping this up!
… free mechanism (ray-project#63218) ## Motivation Within this multi-step PR process, our goal is to change our current **FreeObjects** implementation to an owner driven process. Current design of FreeObjects involves spraying the entire cluster with FreeObjects RPCs. This introduces many caveats: bloating observability with FreeObjects RPC counts, sending excessive RPCs, and worse mental model from owner-driven reference counting. This is a continuation from ray-project#63117. Due to the race condition detailed in the testing section of the PR, we decided to merge both changes for a complete PR. Our current design for **FreeObjects** involves the following steps: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner finds out, and sends a pubsub message (initialized when pinning the primary copy) to the primary copy raylet. 3. The primary copy raylet frees its primary copy, and then broadcasts free secondary copies to all nodes within the cluster. (This is batched and sent periodically). The reason the primary copy raylet needs to broadcast secondary copies is because it doesn't store object locations for its primary copy, this is only stored on the owner. Thus, in order to ensure all secondary copies are freed, there is a need to broadcast to all nodes. ## Design As noted above, the owner stores the locations of all copies of the objects, where `pinned_at_node_id_` represents the primary copy location and the `locations` vector demonstrates all secondary object locations. We now move towards a new design **FreeObjects**. We will get rid of the pubsub between owner -> primary copy raylet. Instead: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner sends RPCs to primary and secondary copy holders to free their objects. (Since it has all of its locations) However, this doesn't easily solve our issue since the pubsub also has an `owner_dead_callback`, which fires when the owner has died. This will help clean up the primary object and ensure there are no memory leaks in this case. To continue supporting this functionality, if the owner dies, this information is propagated by the GCS, and thus each raylet just listens to the GCS events and updates their states accordingly. Originally, the design was that: - the pubsub connection fails / ends for some unexpected reason - the owner is thought to be dead, so the primary copy raylet then frees its primary copy and queues up **FreeObjects** to broadcast to all secondary copies The new design: - The GCS already publishes WorkerFailure and NodeRemoved announcements to all raylets. This is so that raylets know to release worker leases of dead nodes / workers - With this new design, the raylets will listen and additionally clear any objects that had their owner on the failed worker / node - Something to consider is how exactly GCS gets these notifications, and if there would be any slowness in these notifications. 1.) When the worker process dies (but the node remains alive), the raylet picks up the worker death relatively quickly via the broken IPC connection and sends the worker death up to the GCS, and GCS broadcasts it. 2.) On node death, similar story. However, in old implementation, the long poll connection would be sitting the retryable grpc client queue waiting for either the connection to come back up or the GCS to get a worker death notification. Hence all in all, there really shouldn't be a significant change in behavior. ## Description This PR covers the first and second part of the **FreeObjects** change. The first part is strictly adding functionality for the owner to be in charge of freeing objects. We make the first step away from this design such that the owner calls a new **FreeLocalObjects** RPC to all primary and secondary copy locations when **OnObjectsOutOfScopeOrFreed**. The second part amends the functionality of the current owner dead pubsub callback to be moved from an eager pubsub death callback to a more passive listener callback. ## Considerations ### NodeManager RPC vs. ObjectManager RPC For this PR, I considered either 1) Adding a new RPC to **NodeManager** or 2) Adding new route that calls into existing **ObjectManager** FreeObjects. Ultimately, I decided to go with 1). A design consideration here is that workers currently only call into raylets' **NodeManager**, so part of this is to keep with existing implementation. Another reason is that our new **HandleFreeLocalObjects** would be responsible for 2 things: 1) if primary copy, delete metadata from **LocalObjectManager** (manages spilled and primary copies) and 2) if any copy, queue up within **FreeObjects**. Thus, **NodeManager** currently has functionality that calls into **LocalObjectManager**. Furthermore, I find that directly interfacing with **ObjectManager** is not as intuitive, and creating a new path just for **ObjectManager** does not seem ideal. ### Moving Around ReferenceCounter Variables For this PR, I decided to follow similar formats in the codebase, and have all the lambdas within the constructor shifted to the end. In this case, they can be considered optional arguments and can be defaulted to null if not specified. This leads to easier testing implementations. A tricky part is to ensure these functions generate no-op if they are not specified. ### Only Owner Frees An important consideration is that now that we are sending from the worker side, only if the object is freed is owned by the current worker should the worker send RPC requests to the object locations. Otherwise, the worker should just keep quiet. ### Dead Code Deleted in Future For this PR, I kept **FreeObjects**'s `local_only=false` case still alive, even though this case is essentially never called again. In the future, I will delete this dead code. ### Testing Changes and ReferenceCounter Changes For this PR, there were many testing changes that are needed because of this new path that is different from the first one. For now, many of these tests are just hardcoded to match correct behavior, but in the future some unnecessary tests might be deleted or shuffled around to match the new implementation. ### Pass Over All Objects This new design introduces a pass over all objects within the current node every announcement. However, failed nodes and worker announcements should not be too common and if the object is not owned by the failed worker / node it would be a no-op; thus this should not lead to any latency issues. ### Owner is Less Eager This new design will be a less eager free, especially for the primary copy of the node. This is definitely an important part to consider, however since it is similar a pubsub for node information, the latency should not be that big of a deal. Furthermore, the pubsub interface already keeps track of network failures etc. to some extent, and if there are further failures / GCS failures there are probably worse problems to deal with. ### LocalObjectManager local_objects_ vs. ObjectManager local_objects_ An important distinction is needed between both classes' local objects, where we need to aggregate and free any objects within both classes. LocalObjectManager in this case keeps track of primary copies as well as spilled copies. ObjectManager keeps track of anything in plasma such as primary copies / secondary copies. Thus, we need to get the union of both objects to get the objects that we want to free. ## Testing Ran python tests and C++ tests adjacent to these changes to ensure no regressions. Future e2e testing in ray-project#63181 We will fix this race condition in the immediate next PR, which uses the GCS to broadcast deaths and have the raylets free accordingly. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]>
… ObjectEviction pubsub (#63181) ## Description The first two parts of this feature demonstrated removing the dependency of the pubsub as well as the **FreeObjects** spray, and thus many original implementations are also necessary to be gutted. In this PR, we will target removing the 1) original FreeObjects RPC and the `local_only=false` branch and also 2) completely remove and get rid of the **ObjectEviction** pubsub. Now, the new **FreeObjects** design completely depends on the new design that we have. For 1): Essentially, we will remove these parts: - We no longer need the `FreeObjects` RPC that was broadcasted to all nodes, so we can delete this and any code relating this (tests, proto, etc.) - We no longer need `local_only=false` option (broadcasted `FreeObjects` RPC), so we can delete any logic relating to this as well. For 2): We will remove: - There is no longer a pubsub for object eviction which is removed When an object has no more references, we will now: Send **FreeLocalObject** RPCs to every raylet that we know has either a primary or secondary copy. If an owner has died, whether its worker process fails or node dies, then this will be broadcasted through the GCS. Any raylets that receive this notification will delete any copies they hold of the owner's objects accordingly. ## Considerations ### Test Changes There were some tests that relied on this RPC call to just test pubsub correctedness, I changed the channel to use a different one instead. There were also old tests that tested the pubsub as part of an e2e test for making sure an object becomes freed. I decided to remove the pubsub checks, but keep the overall test to ensure there is still the same functionality. ## Testing ### Initial Benchmarking Now that all parts of **FreeObjects** has been written, I decided to dive into benchmarking to ensure there are no regressions. I ran two of the following data release tests, each freeing thousands of objects: - [gpu_batch_inference.py](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/dataset/gpu_batch_inference.py) - [ray_data_main.py](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/multimodal_inference_benchmarks/audio_transcription/ray_data_main.py) These were ran with the following [benchmark](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/dataset/benchmark.py). Both tests on high level demonstrated no regression in throughput or overall latency. However, digging more into the perf graphs revealed a caveat. **FreeObjects** itself, although called a lot, is not necessarily a big part of the data-intensive workloads themselves. Thus, this requires still more investigation into the driver io_context for us to be sure there are no regressions there. Another investigation that is required is that whether this improves raylet RPC contention and overall raylet io context latency as we claim. ### Driver io_context Investigation #### Driver io_context with FreeObjects <img width="1199" height="348" alt="image" src="https://github.com/user-attachments/assets/615b19be-d285-463c-b601-ae583b46d731" /> #### New driver io_context <img width="1192" height="391" alt="image" src="https://github.com/user-attachments/assets/4c2c592c-4d17-498d-a405-8a1e7d40a612" /> #### Extra FreeLocalObjects Work But Pubsub Dropped Both driver_io context perfs are ran on the driver for the **gpu_batch_inference.py** data benchmark. The second image represents the current branch's changes, with **FreeLocalObjects** highlighted in pink within the **worker_io_context**. The highlighted part accounts for roughly **~500,000,000** samples. However, the overall **worker_io** samples only increased by **30,000,000** samples, partly because pubsub decreased by **~350,000,000** samples as well. This is because there is no need for **ObjectEviction** pubsubs to be fired anymore, which seems to result in less contention and less strain on the pubsub grpc, which allows less CPU wall time on pubsub in general. Based on ray logs, we can support this claim further. For **FreeLocalObjects**: | Counter | Count | Exec mean | Exec total | Queueing mean | Queueing total | |---|---:|---:|---:|---:|---:| | `CoreWorker.SpreadFreeLocalObjects` | 5,151 | 0.08 ms | 433 ms | 0.11 ms | 579 ms | | `NodeManagerService.grpc_client.FreeLocalObjects` | 8,288 | 2.13 ms | 17,670 ms | — | — | | `NodeManagerService.grpc_client.FreeLocalObjects.OnReplyReceived` | 8,288 | 0.01 ms | 108 ms | 0.04 ms | 295 ms | The bulk of the work being a **1.74ms** call, and there does not seem to be any buildup on the queue. Furthermore, we can see the long polling time, which is the time the pubsub remains active for publishers is reduced drastically, because there is no need for an object eviction pubsub connection anymore. This execution time means a subscriber has less waiting between subscription vs. publish, which supports our claim that there is overall less pubsub contention / work happening actively. ``` CoreWorkerService.grpc_server.PubsubLongPolling - Execution time: mean = 113.22ms -> mean = 17.64ms ``` ### Driver + Worker Raylet Investigation #### Driver Raylet with FreeObjects <img width="1199" height="270" alt="image" src="https://github.com/user-attachments/assets/5435cb22-d0f1-42d0-88dc-a28bac6e7acb" /> Based on the above flamegraph, it is clear to see that the driver raylet has around **~200M** samples within FreeObjects related work, which is just completely absent in the new driver raylet. Furthermore, based on driver raylet logs, queueing time on average has decreased from **5.7ms** -> **2.7 ms**. #### Driver + Worker Raylet RPC Counts | Operation | old_driver_rl | new_driver_rl | old_worker_rl | new_worker_rl | |---|---|---|---|---| | `NodeManagerService.grpc_server.FreeLocalObjects.HandleRequestImpl` | 0 | 0 | 0 | 809 | | `ObjectManagerService.grpc_server.FreeObjects.HandleRequestImpl` | 1,428 | 0 | 1,289 | 0 | | `ObjectManagerService.grpc_client.FreeObjects.OnReplyReceived` | 50 | 0 | 1,440 | 0 | Here is a following table of the comparisons between old driver / worker raylet vs. new driver / worker raylet RPC counts based on the logs. We can see that the amount of RPCs are reduced significantly. Originally, our driver raylet would send **50** FreeObjects (5 requests to the other 10 nodes) and the worker raylet would send **1440** FreeObjects (144 requests to the other 10 nodes). Both the driver and worker each receive what the other raylets broadcast, leading to a total of **~1400 RPCs** each! In the new implementation, all driver raylet side load is moved to the driver side now since the driver raylet is no longer responsible for freeing objects. Furthermore, the worker raylet side is reduced as well because it does not have to deal with all broadcasts, and it is no longer responsible for freeing objects either. ### Conclusion There is undoubtedly some regression on the **worker_io** context. However, the extra load seems to be somewhat alleviated by getting rid of the current pubsub system. Furthermore, we achieve a big win on the raylets across the cluster. Hence, the drawbacks on the **worker_io** context are outweighed by 1) less raylet contention, 2) better observability since less FreeObjects RPC counts, and 3) better mental model of ownership. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]> Co-authored-by: Aaron <[email protected]> Signed-off-by: elliot-barn <[email protected]>
test_free_objects_idempotent injected RPC failures on ObjectManagerService.FreeObjects, which was removed in ray-project#63181 (FreeObjects 2/n) and replaced by owner-driven NodeManagerService.FreeLocalObjects. The injection has matched no live call since, so the test freed objects with no failure injected -- green but not exercising fault tolerance. Retarget the injection to NodeManagerService.FreeLocalObjects and rename the test, restoring retry/idempotency coverage. Mirrors the passing test_request_worker_lease_idempotent pattern. AI assistance (Claude) was used. Not run locally (installed wheel predates source); relies on CI. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: yuanzhuoyang <[email protected]>
## Description test_free_objects_idempotent injected RPC failures on ObjectManagerService.FreeObjects, which was removed in #63181 (FreeObjects 2/n) and replaced by owner-driven NodeManagerService.FreeLocalObjects. The injection has matched no live call since, so the test freed objects with no failure injected. Retarget the injection to NodeManagerService.FreeLocalObjects and rename the test, restoring retry/idempotency coverage. Signed-off-by: yuanzhuoyang <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
… free mechanism (ray-project#63218) ## Motivation Within this multi-step PR process, our goal is to change our current **FreeObjects** implementation to an owner driven process. Current design of FreeObjects involves spraying the entire cluster with FreeObjects RPCs. This introduces many caveats: bloating observability with FreeObjects RPC counts, sending excessive RPCs, and worse mental model from owner-driven reference counting. This is a continuation from ray-project#63117. Due to the race condition detailed in the testing section of the PR, we decided to merge both changes for a complete PR. Our current design for **FreeObjects** involves the following steps: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner finds out, and sends a pubsub message (initialized when pinning the primary copy) to the primary copy raylet. 3. The primary copy raylet frees its primary copy, and then broadcasts free secondary copies to all nodes within the cluster. (This is batched and sent periodically). The reason the primary copy raylet needs to broadcast secondary copies is because it doesn't store object locations for its primary copy, this is only stored on the owner. Thus, in order to ensure all secondary copies are freed, there is a need to broadcast to all nodes. ## Design As noted above, the owner stores the locations of all copies of the objects, where `pinned_at_node_id_` represents the primary copy location and the `locations` vector demonstrates all secondary object locations. We now move towards a new design **FreeObjects**. We will get rid of the pubsub between owner -> primary copy raylet. Instead: 1. The reference goes out of scope. The reference here represents both the owner's python references, as well as other borrower references throughout the cluster, which is tracked through the owner reference. 2. The owner sends RPCs to primary and secondary copy holders to free their objects. (Since it has all of its locations) However, this doesn't easily solve our issue since the pubsub also has an `owner_dead_callback`, which fires when the owner has died. This will help clean up the primary object and ensure there are no memory leaks in this case. To continue supporting this functionality, if the owner dies, this information is propagated by the GCS, and thus each raylet just listens to the GCS events and updates their states accordingly. Originally, the design was that: - the pubsub connection fails / ends for some unexpected reason - the owner is thought to be dead, so the primary copy raylet then frees its primary copy and queues up **FreeObjects** to broadcast to all secondary copies The new design: - The GCS already publishes WorkerFailure and NodeRemoved announcements to all raylets. This is so that raylets know to release worker leases of dead nodes / workers - With this new design, the raylets will listen and additionally clear any objects that had their owner on the failed worker / node - Something to consider is how exactly GCS gets these notifications, and if there would be any slowness in these notifications. 1.) When the worker process dies (but the node remains alive), the raylet picks up the worker death relatively quickly via the broken IPC connection and sends the worker death up to the GCS, and GCS broadcasts it. 2.) On node death, similar story. However, in old implementation, the long poll connection would be sitting the retryable grpc client queue waiting for either the connection to come back up or the GCS to get a worker death notification. Hence all in all, there really shouldn't be a significant change in behavior. ## Description This PR covers the first and second part of the **FreeObjects** change. The first part is strictly adding functionality for the owner to be in charge of freeing objects. We make the first step away from this design such that the owner calls a new **FreeLocalObjects** RPC to all primary and secondary copy locations when **OnObjectsOutOfScopeOrFreed**. The second part amends the functionality of the current owner dead pubsub callback to be moved from an eager pubsub death callback to a more passive listener callback. ## Considerations ### NodeManager RPC vs. ObjectManager RPC For this PR, I considered either 1) Adding a new RPC to **NodeManager** or 2) Adding new route that calls into existing **ObjectManager** FreeObjects. Ultimately, I decided to go with 1). A design consideration here is that workers currently only call into raylets' **NodeManager**, so part of this is to keep with existing implementation. Another reason is that our new **HandleFreeLocalObjects** would be responsible for 2 things: 1) if primary copy, delete metadata from **LocalObjectManager** (manages spilled and primary copies) and 2) if any copy, queue up within **FreeObjects**. Thus, **NodeManager** currently has functionality that calls into **LocalObjectManager**. Furthermore, I find that directly interfacing with **ObjectManager** is not as intuitive, and creating a new path just for **ObjectManager** does not seem ideal. ### Moving Around ReferenceCounter Variables For this PR, I decided to follow similar formats in the codebase, and have all the lambdas within the constructor shifted to the end. In this case, they can be considered optional arguments and can be defaulted to null if not specified. This leads to easier testing implementations. A tricky part is to ensure these functions generate no-op if they are not specified. ### Only Owner Frees An important consideration is that now that we are sending from the worker side, only if the object is freed is owned by the current worker should the worker send RPC requests to the object locations. Otherwise, the worker should just keep quiet. ### Dead Code Deleted in Future For this PR, I kept **FreeObjects**'s `local_only=false` case still alive, even though this case is essentially never called again. In the future, I will delete this dead code. ### Testing Changes and ReferenceCounter Changes For this PR, there were many testing changes that are needed because of this new path that is different from the first one. For now, many of these tests are just hardcoded to match correct behavior, but in the future some unnecessary tests might be deleted or shuffled around to match the new implementation. ### Pass Over All Objects This new design introduces a pass over all objects within the current node every announcement. However, failed nodes and worker announcements should not be too common and if the object is not owned by the failed worker / node it would be a no-op; thus this should not lead to any latency issues. ### Owner is Less Eager This new design will be a less eager free, especially for the primary copy of the node. This is definitely an important part to consider, however since it is similar a pubsub for node information, the latency should not be that big of a deal. Furthermore, the pubsub interface already keeps track of network failures etc. to some extent, and if there are further failures / GCS failures there are probably worse problems to deal with. ### LocalObjectManager local_objects_ vs. ObjectManager local_objects_ An important distinction is needed between both classes' local objects, where we need to aggregate and free any objects within both classes. LocalObjectManager in this case keeps track of primary copies as well as spilled copies. ObjectManager keeps track of anything in plasma such as primary copies / secondary copies. Thus, we need to get the union of both objects to get the objects that we want to free. ## Testing Ran python tests and C++ tests adjacent to these changes to ensure no regressions. Future e2e testing in ray-project#63181 We will fix this race condition in the immediate next PR, which uses the GCS to broadcast deaths and have the raylets free accordingly. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]> Signed-off-by: 400Ping <[email protected]>
… ObjectEviction pubsub (ray-project#63181) ## Description The first two parts of this feature demonstrated removing the dependency of the pubsub as well as the **FreeObjects** spray, and thus many original implementations are also necessary to be gutted. In this PR, we will target removing the 1) original FreeObjects RPC and the `local_only=false` branch and also 2) completely remove and get rid of the **ObjectEviction** pubsub. Now, the new **FreeObjects** design completely depends on the new design that we have. For 1): Essentially, we will remove these parts: - We no longer need the `FreeObjects` RPC that was broadcasted to all nodes, so we can delete this and any code relating this (tests, proto, etc.) - We no longer need `local_only=false` option (broadcasted `FreeObjects` RPC), so we can delete any logic relating to this as well. For 2): We will remove: - There is no longer a pubsub for object eviction which is removed When an object has no more references, we will now: Send **FreeLocalObject** RPCs to every raylet that we know has either a primary or secondary copy. If an owner has died, whether its worker process fails or node dies, then this will be broadcasted through the GCS. Any raylets that receive this notification will delete any copies they hold of the owner's objects accordingly. ## Considerations ### Test Changes There were some tests that relied on this RPC call to just test pubsub correctedness, I changed the channel to use a different one instead. There were also old tests that tested the pubsub as part of an e2e test for making sure an object becomes freed. I decided to remove the pubsub checks, but keep the overall test to ensure there is still the same functionality. ## Testing ### Initial Benchmarking Now that all parts of **FreeObjects** has been written, I decided to dive into benchmarking to ensure there are no regressions. I ran two of the following data release tests, each freeing thousands of objects: - [gpu_batch_inference.py](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/dataset/gpu_batch_inference.py) - [ray_data_main.py](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/multimodal_inference_benchmarks/audio_transcription/ray_data_main.py) These were ran with the following [benchmark](https://github.com/ray-project/ray/blob/1af4d5b34aad90e330c15c26c66d917104e0c5aa/release/nightly_tests/dataset/benchmark.py). Both tests on high level demonstrated no regression in throughput or overall latency. However, digging more into the perf graphs revealed a caveat. **FreeObjects** itself, although called a lot, is not necessarily a big part of the data-intensive workloads themselves. Thus, this requires still more investigation into the driver io_context for us to be sure there are no regressions there. Another investigation that is required is that whether this improves raylet RPC contention and overall raylet io context latency as we claim. ### Driver io_context Investigation #### Driver io_context with FreeObjects <img width="1199" height="348" alt="image" src="https://github.com/user-attachments/assets/615b19be-d285-463c-b601-ae583b46d731" /> #### New driver io_context <img width="1192" height="391" alt="image" src="https://github.com/user-attachments/assets/4c2c592c-4d17-498d-a405-8a1e7d40a612" /> #### Extra FreeLocalObjects Work But Pubsub Dropped Both driver_io context perfs are ran on the driver for the **gpu_batch_inference.py** data benchmark. The second image represents the current branch's changes, with **FreeLocalObjects** highlighted in pink within the **worker_io_context**. The highlighted part accounts for roughly **~500,000,000** samples. However, the overall **worker_io** samples only increased by **30,000,000** samples, partly because pubsub decreased by **~350,000,000** samples as well. This is because there is no need for **ObjectEviction** pubsubs to be fired anymore, which seems to result in less contention and less strain on the pubsub grpc, which allows less CPU wall time on pubsub in general. Based on ray logs, we can support this claim further. For **FreeLocalObjects**: | Counter | Count | Exec mean | Exec total | Queueing mean | Queueing total | |---|---:|---:|---:|---:|---:| | `CoreWorker.SpreadFreeLocalObjects` | 5,151 | 0.08 ms | 433 ms | 0.11 ms | 579 ms | | `NodeManagerService.grpc_client.FreeLocalObjects` | 8,288 | 2.13 ms | 17,670 ms | — | — | | `NodeManagerService.grpc_client.FreeLocalObjects.OnReplyReceived` | 8,288 | 0.01 ms | 108 ms | 0.04 ms | 295 ms | The bulk of the work being a **1.74ms** call, and there does not seem to be any buildup on the queue. Furthermore, we can see the long polling time, which is the time the pubsub remains active for publishers is reduced drastically, because there is no need for an object eviction pubsub connection anymore. This execution time means a subscriber has less waiting between subscription vs. publish, which supports our claim that there is overall less pubsub contention / work happening actively. ``` CoreWorkerService.grpc_server.PubsubLongPolling - Execution time: mean = 113.22ms -> mean = 17.64ms ``` ### Driver + Worker Raylet Investigation #### Driver Raylet with FreeObjects <img width="1199" height="270" alt="image" src="https://github.com/user-attachments/assets/5435cb22-d0f1-42d0-88dc-a28bac6e7acb" /> Based on the above flamegraph, it is clear to see that the driver raylet has around **~200M** samples within FreeObjects related work, which is just completely absent in the new driver raylet. Furthermore, based on driver raylet logs, queueing time on average has decreased from **5.7ms** -> **2.7 ms**. #### Driver + Worker Raylet RPC Counts | Operation | old_driver_rl | new_driver_rl | old_worker_rl | new_worker_rl | |---|---|---|---|---| | `NodeManagerService.grpc_server.FreeLocalObjects.HandleRequestImpl` | 0 | 0 | 0 | 809 | | `ObjectManagerService.grpc_server.FreeObjects.HandleRequestImpl` | 1,428 | 0 | 1,289 | 0 | | `ObjectManagerService.grpc_client.FreeObjects.OnReplyReceived` | 50 | 0 | 1,440 | 0 | Here is a following table of the comparisons between old driver / worker raylet vs. new driver / worker raylet RPC counts based on the logs. We can see that the amount of RPCs are reduced significantly. Originally, our driver raylet would send **50** FreeObjects (5 requests to the other 10 nodes) and the worker raylet would send **1440** FreeObjects (144 requests to the other 10 nodes). Both the driver and worker each receive what the other raylets broadcast, leading to a total of **~1400 RPCs** each! In the new implementation, all driver raylet side load is moved to the driver side now since the driver raylet is no longer responsible for freeing objects. Furthermore, the worker raylet side is reduced as well because it does not have to deal with all broadcasts, and it is no longer responsible for freeing objects either. ### Conclusion There is undoubtedly some regression on the **worker_io** context. However, the extra load seems to be somewhat alleviated by getting rid of the current pubsub system. Furthermore, we achieve a big win on the raylets across the cluster. Hence, the drawbacks on the **worker_io** context are outweighed by 1) less raylet contention, 2) better observability since less FreeObjects RPC counts, and 3) better mental model of ownership. --------- Signed-off-by: aaron.li <[email protected]> Signed-off-by: aaronscalene <[email protected]> Co-authored-by: Aaron <[email protected]> Signed-off-by: 400Ping <[email protected]>
…ect#64979) ## Description test_free_objects_idempotent injected RPC failures on ObjectManagerService.FreeObjects, which was removed in ray-project#63181 (FreeObjects 2/n) and replaced by owner-driven NodeManagerService.FreeLocalObjects. The injection has matched no live call since, so the test freed objects with no failure injected. Retarget the injection to NodeManagerService.FreeLocalObjects and rename the test, restoring retry/idempotency coverage. Signed-off-by: yuanzhuoyang <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: 400Ping <[email protected]>
## Description In 2.56 [raylet subscribed to object owners](https://github.com/ray-project/ray/pull/63181/changes#diff-52339e7cd2a22cd1c21b1973ba599995827a4b12fdc42fd06c5709836acd767eL3805) to listen to when the objects should be evicted. However, #63181 removed this system in favor of sending free object requests to specifically the nodes that hold them instead of broadcasting to all nodes. This change has caused a regression in the following code snippet: ```py @ray.remote( num_cpus=1, _generator_backpressure_num_objects=1, ) def gen(): for i in range(5): yield np.ones(10**7, dtype=np.uint8) * i gen_ref = gen.remote() del gen_ref # the back-pressured objects will remain with the worker that created # even though the generator has been deleted and the object will be accessible ``` In the snippet above, when the streaming generator gets deleted, the items that are back pressured will be produced anyways to ensure the task runs to completion properly. For version 2.56 and before, [these lines](https://github.com/ray-project/ray/pull/63181/changes#diff-52339e7cd2a22cd1c21b1973ba599995827a4b12fdc42fd06c5709836acd767eL3851-L3856) are responsible for garbage collecting the back-pressured items that got created anyways. However, after the targeted free object change. The mechanism is removed, and reported unconsumed objects sticks around even if their generator ref is deleted, leaking the objects in object store. This PR handles this case by checking if we've received an unconsumed object after generator ref has already gone out of scope. If such objects were received, we would instead free them immediately, avoiding the object leak. ## Related issues Fixes leaking generator object that are reported after generator ref goes out of scope. Introduced in #63181. ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
…ject#65276) ## Description In 2.56 [raylet subscribed to object owners](https://github.com/ray-project/ray/pull/63181/changes#diff-52339e7cd2a22cd1c21b1973ba599995827a4b12fdc42fd06c5709836acd767eL3805) to listen to when the objects should be evicted. However, ray-project#63181 removed this system in favor of sending free object requests to specifically the nodes that hold them instead of broadcasting to all nodes. This change has caused a regression in the following code snippet: ```py @ray.remote( num_cpus=1, _generator_backpressure_num_objects=1, ) def gen(): for i in range(5): yield np.ones(10**7, dtype=np.uint8) * i gen_ref = gen.remote() del gen_ref # the back-pressured objects will remain with the worker that created # even though the generator has been deleted and the object will be accessible ``` In the snippet above, when the streaming generator gets deleted, the items that are back pressured will be produced anyways to ensure the task runs to completion properly. For version 2.56 and before, [these lines](https://github.com/ray-project/ray/pull/63181/changes#diff-52339e7cd2a22cd1c21b1973ba599995827a4b12fdc42fd06c5709836acd767eL3851-L3856) are responsible for garbage collecting the back-pressured items that got created anyways. However, after the targeted free object change. The mechanism is removed, and reported unconsumed objects sticks around even if their generator ref is deleted, leaking the objects in object store. This PR handles this case by checking if we've received an unconsumed object after generator ref has already gone out of scope. If such objects were received, we would instead free them immediately, avoiding the object leak. ## Related issues Fixes leaking generator object that are reported after generator ref goes out of scope. Introduced in ray-project#63181. ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>


Description
The first two parts of this feature demonstrated removing the dependency of the pubsub as well as the FreeObjects spray, and thus many original implementations are also necessary to be gutted. In this PR, we will target removing the 1) original FreeObjects RPC and the
local_only=falsebranch and also 2) completely remove and get rid of the ObjectEviction pubsub. Now, the new FreeObjects design completely depends on the new design that we have.For 1):
Essentially, we will remove these parts:
FreeObjectsRPC that was broadcasted to all nodes, so we can delete this and any code relating this (tests, proto, etc.)local_only=falseoption (broadcastedFreeObjectsRPC), so we can delete any logic relating to this as well.For 2):
We will remove:
When an object has no more references, we will now: Send FreeLocalObject RPCs to every raylet that we know has either a primary or secondary copy.
If an owner has died, whether its worker process fails or node dies, then this will be broadcasted through the GCS. Any raylets that receive this notification will delete any copies they hold of the owner's objects accordingly.
Considerations
Test Changes
There were some tests that relied on this RPC call to just test pubsub correctedness, I changed the channel to use a different one instead. There were also old tests that tested the pubsub as part of an e2e test for making sure an object becomes freed. I decided to remove the pubsub checks, but keep the overall test to ensure there is still the same functionality.
Testing
Initial Benchmarking
Now that all parts of FreeObjects has been written, I decided to dive into benchmarking to ensure there are no regressions. I ran two of the following data release tests, each freeing thousands of objects:
These were ran with the following benchmark.
Both tests on high level demonstrated no regression in throughput or overall latency. However, digging more into the perf graphs revealed a caveat. FreeObjects itself, although called a lot, is not necessarily a big part of the data-intensive workloads themselves. Thus, this requires still more investigation into the driver io_context for us to be sure there are no regressions there.
Another investigation that is required is that whether this improves raylet RPC contention and overall raylet io context latency as we claim.
Driver io_context Investigation
Driver io_context with FreeObjects
New driver io_context
Extra FreeLocalObjects Work But Pubsub Dropped
Both driver_io context perfs are ran on the driver for the gpu_batch_inference.py data benchmark. The second image represents the current branch's changes, with FreeLocalObjects highlighted in pink within the worker_io_context. The highlighted part accounts for roughly ~500,000,000 samples. However, the overall worker_io samples only increased by 30,000,000 samples, partly because pubsub decreased by ~350,000,000 samples as well. This is because there is no need for ObjectEviction pubsubs to be fired anymore, which seems to result in less contention and less strain on the pubsub grpc, which allows less CPU wall time on pubsub in general.
Based on ray logs, we can support this claim further. For FreeLocalObjects:
CoreWorker.SpreadFreeLocalObjectsNodeManagerService.grpc_client.FreeLocalObjectsNodeManagerService.grpc_client.FreeLocalObjects.OnReplyReceivedThe bulk of the work being a 1.74ms call, and there does not seem to be any buildup on the queue.
Furthermore, we can see the long polling time, which is the time the pubsub remains active for publishers is reduced drastically, because there is no need for an object eviction pubsub connection anymore. This execution time means a subscriber has less waiting between subscription vs. publish, which supports our claim that there is overall less pubsub contention / work happening actively.
Driver + Worker Raylet Investigation
Driver Raylet with FreeObjects
Based on the above flamegraph, it is clear to see that the driver raylet has around ~200M samples within FreeObjects related work, which is just completely absent in the new driver raylet. Furthermore, based on driver raylet logs, queueing time on average has decreased from 5.7ms -> 2.7 ms.
Driver + Worker Raylet RPC Counts
NodeManagerService.grpc_server.FreeLocalObjects.HandleRequestImplObjectManagerService.grpc_server.FreeObjects.HandleRequestImplObjectManagerService.grpc_client.FreeObjects.OnReplyReceivedHere is a following table of the comparisons between old driver / worker raylet vs. new driver / worker raylet RPC counts based on the logs. We can see that the amount of RPCs are reduced significantly. Originally, our driver raylet would send 50 FreeObjects (5 requests to the other 10 nodes) and the worker raylet would send 1440 FreeObjects (144 requests to the other 10 nodes). Both the driver and worker each receive what the other raylets broadcast, leading to a total of ~1400 RPCs each!
In the new implementation, all driver raylet side load is moved to the driver side now since the driver raylet is no longer responsible for freeing objects. Furthermore, the worker raylet side is reduced as well because it does not have to deal with all broadcasts, and it is no longer responsible for freeing objects either.
Conclusion
There is undoubtedly some regression on the worker_io context. However, the extra load seems to be somewhat alleviated by getting rid of the current pubsub system. Furthermore, we achieve a big win on the raylets across the cluster. Hence, the drawbacks on the worker_io context are outweighed by 1) less raylet contention, 2) better observability since less FreeObjects RPC counts, and 3) better mental model of ownership.