ray icon indicating copy to clipboard operation
ray copied to clipboard

[core] (FreeObjects 2/n) Remove original FreeObjects RPC and original ObjectEviction pubsub

Open aaronscalene opened this issue 6 months ago • 2 comments

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:

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

image

New driver io_context

image

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

image

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.

aaronscalene avatar May 07 '26 04:05 aaronscalene

This pull request has been automatically marked as stale because it has not had any activity for 14 days. It will be closed in another 14 days if no further activity occurs. Thank you for your contributions.

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.

github-actions[bot] avatar Jun 24 '26 01:06 github-actions[bot]

unstale

aaronlinear avatar Jun 25 '26 01:06 aaronlinear