Skip to content

Commit e6a1df2

Browse files
author
Git for Windows Build Agent
committed
Merge pull request #964 from jeffhostetler/jeffhostetler/memihash_perf
Jeffhostetler/memihash perf
2 parents 8827f70 + 64e84ee commit e6a1df2

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
@@ -173,6 +173,9 @@ struct cache_entry {
173173
unsigned int ce_flags;
174174
unsigned int ce_namelen;
175175
unsigned int index; /* for link extension */
176+
unsigned int precompute_hash_state;
177+
unsigned int precompute_hash_name;
178+
unsigned int precompute_hash_dir;
176179
struct object_id oid;
177180
char name[FLEX_ARRAY]; /* more */
178181
};
@@ -229,6 +232,19 @@ struct cache_entry {
229232
#error "CE_EXTENDED_FLAGS out of range"
230233
#endif
231234

235+
/*
236+
* Bit set if preload-index precomputed the hash value(s)
237+
* for this cache-entry.
238+
*/
239+
#define CE_PRECOMPUTE_HASH_STATE__SET (1 << 0)
240+
/*
241+
* Bit set if precompute-index also precomputed the hash value
242+
* for the parent directory.
243+
*/
244+
#define CE_PRECOMPUTE_HASH_STATE__DIR (1 << 1)
245+
246+
void precompute_istate_hashes(struct cache_entry *ce);
247+
232248
/* Forward structure decls */
233249
struct pathspec;
234250
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)