Skip to content

[core] Update Raylet timing-related logic to use ClockInterface - #62562

Merged
edoakes merged 21 commits into
ray-project:masterfrom
edoakes:eoakes/raylet-clock
May 29, 2026
Merged

edoakes merged 21 commits into
ray-project:masterfrom
edoakes:eoakes/raylet-clock

Conversation

@edoakes

@edoakes edoakes commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

edoakes added 2 commits April 13, 2026 11:29
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Apr 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/ray/raylet/node_manager.cc Outdated
Comment on lines +2913 to +2914
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_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Comment thread src/ray/raylet/node_manager.cc Outdated
Comment on lines +3316 to +3318
int64_t duration_ms =
absl::ToInt64Milliseconds(clock_.Now() - entry.second.creation_time_);
if (duration_ms > RayConfig::instance().task_failure_entry_ttl_ms()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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())) {

@github-actions

Copy link
Copy Markdown

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 github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Apr 29, 2026
edoakes added 2 commits April 30, 2026 08:37
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@edoakes
edoakes marked this pull request as ready for review April 30, 2026 13:46
@edoakes
edoakes requested a review from a team as a code owner April 30, 2026 13:46
@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Apr 30, 2026
@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels May 1, 2026
Comment thread src/ray/raylet/node_manager.cc Resolved
edoakes added 3 commits May 7, 2026 13:46
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@edoakes
edoakes force-pushed the eoakes/raylet-clock branch from 833480d to 0c6526d Compare May 7, 2026 18:49
Comment thread src/ray/raylet/node_manager.cc Resolved
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 3b19df7. Configure here.

Comment thread src/ray/raylet/local_object_manager.cc Resolved
Signed-off-by: Edward Oakes <[email protected]>
Comment on lines -316 to -318
/// 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;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This field was not used anywhere, so removed

@edoakes
edoakes merged commit 44e7cb3 into ray-project:master May 29, 2026
3 checks passed
rueian pushed a commit to rueian/ray that referenced this pull request Jun 4, 2026
…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]>
limarkdcunha pushed a commit to limarkdcunha/ray that referenced this pull request Jun 30, 2026
…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]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants