Fix for slowdown caused by initialfetch#16969
Conversation
| await this.experimentationService.initialFetch; | ||
|
|
||
| const experiments = this.globalState.get<{ features: string[] }>(EXP_MEMENTO_KEY, { features: [] }); | ||
| if (experiments.features.length === 0) { |
There was a problem hiding this comment.
- Do we need to run
this.experimentationService.initialFetchin background in the other case, to ensure the cache is eventually populated? - When the fetch eventually completes, does that mean experiments are changed mid-session?
There was a problem hiding this comment.
Do we need to run this.experimentationService.initialFetch in background in the other case, to ensure the cache is eventually populated?
initialFetch is a promise, so it will be run in the background no matter what.
When the fetch eventually completes, does that mean experiments are changed mid-session?
Yes, this may happen.
There was a problem hiding this comment.
Yes, this may happen.
This seems unideal. In deprecated exp manager, we had a separate storage for experiments downloaded in background, and it was only used in the next session.
Seems like a feature request for the exp team.
There was a problem hiding this comment.
We have an interim solution. We could essentially read all the values at start up and use a in memory cache for the experiment values?
There was a problem hiding this comment.
As far as I can see, under the hood the package loads info from cache, but then doesn't update the in-memory data for this session unless the overrideInMemoryFeatures flag for getFeaturesAsync is set to true.
@karthiknadig Could you set a breakpoint in getFeaturesAsync (in node_modules/tas-client/tas-client/ExperimentationServiceBase.js) and see if it's ever called with overrideInMemoryFeatures set to true? If that's the case, we would probably use the solution you suggest. If not, we don't need to make extra changes.
There was a problem hiding this comment.
Might be worth adding a comment describing this behavior.
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

Closes #16959