Skip to content

Draft: Adding a cache layer on top of Praefect

Adrien Carreira requested to merge XciD/gitaly:praefect-cache into master

Purpose of this PR is to create a cache layer on top of Gitaly avoiding calling gitaly nodes if no changes occurs.

For that, we can use the generation from praefect database, each update increase the generation value, that will automatically invalidate the cache.

In order to get the generation, we use the current query that get the list of node with the repository. We add the generation on the select query. Praefect use a internal cache + listening into db to invalidate this generation.

Hash key is composed of: method / repo generation / serialized message

Also handle NotFound as cache entry

NB: I've implemented a custom LRU that handle the size of objects instead of the count. (did not found a good library to do it) NB2: Code could be cleaner, I've tried to limit code modification for fork maintenance NB3: Not tested in go for now

Screenshot_2022-08-05_at_11.51.41 Screenshot_2022-08-05_at_11.52.43 Screenshot_2022-08-05_at_11.55.13

Edited by Adrien Carreira

Merge request reports