git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Anh Le <anh@canva.com>
Date
Oct 30, 2022, 23:28 UTC
Message-ID
<CAOZNrpH7DSF9m+M7r=Za--dVWDiHyL4hdAUWHfW=DDy10n5eeQ@mail.gmail.com>
In-Reply-To
<xmqqy1szj29n.fsf@gitster.g>

Thank you everyone, lots of things for me to take notes of. I'll send in another patch.

Regards, Anh

On Sat, Oct 29, 2022 at 4:17 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 82 quoted lines
>
> Derrick Stolee <derrickstolee@github.com> writes:
>
> > A few style things:
> >
> > 1. Use "if (path_counts[0])" to detect a non-zero value.
> > 2. Don't use { } around a single-line block.
> > 3. Your lines are quite long, due a lot from your long keys.
> >    Shorten the keys (maybe "sparse_path_count" and "restarted_count"
> >    is enough context) and consider using a line break in
> >    the middle of the parameters.
>
> All good suggestions.  Let me add another one.
>
>   4. Call an array you primarily access its individual elements in
>      singular.  That way, you can say path_count[0] (i.e. the count
>      for the zeroth round).  An array that exists mostly to be
>      passed around as a whole to represent a "set of things", on the
>      other hand, can be called in plural.
>
> Taking them all together, perhaps something like this is what you
> meant?
>
>  sparse-index.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git c/sparse-index.c w/sparse-index.c
> index dbf647949c..8c269dab80 100644
> --- c/sparse-index.c
> +++ w/sparse-index.c
> @@ -493,22 +493,25 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
>         int dir_found = 1;
>
>         int i;
> -       int path_counts[2] = {0, 0};
> +       int path_count[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);
> +       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_counts[restarted]++;
> +                       path_count[restarted]++;
>                         if (path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
>                                 if (S_ISSPARSEDIR(ce->ce_mode)) {
> +                                       if (restarted)
> +                                               BUG("ensure-full-index did not fully flatten?");
>                                         ensure_full_index(istate);
>                                         restarted = 1;
>                                         goto restart;
> @@ -518,13 +521,14 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
>                 }
>         }
>
> -       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);
> +       if (path_count[0])
> +               trace2_data_intmax("index", istate->repo,
> +                                  "sparse_path_count", path_count[0]);
> +       if (restarted)
> +               trace2_data_intmax("index", istate->repo,
> +                                  "sparse_path_count_full", path_count[1]);
> +       trace2_region_leave("index", "clear_skip_worktree_from_present_files",
> +                           istate->repo);
>  }
>
>  /*
>
-- 
**
** <https://www.canva.com/>Empowering the world to design
We're hiring, 
apply here <https://www.canva.com/careers/>! Check out the latest news and 
learnings from our team on the Canva Newsroom 
<https://www.canva.com/newsroom/news/>.
 <https://twitter.com/canva> 
<https://facebook.com/canva> <https://au.linkedin.com/company/canva> 
<https://twitter.com/canva>  <https://facebook.com/canva>  
<https://www.linkedin.com/company/canva> 
 <https://instagram.com/canva>
Previous: Junio C HamanoNext: Jeff Hostetler
Message 10 of 18 in “index: add trace2 region for clear skip worktree”
  1. index: add trace2 region for clear skip worktreeAnh Le via GitGitGadget, Oct 26, 2022
  2. Junio C HamanoOct 26, 2022
  3. Jeff HostetlerOct 26, 2022
  4. Junio C HamanoOct 26, 2022
  5. Jeff HostetlerOct 26, 2022
  6. Anh LeOct 27, 2022
  7. index: add trace2 region for clear skip worktreeAnh Le via GitGitGadget, Oct 28, 2022
  8. Derrick StoleeOct 28, 2022
  9. Junio C HamanoOct 28, 2022
  10. Anh LeOct 30, 2022
  11. Jeff HostetlerOct 28, 2022
  12. index: add trace2 region for clear skip worktreeAnh Le via GitGitGadget, Oct 31, 2022
  13. Taylor BlauOct 31, 2022
  14. 0/2 index: add trace2 region for clear skip worktreeAnh Le via GitGitGadget, Nov 3, 2022
  15. 2/2 index: raise a bug if the index is materialised more than onceAnh Le via GitGitGadget, Nov 3, 2022
  16. 1/2 index: add trace2 region for clear skip worktreeAnh Le via GitGitGadget, Nov 3, 2022
  17. Taylor BlauNov 5, 2022
  18. Derrick StoleeNov 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.