Commit Graph

4 Commits

Author SHA1 Message Date
Richard Cox 12f6b38dee Changes following review
- update preferences layout
- disable interval by setting, rather than 0
- move out preference update logic to gc land
- ensure new interval time period picked up by always stopping interval
2022-10-10 17:08:43 +01:00
Richard Cox bdb9f7b9f7 Multiple changes
- Update text
- Add enabled settings for both types of gc initiator (interval and route change)
- Add sensible defaults
- Remove TODOs
2022-10-10 17:08:43 +01:00
Richard Cox 64dd1e9512 Refactor
- Don't cache gc state in store (avoids any chance of prompting change detection when update type accessed time)
- use TS instead of JS where possible
- split out two prompts into own file (on interval and on route change)
2022-10-10 17:08:43 +01:00
Richard Cox 694310352b Garbage Collect Stale Resources
Remove resources from the store if they meet certain criteria. This will reduce the memory footprint of the dashboard and load on the backend (less watchers for large collections)

- GC is disabled by default and can be enabled via the Global Settings --> Performance tab
  - User can configure
    - The age in milliseconds in which a resource has to exceed in order to be gc'd
    - The count which a resource has to exceed in order to be gc'd
- GC occures in stores that have it enabled
  - ATM this is just the `cluster` store... but could be enabled for dashboard-store's such as the harvester one (one liner plus optional `gcIgnoreTypes` override for ignoring types)
- GC will be kicked off in two cases
  - Route Change for a logged in state
  - At a given interval

- Resource type _not_ GC'd if
  - The store is ignoring the type
    - For example the `cluster` store doesn't want to gc things like `schema` and `count`
  - We're going to a page for that resource (list, detail, etc)
    - For example don't GC pods if we're going to a pods page
  - The last time the resource was accessed was recently
    - We store the resource accessed time via hooking into actions and getters
    - Setting the last accessed time will cause watchers of that type to trigger (only an issue for duplicate watchers)... but importantly not watchers of other types
  - The resource is being used in the current page/context
    - We store the route changed time and compare it to the resource accessed time
  - There's too few resources
    - We might as well keep them to avoid a network request to re-populate

// TODO:
- Should additional features be added to preferences
  - if GC on route change is enabled
  - if GC on interval is enabled, and how often it runs
- Sensible default preferences
- Remove some logging
2022-10-10 17:08:43 +01:00