-
Notifications
You must be signed in to change notification settings - Fork 142
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
Introducing new max for foreground periods #1032
Introducing new max for foreground periods #1032
Conversation
9244fe8
to
4b87a41
Compare
Codecov Report
@@ Coverage Diff @@
## main #1032 +/- ##
=======================================
Coverage 88.93% 88.94%
=======================================
Files 88 88
Lines 4168 4170 +2
Branches 959 959
=======================================
+ Hits 3707 3709 +2
Misses 461 461
Continue to review full report at Codecov.
|
// Arbitrary value to cap number of element mostly for backend & to save bandwidth | ||
export const MAX_NUMBER_OF_FOCUSED_TIME_PER_VIEW = 500 | ||
// Arbitrary value to cap number of element mostly for memory consumption in the browser | ||
export const MAX_NUMBER_OF_FOCUSED_TIME = 2500 |
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.
Do we need to keep and increase MAX_NUMBER_OF_FOCUSED_TIME
?
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.
The idea is to have two limits serving two different purposes:
MAX_NUMBER_OF_FOCUSED_TIME
is here to limit the memory usage. It can be fairly large as objects are small.MAX_NUMBER_OF_FOCUSED_TIME_PER_VIEW
is here to limit the bandwidth usage. We keep the same limit as before (500) as it should be enough.
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.
Agreed. Most of the views have less than 500 focused periods therefore the array is full because of SPA changes. We can drastically reduce the number of errors while keeping the same limit for the bandwidth.
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.
IIUC:
MAX_NUMBER_OF_FOCUSED_TIME
is the max number of foreground periods storedMAX_NUMBER_OF_FOCUSED_TIME_PER_VIEW
is the max number of foreground periods than can be returned bygetInForegroundPeriods
.
if that so, we could probably clarify the namings:
- using "view" in the constant is "leaking" information about the current consumer which we don't need to know here
- I am confused by "focused time" vs "foreground period", is there a difference?
- we could maybe be more expressive than
get
forgetInForeground
andgetInForegroundPeriods
and use the same verb forgetInForegroundPeriods
and the related constant.
Given that, I would have in mind something like:
const MAX_NUMBER_OF_SELECTABLE_FOREGROUND_PERIODS = 500
const MAX_NUMBER_OF_STORED_FOREGROUND_PERIODS = 2500
isInForegroundAt: (startTime: RelativeTime) => boolean | undefined
selectInForegroundPeriodsFor: (startTime: RelativeTime, duration: Duration) => InForegroundPeriod[] | undefined
wdyt?
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.
Agreed, the naming you're proposing is better than the current one
Co-authored-by: Benoît <[email protected]>
…number-of-foreground-periods
4a1804a
to
8d3a0d0
Compare
…number-of-foreground-periods
d3aa79d
to
94266f1
Compare
…number-of-foreground-periods
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
Motivation
We have quite a log of
Reached maximum of foreground time
errors but the views do not have 500 items.Changes
Let's split the max in two:
Testing
It's unit tested