perf(providers): Save the pool's feature list and use it at launch #38
Loading…
Reference in a new issue
No description provided.
Delete branch "perf/pool-features-disk"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was wrong
Every launch had to get a
pool_infoanswer within 3 seconds (POOL_CHECK_TIMEOUT_MS) before the app used the pool's features: retry, stop, sources, live game info (event_info) and the shorter guide (guide_window). When the pool was slow, during a rebuild pause or the first minute after a deploy, the app treated it as a plain panel for a minute and downloaded the full guide. The pool agent asked for this in its note; the two refinements below are mine.What changed
ProviderFileStore.ktis a new store for small per-provider files. Names are hashes of the provider id and of its URL and login, the same scheme as the channel list cache, so a name never reveals either. Saving replaces the provider's file from an earlier URL or login.ProviderRepository.ktsaves each realpool_infoanswer there. A launch uses the saved list at once and askspool_infoagain in the background; the answer replaces the saved list. A real answer is the pool's feature list, or empty for a plain panel (a 404, or an accepted login with no pool shape).Retry-After). With nothing saved, the first call still waits for the answer, as before.XtreamClient.kt: a refused login (HTTP 401 or 403, or a 200 withuser_info.auth0) is nowPoolCheck.refused. Before, it counted as "plain panel" for the whole run, so a rotated password would have turned the features off and saved an empty list.pool_infocheck runs at a time per provider, so a launch no longer sends two.forgetProvider(called on edit and delete) also deletes the saved list. The tests that build aProviderRepository(LiveNowEventsTest.kt,PoolFeaturesCacheTest.kt,EpgGuideWindowTest.kt) pass a memory-only store.Verified
testDebugUnitTest(639 tests),lintDebugandassembleDebugpass.PoolFeaturesSavedTest.kthas 10 cases: the saved list returned while the pool hasn't answered, a new answer replacing it, each failure keeping it and the minute's wait, plain-panel answers saving an empty list, a refused login with nothing saved, six callers at once sending one check, delete, a check ending after delete, file name and contents, and a new login replacing the old file.pool_infoas before and saved a 54-byte file holding only the five feature names. The next launches read it and checked in the background, with onepool_infoeach.pool_infoforced to time out (a 1 ms limit in a throwaway build of each, saved guide deleted first):maintreated the pool as plain and asked for the full guide. This branch used the saved list and asked forpast_hours=2&future_hours=15. The saved file was left unchanged.