Re: [PATCH v2] index: add trace2 region for clear skip worktree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 10/27/22 8:46 PM, Anh Le via GitGitGadget wrote:
[...]
diff --git a/sparse-index.c b/sparse-index.c
index e4a54ce1943..dbf647949c1 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -493,24 +493,38 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
  	int dir_found = 1;
int i;
+	int path_counts[2] = {0, 0};
+	int restarted = 0;
if (!core_apply_sparse_checkout ||
  	    sparse_expect_files_outside_of_patterns)
  		return;
+ trace2_region_enter("index", "clear_skip_worktree_from_present_files", istate->repo);
  restart:
  	for (i = 0; i < istate->cache_nr; i++) {
  		struct cache_entry *ce = istate->cache[i];
- if (ce_skip_worktree(ce) &&
-		    path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
-			if (S_ISSPARSEDIR(ce->ce_mode)) {
-				ensure_full_index(istate);
-				goto restart;
+		if (ce_skip_worktree(ce)) {
+			path_counts[restarted]++;
+			if (path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
+				if (S_ISSPARSEDIR(ce->ce_mode)) {
+					ensure_full_index(istate);
+					restarted = 1;
+					goto restart;
+				}
+				ce->ce_flags &= ~CE_SKIP_WORKTREE;
  			}
-			ce->ce_flags &= ~CE_SKIP_WORKTREE;
  		}
  	}
+
+	if (path_counts[0] > 0) {
+		trace2_data_intmax("index", istate->repo, "clear_skip_worktree_from_present_files/path_count", path_counts[0]);
+	}
+	if (restarted) {
+		trace2_data_intmax("index", istate->repo, "clear_skip_worktree_from_present_files/full_index/path_count", path_counts[1]);
+	}
+	trace2_region_leave("index", "clear_skip_worktree_from_present_files", istate->repo);
  }

This looks good.  And I think it sets us up to later
answer some of our earlier perf questions after you
get some data.

For example, if the path_count[0] phase is expensive,
does the restart always need to restart the loop at i=0?
Granted, the `ensure_full_index()` may create a new cache-entry
array, so the value of `i` prior to the call may not correspond
to the same cell after the call at the `goto`, but we could
cache the strdup the pathname of cache[i] before the call and
do a find on the new cache[] afterwards to get the corresponding
i-prime value and let the restart start the loop on i-prime.
That's just an idea, but let's wait for the data to see if that
would be helpful.


Thanks!
Jeff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux