-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUM-6093:Add TimeBank in session replay recorder for dynamic optimisation #2247
RUM-6093:Add TimeBank in session replay recorder for dynamic optimisation #2247
Conversation
...ssion-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/TimeBank.kt
Outdated
Show resolved
Hide resolved
...sion-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/Debouncer.kt
Outdated
Show resolved
Hide resolved
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
if (timePassedSinceLastExecution >= maxRecordDelayInNs) { | ||
executeRunnable(runnable) | ||
} else { | ||
handler.postDelayed({ executeRunnable(runnable) }, DEBOUNCE_TIME_IN_MS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
Shouldn't you remove previously posted runnables, if there are multiple debounced executions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is done above at line 33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, so I changed the place where runInTimeBalance
should wrap up.
Now runInTimeBalance
wrap only the function of executeRunnable
, so we check first the condition of debounce frequency, then check if it meets the time balance.
...sion-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/Debouncer.kt
Outdated
Show resolved
Hide resolved
if (timePassedSinceLastExecution >= maxRecordDelayInNs) { | ||
executeRunnable(runnable) | ||
} else { | ||
handler.postDelayed({ executeRunnable(runnable) }, DEBOUNCE_TIME_IN_MS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is done above at line 33
ff54810
to
fe0410a
Compare
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
8d854e7
to
705fa22
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/sr-dynamic-optimisation #2247 +/- ##
===================================================================
- Coverage 70.12% 69.99% -0.13%
===================================================================
Files 727 728 +1
Lines 27062 27077 +15
Branches 4560 4561 +1
===================================================================
- Hits 18975 18951 -24
- Misses 6827 6842 +15
- Partials 1260 1284 +24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, I added some suggestions
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
...lay/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/RecordingTimeBank.kt
Outdated
Show resolved
Hide resolved
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Outdated
Show resolved
Hide resolved
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Outdated
Show resolved
Hide resolved
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Outdated
Show resolved
Hide resolved
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Show resolved
Hide resolved
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Outdated
Show resolved
Hide resolved
fun `M allow everything W set max balance to 1000ms per sec`(forge: Forge) { | ||
recordingTimeBank = RecordingTimeBank(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it is more than 1s? shouldn't we cover this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I updated the test to M allow everything W set max balance more than 1000ms per sec
with a random value with 1000ms as min value.
...n-replay/src/test/kotlin/com/datadog/android/sessionreplay/recorder/RecordingTimeBankTest.kt
Show resolved
Hide resolved
86dac33
705fa22
to
86dac33
Compare
What does this PR do?
Add TimeBank in session replay recorder for dynamic optimisation.
The main idea is to have a time balance in this
TimeBank
, every execution of session replay recording will consume this balance, and the balance will be recharged during the time passing until a maximum balance is reached.Before every execution of recording, if the balance is negative, the execution will skipped until the balance is recharged to positive.
Motivation
RUM-6093
Review checklist (to be filled by reviewers)