pack: use LRU eviction for delta bases by msuozzo · Pull Request #7410 · libgit2/libgit2 · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 52 additions & 22 deletions src/libgit2/pack.c
6 changes: 4 additions & 2 deletions src/libgit2/pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ struct git_pack_idx_header {
};

typedef struct git_pack_cache_entry {
size_t last_usage; /* enough? */
/* Neighbors in the cache's LRU list, most recently used first. */
struct git_pack_cache_entry *prev, *next;
off64_t offset;
git_atomic32 refcount;
git_rawobj raw;
} git_pack_cache_entry;
Expand Down Expand Up @@ -100,7 +102,7 @@ GIT_HASHMAP_OID_PROTOTYPES(git_pack_oidmap, struct git_pack_entry *);
typedef struct {
size_t memory_used;
size_t memory_limit;
size_t use_ctr;
git_pack_cache_entry *head, *tail; /* LRU list */
git_mutex lock;
git_pack_offsetmap entries;
} git_pack_cache;
Expand Down
113 changes: 113 additions & 0 deletions tests/libgit2/pack/cache.c
Loading