Skip to content

Commit 0b2637a

Browse files
committed
Merge pull request #964 from jeffhostetler/jeffhostetler/memihash_perf
Jeffhostetler/memihash perf
2 parents 39c002a + f4517f3 commit 0b2637a

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

cache.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ struct cache_entry {
177177
unsigned int ce_flags;
178178
unsigned int ce_namelen;
179179
unsigned int index; /* for link extension */
180+
unsigned int precompute_hash_state;
181+
unsigned int precompute_hash_name;
182+
unsigned int precompute_hash_dir;
180183
struct object_id oid;
181184
char name[FLEX_ARRAY]; /* more */
182185
};
@@ -233,6 +236,19 @@ struct cache_entry {
233236
#error "CE_EXTENDED_FLAGS out of range"
234237
#endif
235238

239+
/*
240+
* Bit set if preload-index precomputed the hash value(s)
241+
* for this cache-entry.
242+
*/
243+
#define CE_PRECOMPUTE_HASH_STATE__SET (1 << 0)
244+
/*
245+
* Bit set if precompute-index also precomputed the hash value
246+
* for the parent directory.
247+
*/
248+
#define CE_PRECOMPUTE_HASH_STATE__DIR (1 << 1)
249+
250+
void precompute_istate_hashes(struct cache_entry *ce);
251+
236252
/* Forward structure decls */
237253
struct pathspec;
238254
struct child_process;

preload-index.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static void *preload_thread(void *_data)
4747
struct cache_entry *ce = *cep++;
4848
struct stat st;
4949

50+
precompute_istate_hashes(ce);
51+
5052
if (ce_stage(ce))
5153
continue;
5254
if (S_ISGITLINK(ce->ce_mode))

read-cache.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void rename_index_entry_at(struct index_state *istate, int nr, const char *new_n
7373
copy_cache_entry(new, old);
7474
new->ce_flags &= ~CE_HASHED;
7575
new->ce_namelen = namelen;
76+
new->precompute_hash_state = 0;
7677
new->index = 0;
7778
memcpy(new->name, new_name, namelen + 1);
7879

@@ -614,6 +615,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
614615
new = xcalloc(1, cache_entry_size(len));
615616
memcpy(new->name, alias->name, len);
616617
copy_cache_entry(new, ce);
618+
new->precompute_hash_state = 0;
617619
save_or_free_index_entry(istate, ce);
618620
return new;
619621
}
@@ -1446,6 +1448,7 @@ static struct cache_entry *cache_entry_from_ondisk(struct ondisk_cache_entry *on
14461448
ce->ce_stat_data.sd_size = get_be32(&ondisk->size);
14471449
ce->ce_flags = flags & ~CE_NAMEMASK;
14481450
ce->ce_namelen = len;
1451+
ce->precompute_hash_state = 0;
14491452
ce->index = 0;
14501453
hashcpy(ce->oid.hash, ondisk->sha1);
14511454
memcpy(ce->name, name, len);

0 commit comments

Comments
 (0)