-
Notifications
You must be signed in to change notification settings - Fork 356
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
fix: prevent extra initial calls to search endpoints #9782
Conversation
this fixes an issue where the new table experience tables would call their search endpoints multiple times on mount, possibly causing server load issues. This happened due to two root causes: 1) the comparison view would call the search endpoint for user selections even when the comparison view was closed and the user had selected no experiments or runs. we now bail on the request if the comparison view is closed or the selection is empty. This may impact the user because now the comparison view will update on open instead of in the background, but I think this is a fair tradeoff. 2) the sort state updated as an effect of loading the settings, so the polling function would initially fire when the settings loaded, then again when the sort state updated. We now derive the sort state directly from the sort string instead.
✅ Deploy Preview for determined-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9782 +/- ##
==========================================
- Coverage 54.05% 49.73% -4.32%
==========================================
Files 1260 937 -323
Lines 155545 126227 -29318
Branches 3503 3508 +5
==========================================
- Hits 84074 62783 -21291
+ Misses 71325 63298 -8027
Partials 146 146
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@EmilyBonar could you also review this since i think you are more familiar with the code |
i tested it against gcloud server, and see multiple run apis. that's not what we expect, right? Screen.Recording.2024-08-01.at.2.55.43.PM.mov |
with the comparison view open i'd expect to see two -- one for the main list and one for the selection for comparison view. i also noticed an issue where users aren't able to add new sorts. looking into these now. |
@@ -31,7 +31,7 @@ export function useDebouncedSettings<T extends t.HasProps | t.ExactC<t.HasProps> | |||
const settingsObs = useMemo(() => userSettings.get(type, path), [type, path]); | |||
const [localState, updateLocalState] = useState<Loadable<T | null>>(NotLoaded); | |||
|
|||
useEffect(() => { | |||
useLayoutEffect(() => { |
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.
saw issues where we were still seeing two requests to the search endpoint because settings was loaded but column widths were not. useObservable
subscribes to the observable in useLayoutEffect
instead of useEffect
, so we do that here to ensure all the subscriptions fire at the same 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.
Looks good, can confirm that I'm not seeing the repeated initial calls in the network tab!
if (response?.pagination?.total && response?.pagination?.total > SELECTION_LIMIT) { | ||
setIsSelectionLimitReached(true); | ||
} else { | ||
setIsSelectionLimitReached(false); |
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.
nit: could be reduced to setIsSelectionLimitReached(response?.pagination?.total && response?.pagination?.total > SELECTION_LIMIT);
if (response?.pagination?.total && response?.pagination?.total > SELECTION_LIMIT) { | ||
setIsSelectionLimitReached(true); | ||
} else { | ||
setIsSelectionLimitReached(false); |
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.
nit: same reduction
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [isLoadingSettings]); | ||
useLayoutEffect(() => { |
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.
sugg: we're doing this same pattern 3 times, could it be extracted out into a custom hook?
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.
i'm not sure if there's value in abstracting this pattern -- while we do handoff local/server state three times in this pr (and more when you factor in filterFormState + columnWidths), the knobs necessary to twist (observable, default value, state, etc.) mean that it'll either only be used in these three places or it'll be easier to just inline.
let cleanup: () => void; | ||
// eslint-disable-next-line prefer-const | ||
cleanup = eagerSubscribe(projectSettingsObs, (ps, prevPs) => { |
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.
q: what's the reason for declaring the variable separately from initializing it?
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.
ran into an issue where cleanup
wasn't defined in scope when the module was parsed. when we used this pattern for filterformstate, cleanup was defined and set at runtime, so i think it's just an odd issue. I'm going to take another look and see if it still makes sense.
(cherry picked from commit 9702d22)
Ticket
ET-677
Description
this fixes an issue where the new table experience tables would call their search endpoints multiple times on mount, possibly causing server load issues. This happened due to two root causes:
the comparison view would call the search endpoint for user selections even when the comparison view was closed and the user had selected no experiments or runs. we now bail on the request if the comparison view is closed or the selection is empty. This may impact the user because now the comparison view will update on open instead of in the background, but I think this is a fair tradeoff.
the sort state updated as an effect of loading the settings, so the polling function would initially fire when the settings loaded, then again when the sort state updated. We now
derive the sort state directly from the sort string insteaddirectly update the sort state when the settings load.Test Plan
Checklist
docs/release-notes/
See Release Note for details.