> Fork some of the informer code to add filters, to reduce what objects are cached to only the ones cared about.
> Add an option to drop the field manager annotation which is huge and rarely needing to be read or modified by most controllers
> Add an option to just store metadata, for controllers that don’t need the spec or status cached
The client can supply a ListerWatcher that trims (or even transforms, consistently of course) the objects.
> Ensure objects are being dereferenced aggressively to minimize memory footprint outside of the informers
I am not sure what this one means. "dereference" usually means to follow a pointer. Perhaps the idea is something about removing unneeded pointers from somewhere?
> CRDs are sent over the wire as json
As noted, this is a big deal for other reasons too. It is a sufficiently big deal to discuss on its own.
2. Regarding memory costs of decoding.
Decoding requires holding two copies: the JSON or protobuf copy received, and the decoded copy. At some point after decoding is done, the received bytes become unreachable and thus subject to garbage collection. There are also helper objects created during decoding that become unreachable even before decoding returns. If you look carefully, garbage collection is somewhat squishy. One, slow and crude, kind of squishiness is the fact that the GC can be tuned through runtime configuration. For another, the behavior of the collector in the Go runtime is dependent on the combination of all the relevant mutator activity in that process. And even less obviously: when it releases memory, the Go runtime does _not_ actually itself decrease the memory usage of the process; instead it marks the released pages as ones that the operating system can ghost, and whether and when the OS does this is another can of worms. In short, YMMV.
Caching on disk does not remove the need to hold the relevant copies of an object in memory at once. Caching on disk would add more encoding and decoding.
Caching on disk would help in scenarios where the cache holds significantly more volume than the client needs to be reachable in memory at any given time.