Skip to content

Commit fe835b0

Browse files
pks-tgitster
authored andcommitted
odb: move MRU list of packfiles into struct packfile_store
The object database tracks the list of packfiles in most-recently-used order, which is mostly used to favor reading from packfiles that contain most of the objects that we're currently accessing. With the introduction of the `struct packfile_store` we have a better place to host this list though. Move the list accordingly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14aaf5c commit fe835b0

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ int prepare_midx_pack(struct multi_pack_index *m,
468468
m->source->local);
469469
if (p) {
470470
install_packed_git(r, p);
471-
list_add_tail(&p->mru, &r->objects->packed_git_mru);
471+
list_add_tail(&p->mru, &r->objects->packfiles->mru);
472472
}
473473
}
474474

odb.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ struct object_database *odb_new(struct repository *repo)
997997
memset(o, 0, sizeof(*o));
998998
o->repo = repo;
999999
o->packfiles = packfile_store_new(o);
1000-
INIT_LIST_HEAD(&o->packed_git_mru);
10011000
pthread_mutex_init(&o->replace_mutex, NULL);
10021001
string_list_init_dup(&o->submodule_source_paths);
10031002
return o;
@@ -1035,7 +1034,6 @@ void odb_clear(struct object_database *o)
10351034
free((char *) o->cached_objects[i].value.buf);
10361035
FREE_AND_NULL(o->cached_objects);
10371036

1038-
INIT_LIST_HEAD(&o->packed_git_mru);
10391037
close_object_store(o);
10401038
packfile_store_free(o->packfiles);
10411039
o->packfiles = NULL;

odb.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "hashmap.h"
55
#include "object.h"
6-
#include "list.h"
76
#include "oidset.h"
87
#include "oidmap.h"
98
#include "string-list.h"
@@ -138,9 +137,6 @@ struct object_database {
138137
* Should only be accessed directly by packfile.c and midx.c.
139138
*/
140139
struct packfile_store *packfiles;
141-
/* A most-recently-used ordered version of the packed_git list. */
142-
struct list_head packed_git_mru;
143-
144140
struct {
145141
struct packed_git **packs;
146142
unsigned flags;

packfile.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,10 @@ static void prepare_packed_git_mru(struct repository *r)
10171017
{
10181018
struct packed_git *p;
10191019

1020-
INIT_LIST_HEAD(&r->objects->packed_git_mru);
1020+
INIT_LIST_HEAD(&r->objects->packfiles->mru);
10211021

10221022
for (p = r->objects->packfiles->packs; p; p = p->next)
1023-
list_add_tail(&p->mru, &r->objects->packed_git_mru);
1023+
list_add_tail(&p->mru, &r->objects->packfiles->mru);
10241024
}
10251025

10261026
static void prepare_packed_git(struct repository *r)
@@ -1095,7 +1095,7 @@ struct packed_git *get_all_packs(struct repository *r)
10951095
struct list_head *get_packed_git_mru(struct repository *r)
10961096
{
10971097
prepare_packed_git(r);
1098-
return &r->objects->packed_git_mru;
1098+
return &r->objects->packfiles->mru;
10991099
}
11001100

11011101
unsigned long unpack_object_header_buffer(const unsigned char *buf,
@@ -2078,10 +2078,10 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
20782078
if (!r->objects->packfiles->packs)
20792079
return 0;
20802080

2081-
list_for_each(pos, &r->objects->packed_git_mru) {
2081+
list_for_each(pos, &r->objects->packfiles->mru) {
20822082
struct packed_git *p = list_entry(pos, struct packed_git, mru);
20832083
if (!p->multi_pack_index && fill_pack_entry(oid, e, p)) {
2084-
list_move(&p->mru, &r->objects->packed_git_mru);
2084+
list_move(&p->mru, &r->objects->packfiles->mru);
20852085
return 1;
20862086
}
20872087
}
@@ -2347,6 +2347,7 @@ struct packfile_store *packfile_store_new(struct object_database *odb)
23472347
struct packfile_store *store;
23482348
CALLOC_ARRAY(store, 1);
23492349
store->odb = odb;
2350+
INIT_LIST_HEAD(&store->mru);
23502351
hashmap_init(&store->map, pack_map_entry_cmp, NULL, 0);
23512352
return store;
23522353
}

packfile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ struct packfile_store {
6464
*/
6565
struct packed_git *packs;
6666

67+
/* A most-recently-used ordered version of the packs list. */
68+
struct list_head mru;
69+
6770
/*
6871
* A map of packfile names to packed_git structs for tracking which
6972
* packs have been loaded already.

0 commit comments

Comments
 (0)