-
Notifications
You must be signed in to change notification settings - Fork 192
More index cleanups #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More index cleanups #839
Changes from all commits
bdc8ecc
1b8b568
314b6b3
4e688d2
6373997
9b545d7
554cc76
b37181b
72f9253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,11 +22,6 @@ static char const * const builtin_sparse_checkout_usage[] = { | |
| NULL | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): |
||
| }; | ||
|
|
||
| static char *get_sparse_checkout_filename(void) | ||
| { | ||
| return git_pathdup("info/sparse-checkout"); | ||
| } | ||
|
|
||
| static void write_patterns_to_file(FILE *fp, struct pattern_list *pl) | ||
| { | ||
| int i; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ static int subtree_name_cmp(const char *one, int onelen, | |
| return memcmp(one, two, onelen); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): |
||
| } | ||
|
|
||
| static int subtree_pos(struct cache_tree *it, const char *path, int pathlen) | ||
| int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen) | ||
| { | ||
| struct cache_tree_sub **down = it->down; | ||
| int lo, hi; | ||
|
|
@@ -72,7 +72,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it, | |
| int create) | ||
| { | ||
| struct cache_tree_sub *down; | ||
| int pos = subtree_pos(it, path, pathlen); | ||
| int pos = cache_tree_subtree_pos(it, path, pathlen); | ||
| if (0 <= pos) | ||
| return it->down[pos]; | ||
| if (!create) | ||
|
|
@@ -123,7 +123,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path) | |
| it->entry_count = -1; | ||
| if (!*slash) { | ||
| int pos; | ||
| pos = subtree_pos(it, path, namelen); | ||
| pos = cache_tree_subtree_pos(it, path, namelen); | ||
| if (0 <= pos) { | ||
| cache_tree_free(&it->down[pos]->cache_tree); | ||
| free(it->down[pos]); | ||
|
|
@@ -151,16 +151,15 @@ void cache_tree_invalidate_path(struct index_state *istate, const char *path) | |
| istate->cache_changed |= CACHE_TREE_CHANGED; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): |
||
| } | ||
|
|
||
| static int verify_cache(struct cache_entry **cache, | ||
| int entries, int flags) | ||
| static int verify_cache(struct index_state *istate, int flags) | ||
| { | ||
| int i, funny; | ||
| unsigned i, funny; | ||
| int silent = flags & WRITE_TREE_SILENT; | ||
|
|
||
| /* Verify that the tree is merged */ | ||
| funny = 0; | ||
| for (i = 0; i < entries; i++) { | ||
| const struct cache_entry *ce = cache[i]; | ||
| for (i = 0; i < istate->cache_nr; i++) { | ||
| const struct cache_entry *ce = istate->cache[i]; | ||
| if (ce_stage(ce)) { | ||
| if (silent) | ||
| return -1; | ||
|
|
@@ -180,13 +179,13 @@ static int verify_cache(struct cache_entry **cache, | |
| * stage 0 entries. | ||
| */ | ||
| funny = 0; | ||
| for (i = 0; i < entries - 1; i++) { | ||
| for (i = 0; i + 1 < istate->cache_nr; i++) { | ||
| /* path/file always comes after path because of the way | ||
| * the cache is sorted. Also path can appear only once, | ||
| * which means conflicting one would immediately follow. | ||
| */ | ||
| const struct cache_entry *this_ce = cache[i]; | ||
| const struct cache_entry *next_ce = cache[i + 1]; | ||
| const struct cache_entry *this_ce = istate->cache[i]; | ||
| const struct cache_entry *next_ce = istate->cache[i + 1]; | ||
| const char *this_name = this_ce->name; | ||
| const char *next_name = next_ce->name; | ||
| int this_len = ce_namelen(this_ce); | ||
|
|
@@ -436,16 +435,20 @@ static int update_one(struct cache_tree *it, | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): |
||
| int cache_tree_update(struct index_state *istate, int flags) | ||
| { | ||
| struct cache_tree *it = istate->cache_tree; | ||
| struct cache_entry **cache = istate->cache; | ||
| int entries = istate->cache_nr; | ||
| int skip, i = verify_cache(cache, entries, flags); | ||
| int skip, i; | ||
|
|
||
| i = verify_cache(istate, flags); | ||
|
|
||
| if (i) | ||
| return i; | ||
|
|
||
| if (!istate->cache_tree) | ||
| istate->cache_tree = cache_tree(); | ||
|
|
||
| trace_performance_enter(); | ||
| trace2_region_enter("cache_tree", "update", the_repository); | ||
| i = update_one(it, cache, entries, "", 0, &skip, flags); | ||
| i = update_one(istate->cache_tree, istate->cache, istate->cache_nr, | ||
| "", 0, &skip, flags); | ||
| trace2_region_leave("cache_tree", "update", the_repository); | ||
| trace_performance_leave("cache_tree_update"); | ||
| if (i < 0) | ||
|
|
@@ -635,9 +638,6 @@ static int write_index_as_tree_internal(struct object_id *oid, | |
| cache_tree_valid = 0; | ||
| } | ||
|
|
||
| if (!index_state->cache_tree) | ||
| index_state->cache_tree = cache_tree(); | ||
|
|
||
| if (!cache_tree_valid && cache_tree_update(index_state, flags) < 0) | ||
| return WRITE_TREE_UNMERGED_INDEX; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -328,6 +328,7 @@ struct index_state { | |
| struct ewah_bitmap *fsmonitor_dirty; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): |
||
| struct mem_pool *ce_mem_pool; | ||
| struct progress *progress; | ||
| struct repository *repo; | ||
| }; | ||
|
|
||
| /* Name hashing */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,14 +13,19 @@ | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): |
||
| struct trace_key trace_fsmonitor = TRACE_KEY_INIT(FSMONITOR); | ||
|
|
||
| static void assert_index_minimum(struct index_state *istate, size_t pos) | ||
| { | ||
| if (pos > istate->cache_nr) | ||
| BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", | ||
| (uintmax_t)pos, istate->cache_nr); | ||
| } | ||
|
|
||
| static void fsmonitor_ewah_callback(size_t pos, void *is) | ||
| { | ||
| struct index_state *istate = (struct index_state *)is; | ||
| struct cache_entry *ce; | ||
|
|
||
| if (pos >= istate->cache_nr) | ||
| BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" >= %u)", | ||
| (uintmax_t)pos, istate->cache_nr); | ||
| assert_index_minimum(istate, pos + 1); | ||
|
|
||
| ce = istate->cache[pos]; | ||
| ce->ce_flags &= ~CE_FSMONITOR_VALID; | ||
|
|
@@ -82,10 +87,8 @@ int read_fsmonitor_extension(struct index_state *istate, const void *data, | |
| } | ||
| istate->fsmonitor_dirty = fsmonitor_dirty; | ||
|
|
||
| if (!istate->split_index && | ||
| istate->fsmonitor_dirty->bit_size > istate->cache_nr) | ||
| BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", | ||
| (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); | ||
| if (!istate->split_index) | ||
| assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); | ||
|
|
||
| trace_printf_key(&trace_fsmonitor, "read fsmonitor extension successful"); | ||
| return 0; | ||
|
|
@@ -110,10 +113,8 @@ void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate) | |
| uint32_t ewah_size = 0; | ||
| int fixup = 0; | ||
|
|
||
| if (!istate->split_index && | ||
| istate->fsmonitor_dirty->bit_size > istate->cache_nr) | ||
| BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", | ||
| (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); | ||
| if (!istate->split_index) | ||
| assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); | ||
|
|
||
| put_be32(&hdr_version, INDEX_EXTENSION_VERSION2); | ||
| strbuf_add(sb, &hdr_version, sizeof(uint32_t)); | ||
|
|
@@ -335,9 +336,7 @@ void tweak_fsmonitor(struct index_state *istate) | |
| } | ||
|
|
||
| /* Mark all previously saved entries as dirty */ | ||
| if (istate->fsmonitor_dirty->bit_size > istate->cache_nr) | ||
| BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", | ||
| (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); | ||
| assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); | ||
| ewah_each_bit(istate->fsmonitor_dirty, fsmonitor_ewah_callback, istate); | ||
|
|
||
| refresh_fsmonitor(istate); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): |
||
| #include "cache.h" | ||
| #include "thread-utils.h" | ||
| #include "trace2.h" | ||
|
|
||
| struct dir_entry { | ||
| struct hashmap_entry ent; | ||
|
|
@@ -577,6 +578,7 @@ static void lazy_init_name_hash(struct index_state *istate) | |
| if (istate->name_hash_initialized) | ||
| return; | ||
| trace_performance_enter(); | ||
| trace2_region_enter("index", "name-hash-init", istate->repo); | ||
| hashmap_init(&istate->name_hash, cache_entry_cmp, NULL, istate->cache_nr); | ||
| hashmap_init(&istate->dir_hash, dir_entry_cmp, NULL, istate->cache_nr); | ||
|
|
||
|
|
@@ -597,6 +599,7 @@ static void lazy_init_name_hash(struct index_state *istate) | |
| } | ||
|
|
||
| istate->name_hash_initialized = 1; | ||
| trace2_region_leave("index", "name-hash-init", istate->repo); | ||
| trace_performance_leave("initialize name hash"); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,8 +303,7 @@ test_expect_success 'progress generates traces' ' | |
| "Working hard" <in 2>stderr && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Elijah Newren wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this): |
||
|
|
||
| # t0212/parse_events.perl intentionally omits regions and data. | ||
| grep -e "region_enter" -e "\"category\":\"progress\"" trace.event && | ||
| grep -e "region_leave" -e "\"category\":\"progress\"" trace.event && | ||
| test_region progress "Working hard" trace.event && | ||
| grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event && | ||
| grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event | ||
| ' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Elijah Newren wrote (reply to this):