Repository navigation
[core] Update Raylet timing-related logic to use ClockInterface - #62562
Conversation
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors time-related logic across the Raylet and common components to use a unified ClockInterface. Key changes include updating constructors for NodeManager, LocalObjectManager, Worker, and Throttler to accept a clock reference, and replacing various calls to current_time_ms or std::chrono with ClockInterface methods. This refactoring improves testability by allowing the use of FakeClock in unit tests. Review feedback highlighted concerns regarding the loss of monotonicity in certain duration calculations and GC triggers, suggesting the use of absl::Duration and absl::Time to prevent issues during system clock adjustments.
| const bool local_gc_trigger = | ||
| absl::GetCurrentTimeNanos() - local_gc_throttler_.LastRunTime() > | ||
| local_gc_interval_ns_; | ||
| clock_.NowUnixNanos() - local_gc_throttler_.LastRunTime() > local_gc_interval_ns_; |
There was a problem hiding this comment.
This manual interval check is susceptible to system clock jumps because clock_.NowUnixNanos() is not monotonic. If the system clock is adjusted backwards, the subtraction will result in a large value (due to unsigned promotion if local_gc_interval_ns_ is unsigned), triggering GC prematurely. Since Throttler already handles the interval check internally, consider relying on it or using absl::Time and absl::Duration for a more robust check.
| int64_t duration_ms = | ||
| absl::ToInt64Milliseconds(clock_.Now() - entry.second.creation_time_); | ||
| if (duration_ms > RayConfig::instance().task_failure_entry_ttl_ms()) { |
There was a problem hiding this comment.
The switch from std::chrono::steady_clock to clock_.Now() means the duration calculation is no longer monotonic. If the system clock is adjusted backwards, duration_ms could be negative. When compared against a TTL value, this could lead to unexpected behavior if the comparison involves unsigned types (e.g., if the config value is promoted to unsigned). Comparing absl::Duration directly is more robust and readable.
if (clock_.Now() - entry.second.creation_time_ > absl::Milliseconds(RayConfig::instance().task_failure_entry_ttl_ms())) {Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[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. |
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
833480d to
0c6526d
Compare
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 3b19df7. Configure here.
Signed-off-by: Edward Oakes <[email protected]>
| /// The time that we last sent a FreeObjects request to other nodes for | ||
| /// objects that have gone out of scope in the application. | ||
| uint64_t last_free_objects_at_ms_ = 0; |
There was a problem hiding this comment.
This field was not used anywhere, so removed
…y-project#62562) - Update Raylet subcomponents to use the interface introduced in: ray-project#62476 - Updated tests to use FakeClock --------- Signed-off-by: Edward Oakes <[email protected]>
…y-project#62562) - Update Raylet subcomponents to use the interface introduced in: ray-project#62476 - Updated tests to use FakeClock --------- Signed-off-by: Edward Oakes <[email protected]>
…y-project#62562) - Update Raylet subcomponents to use the interface introduced in: ray-project#62476 - Updated tests to use FakeClock --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: 400Ping <[email protected]>

ClockInterfaceand fake clock for testing #62476