buffer: in cache, replace global tile queue with per-instance queues
Currently, we maintain a global queue of tiles, ordered by access time, from most-recent to least-recent. This requires us to acquire a global mutex whenever accessing/inserting a tile, in order to maintain the queue. The commit replaces the global tile queue with per-instance tile queues, ordered by the same criterion, which allows us to avoid acquiring the global cache mutex in the above cases. The global mutex mainly has to be acquired only during cache construction, destruction, and trimming. To keep trimming simple, and relatively efficient, this commit changes the cache eviction strategy: instead of evicting the least- recently accessed tile first, we evict the least-recently accessed tile of the least-recently accessed cache first (which might not be the least-recently accessed tile overall).
Showing with 246 additions and 153 deletions