mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
packfile: move the MRU list into the packfile store
Packfiles have two lists associated to them:
- A list that keeps track of packfiles in the order that they were
added to a packfile store.
- A list that keeps track of packfiles in most-recently-used order so
that packfiles that are more likely to contain a specific object are
ordered towards the front.
Both of these lists are hosted by `struct packed_git` itself, So to
identify all packfiles in a repository you simply need to grab the first
packfile and then iterate the `->next` pointers or the MRU list. This
pattern has the problem that all packfiles are part of the same list,
regardless of whether or not they belong to the same object source.
With the upcoming pluggable object database effort this needs to change:
packfiles should be contained by a single object source, and reading an
object from any such packfile should use that source to look up the
object. Consequently, we need to break up the global lists of packfiles
into per-object-source lists.
A first step towards this goal is to move those lists out of `struct
packed_git` and into the packfile store. While the packfile store is
currently sitting on the `struct object_database` level, the intent is
to push it down one level into the `struct odb_source` in a subsequent
patch series.
Introduce a new `struct packfile_list` that is used to manage lists of
packfiles and use it to store the list of most-recently-used packfiles
in `struct packfile_store`. For now, the new list type is only used in a
single spot, but we'll expand its usage in subsequent patches.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e78ab37054
commit
f905a855b1
19
packfile.h
19
packfile.h
@@ -12,7 +12,6 @@ struct object_info;
|
||||
|
||||
struct packed_git {
|
||||
struct packed_git *next;
|
||||
struct list_head mru;
|
||||
struct pack_window *windows;
|
||||
off_t pack_size;
|
||||
const void *index_data;
|
||||
@@ -52,6 +51,20 @@ struct packed_git {
|
||||
char pack_name[FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
struct packfile_list {
|
||||
struct packfile_list_entry *head, *tail;
|
||||
};
|
||||
|
||||
struct packfile_list_entry {
|
||||
struct packfile_list_entry *next;
|
||||
struct packed_git *pack;
|
||||
};
|
||||
|
||||
void packfile_list_clear(struct packfile_list *list);
|
||||
void packfile_list_remove(struct packfile_list *list, struct packed_git *pack);
|
||||
void packfile_list_prepend(struct packfile_list *list, struct packed_git *pack);
|
||||
void packfile_list_append(struct packfile_list *list, struct packed_git *pack);
|
||||
|
||||
/*
|
||||
* A store that manages packfiles for a given object database.
|
||||
*/
|
||||
@@ -79,7 +92,7 @@ struct packfile_store {
|
||||
} kept_cache;
|
||||
|
||||
/* A most-recently-used ordered version of the packs list. */
|
||||
struct list_head mru;
|
||||
struct packfile_list mru;
|
||||
|
||||
/*
|
||||
* A map of packfile names to packed_git structs for tracking which
|
||||
@@ -153,7 +166,7 @@ struct packed_git *packfile_store_get_packs(struct packfile_store *store);
|
||||
/*
|
||||
* Get all packs in most-recently-used order.
|
||||
*/
|
||||
struct list_head *packfile_store_get_packs_mru(struct packfile_store *store);
|
||||
struct packfile_list_entry *packfile_store_get_packs_mru(struct packfile_store *store);
|
||||
|
||||
/*
|
||||
* Open the packfile and add it to the store if it isn't yet known. Returns
|
||||
|
||||
Reference in New Issue
Block a user