Skip to content

RUM-17182: Stablize MoveDataMigrationOperationTest under high CPU usage#3614

Merged
abrooksv merged 2 commits into
developfrom
abrooks/RUM-17182
Jul 9, 2026
Merged

RUM-17182: Stablize MoveDataMigrationOperationTest under high CPU usage#3614
abrooksv merged 2 commits into
developfrom
abrooks/RUM-17182

Conversation

@abrooksv

@abrooksv abrooksv commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Increase CPU time budget for when under high CPU load
  • Combine retryWithDelay overloads
  • Add a sleep into retryWithDelay to avoid spinning the CPU for the delay time

Motivation

Tests failed locally when ran through local_ci.sh

java.lang.AssertionError: 
Expecting actual:
  601L
to be between:
  [500L, 550L]

	at com.datadog.android.core.internal.persistence.file.advanced.MoveDataMigrationOperationTest.M retry with 500ms delay W run() {move fails once}(MoveDataMigrationOperationTest.kt:166)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)

Comment on lines +43 to +51
var lastAttemptEndNs = timeProvider.getDeviceElapsedTimeNanos()
while (attempt <= times) {
if (attempt > 1) {
val timeSinceLastAttemptNs = timeProvider.getDeviceElapsedTimeNanos() - lastAttemptEndNs
val timeToWaitNs = retryDelayNs - timeSinceLastAttemptNs
if (timeToWaitNs > 0) {
sleepSafe(TimeUnit.NANOSECONDS.toMillis(timeToWaitNs), internalLogger)
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

time provider is only really for testing and does complicate the code, is it worth removing?

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.

TimeProvider had a value for testing before because we weren't sleeping, so we could speed up the tests. With the new implementation (which I think is nice because we don't waste CPU), I guess what you are suggesting is basically removing all the timeToWait stuff and just sleeping for the whole delay.

I don't see much value from timeProvider now, so it makes sense to me to remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, 100% what I was suggesting and drew same conclusion as me

@abrooksv
abrooksv marked this pull request as ready for review July 7, 2026 16:58
@abrooksv
abrooksv requested review from a team as code owners July 7, 2026 16:58

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cb1a187c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@abrooksv
abrooksv force-pushed the abrooks/RUM-17182 branch 4 times, most recently from 583b2f6 to a1d3df9 Compare July 7, 2026 17:58

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1d3df92b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@abrooksv
abrooksv marked this pull request as draft July 7, 2026 18:04
* Increase CPU time budget for when under high CPU load
* Combine retryWithDelay overloads
* Add a sleep into retryWithDelay to avoid spinning the CPU for the delay time
@abrooksv
abrooksv force-pushed the abrooks/RUM-17182 branch from a1d3df9 to 6ddcc99 Compare July 7, 2026 18:08
@abrooksv
abrooksv marked this pull request as ready for review July 7, 2026 18:20
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.85%. Comparing base (ed5ce03) to head (6ddcc99).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3614      +/-   ##
===========================================
+ Coverage    72.80%   72.85%   +0.05%     
===========================================
  Files          975      975              
  Lines        35282    35271      -11     
  Branches      5973     5974       +1     
===========================================
+ Hits         25684    25694      +10     
+ Misses        7919     7906      -13     
+ Partials      1679     1671       -8     

see 44 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

hamorillo
hamorillo previously approved these changes Jul 8, 2026
Comment on lines +43 to +51
var lastAttemptEndNs = timeProvider.getDeviceElapsedTimeNanos()
while (attempt <= times) {
if (attempt > 1) {
val timeSinceLastAttemptNs = timeProvider.getDeviceElapsedTimeNanos() - lastAttemptEndNs
val timeToWaitNs = retryDelayNs - timeSinceLastAttemptNs
if (timeToWaitNs > 0) {
sleepSafe(TimeUnit.NANOSECONDS.toMillis(timeToWaitNs), internalLogger)
}
}

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.

TimeProvider had a value for testing before because we weren't sleeping, so we could speed up the tests. With the new implementation (which I think is nice because we don't waste CPU), I guess what you are suggesting is basically removing all the timeToWait stuff and just sleeping for the whole delay.

I don't see much value from timeProvider now, so it makes sense to me to remove it.

The TimeProvider does not offer much gain with the new retryWithDelay implementation that is not a spin-loop.
This also un-weaves TimeProvider from callers since they are no longer needed
@abrooksv
abrooksv merged commit 09d7b68 into develop Jul 9, 2026
27 checks passed
@abrooksv
abrooksv deleted the abrooks/RUM-17182 branch July 9, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants