Skip to content

[core] Add shared ClockInterface and fake clock for testing - #62476

Merged
edoakes merged 40 commits into
ray-project:masterfrom
edoakes:eoakes/fake-clock
Apr 10, 2026
Merged

edoakes merged 40 commits into
ray-project:masterfrom
edoakes:eoakes/fake-clock

Conversation

@edoakes

@edoakes edoakes commented Apr 9, 2026 •

Copy link
Copy Markdown
Collaborator

Wanted this for an upcoming PR for deterministic unit testing, so adding it here and replacing some existing tests that had their own version.

Was also able to make the timestamp checks in local_resource_manager_test.cc deterministic.

edoakes added 30 commits April 3, 2026 09:58
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]>
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]>
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]>
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]>
@edoakes
edoakes requested a review from a team as a code owner April 9, 2026 18:38
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Apr 9, 2026
Signed-off-by: Edward Oakes <[email protected]>

@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 introduces a new ClockInterface and its implementations (Clock and FakeClock) to standardize time retrieval across the codebase, replacing direct absl::Now() calls and manual time-tracking logic in tests. The changes include updating various scheduling components and tests to inject the clock interface. The review feedback suggests marking the Now() methods as const and declaring the Clock and FakeClock classes as final to improve API design and enable potential compiler optimizations.

Comment thread src/ray/util/clock.h Resolved
Comment thread src/ray/util/clock.h Resolved
Comment thread src/ray/util/clock.h Resolved
Comment thread src/ray/util/clock.h Resolved
Comment thread src/ray/util/clock.h Resolved
edoakes added 3 commits April 9, 2026 11:45
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Apr 9, 2026

@Yicheng-Lu-llll Yicheng-Lu-llll left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@edoakes
edoakes merged commit 262edcf into ray-project:master Apr 10, 2026
3 checks passed
HLDKNotFound pushed a commit to chichic21039/ray that referenced this pull request Apr 22, 2026
…oject#62476)

Wanted this for an upcoming PR for deterministic unit testing, so adding
it here and replacing some existing tests that had their own version.

Was also able to make the timestamp checks in
`local_resource_manager_test.cc` deterministic.

---------

Signed-off-by: Edward Oakes <[email protected]>
edoakes added a commit that referenced this pull request May 13, 2026
- Update gcs components to use the interface introduced in:
#62476
- Updated tests to use `FakeClock`
- Added additional convenience methods to `ClockInterface`

---------

Signed-off-by: Edward Oakes <[email protected]>
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…oject#62476)

Wanted this for an upcoming PR for deterministic unit testing, so adding
it here and replacing some existing tests that had their own version.

Was also able to make the timestamp checks in
`local_resource_manager_test.cc` deterministic.

---------

Signed-off-by: Edward Oakes <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
…roject#62502)

- Update gcs components to use the interface introduced in:
ray-project#62476
- Updated tests to use `FakeClock`
- Added additional convenience methods to `ClockInterface`

---------

Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
edoakes added a commit that referenced this pull request May 29, 2026
…2562)

- Update Raylet subcomponents to use the interface introduced in:
#62476
- Updated tests to use FakeClock

---------

Signed-off-by: Edward Oakes <[email protected]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants