SakulFlee / Akimo-Project

Other
0 stars 0 forks source link

Cache access timer + cleanup after treshold #156

Closed SakulFlee closed 1 month ago

SakulFlee commented 1 month ago

Currently, once something gets cached, in e.g. the Pipeline/Shader cache, it remains there basically forever until the application exits. There is no way of removing something from the cache at this moment, nor does it ever clean itself up.

The idea here would be to add a timer to each entry in the cache. Something very minimal and cheap, like an Instant.

Each time the cache hits, this timer should be reset.

Once every X interval (1s?) we can quickly loop through the whole cache, look at all timer and any that are beyond a given treshhold (30s?) will be dropped. Keep in mind that the cache gets accessed many times per second, thus every USED entry in the cache should be having at least an equal amount of calls as the current FPS rating.

This would automatically (internally speaking) cleanup the cache without the end-user needing to do anything at all. No tracking required either. Just load your thing once somewhere, drop it and forget about it; eventually it'll get cleared out.

While Pipelines and Shaders are very cheap in memory size(???), the Material Cache as mentioned in #141 would store many textures at once which quiet easily could feed on memory until heap exhausting.