From: "Mark C. Chu-Carroll" <markchucarroll@fastmail.com>
To: "Christian Couder" <christian.couder@gmail.com>,
"Mark C. Chu-Carroll" <markchucarroll@fastmail.com>
Cc: <git@vger.kernel.org>
Subject: Re: [PATCH v5 1/2] repo: add level of concern reporting
Date: Mon, 30 Nov 2026 10:44:50 -0500 [thread overview]
Message-ID: <DN8NTQVTG5OJ.3P2Y8DP4XDR8@fastmail.com> (raw)
In-Reply-To: <CAP8UFD2rmfaSrNJsBcSyWPJiPneFrJyXxT5KtJUWz-SNU8=8SQ@mail.gmail.com>
On Wed Nov 18, 2026 at 12:34 PM EST, Christian Couder wrote:
> On Mon, Nov 2, 2026 at 9:52 PM Mark C. Chu-Carroll
> <markchucarroll@fastmail.com> wrote:
>>
> diff --git a/builtin/repo.c b/builtin/repo.c
>> index 84e012f83f..7a50605779 100644
>> --- a/builtin/repo.c
>> +++ b/builtin/repo.c
>> @@ -1,7 +1,9 @@
>> #define USE_THE_REPOSITORY_VARIABLE
>>
>> +#include "git-compat-util.h"
>> #include "builtin.h"
>> #include "commit.h"
>> +#include "config.h"
>
> This may be only needed by the second patch.
Yup, you're right.
>
>> #define REPO_INFO_USAGE \
>> "git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \
>> "git repo info --keys [--format=(lines|nul) | -z]"
>>
>> #define REPO_STRUCTURE_USAGE \
>> - "git repo structure [--format=(table|lines|nul) | -z]"
>> + "git repo structure [--format=(table|lines|nul) | -z] [--[no-]concern]"
>> +
>> +#define REPO_STRUCTURE_CONFIG_PREFIX "repo.concern."
>
> The above constants could be defined like the following:
>
> static const char rs_config_prefix[] = "repo.concern.";
>
> This improves type checking and debugging. Also as the constants are
> internal to this file, I don't think it's worth spelling out
> "REPO_STRUCTURE" in their names.
The two usage strings weren't added in this patch; I think
changing them is out of scope. It's probably a good change, but
I don't think it belongs here. For the prefix, I'll change it.
>> static const char *const repo_usage[] = {
>> REPO_INFO_USAGE,
>> @@ -348,8 +353,93 @@ struct stats_table {
>> int name_col_width;
>> int value_col_width;
>> int unit_col_width;
>> + size_t max_concern_value;
>> +};
>> +
>> +/*
>> + * For computing level of concern about a stat, we need to have some
>> + * baseline values. For each of these, we define a minimum level
>> + * of concern, which will appear as 1 star. Then we scale exponentially:
>> + * each time that value doubles, we add another star.
>> + *
>> + * The threshold values for concern are expressed as log_2 values of the size
>> + * at which the statistic becomes concerning. The default values for the
>> + * threshold were selected based on observed values from a collection of
>> + * representative-ish repositories of varying size, by finding the mean log_2
>> + * value and standard deviation (sigma) for each statistic over the collection.
>> + * The threshold for each metric is then set at mean(log_2) + sigma.
>> + */
>> +struct concern_stat_threshold {
>> + const char *name;
>> + size_t threshold;
>> };
>>
>> +#define CONCERN_STAT_COMMIT_COUNT "commit-count"
>> +#define CONCERN_STAT_TREE_COUNT "tree-count"
>> +#define CONCERN_STAT_BLOB_COUNT "blob-count"
>> +#define CONCERN_STAT_TAG_COUNT "tag-count"
>> +#define CONCERN_STAT_COMMIT_SIZE "commit-size"
>> +#define CONCERN_STAT_TREE_SIZE "tree-size"
>> +#define CONCERN_STAT_BLOB_SIZE "blob-size"
>> +#define CONCERN_STAT_TAG_SIZE "tag-size"
>> +#define CONCERN_STAT_COMMIT_LARGEST "commit-largest"
>> +#define CONCERN_STAT_TREE_LARGEST "tree-largest"
>> +#define CONCERN_STAT_BLOB_LARGEST "blob-largest"
>> +#define CONCERN_STAT_TAG_LARGEST "tag-largest"
>> +#define CONCERN_STAT_COMMIT_INFLATED_SIZE "commit-inflated-size"
>> +#define CONCERN_STAT_TREE_INFLATED_SIZE "tree-inflated-size"
>> +#define CONCERN_STAT_BLOB_INFLATED_SIZE "blob-inflated-size"
>> +#define CONCERN_STAT_TAG_INFLATED_SIZE "tag-inflated-size"
>
> Same comment as above about using something for example like:
>
> static const char concern_tag_inflated_size[] = "tag-inflated-size";
Yup, will do.
>> +static struct concern_stat_threshold repo_structure_concern_thresholds[] = {
>> + { .name = CONCERN_STAT_COMMIT_COUNT, .threshold = 19 },
>> + { .name = CONCERN_STAT_TREE_COUNT, .threshold = 21 },
>> + { .name = CONCERN_STAT_BLOB_COUNT, .threshold = 22 },
>> + { .name = CONCERN_STAT_TAG_COUNT, .threshold = 15 },
>> + { .name = CONCERN_STAT_COMMIT_SIZE, .threshold = 28 },
>> + { .name = CONCERN_STAT_TREE_SIZE, .threshold = 27 },
>> + { .name = CONCERN_STAT_BLOB_SIZE, .threshold = 36 },
>> + { .name = CONCERN_STAT_TAG_SIZE, .threshold = 18 },
>> + { .name = CONCERN_STAT_COMMIT_LARGEST, .threshold = 18 },
>> + { .name = CONCERN_STAT_TREE_LARGEST, .threshold = 18 },
>> + { .name = CONCERN_STAT_BLOB_LARGEST, .threshold = 26 },
>> + { .name = CONCERN_STAT_TAG_LARGEST, .threshold = 15 },
>> + { .name = CONCERN_STAT_COMMIT_INFLATED_SIZE, .threshold = 28 },
>> + { .name = CONCERN_STAT_TREE_INFLATED_SIZE, .threshold = 32 },
>> + { .name = CONCERN_STAT_BLOB_INFLATED_SIZE, .threshold = 34 },
>> + { .name = CONCERN_STAT_TAG_INFLATED_SIZE, .threshold = 25 },
>> + { 0 }
>> +};
>
> Actually it might be better to use enums like for example:
>
> enum concern_stat {
> CONCERN_COMMIT_COUNT = 0,
> CONCERN_TREE_COUNT,
> ...
> CONCERN_TAG_INFLATED_SIZE,
> CONCERN_STAT_NR
> };
>
> static const char *concern_stat_names[CONCERN_STAT_NR] = {
> [CONCERN_COMMIT_COUNT] = "commit-count",
> [CONCERN_TREE_COUNT] = "tree-count",
> ...
> [CONCERN_TAG_INFLATED_SIZE] = "tag-inflated-size",
> };
>
> static const size_t default_concern_thresholds[CONCERN_STAT_NR] = {
> [CONCERN_COMMIT_COUNT] = 19,
> [CONCERN_TREE_COUNT] = 21,
> ...
> [CONCERN_TAG_INFLATED_SIZE] = 25,
> };
>
> struct concern_thresholds {
> size_t log2[CONCERN_STAT_NR];
> };
>
> See `enum color_branch` and the following related definitions in
> "builtin/branch.c" for example.
This is something that I went back and forth on - I actually did this
in an early version of the change. Using the strings the way I landed
on isn't great; but the amount of duplication in having the strings and
the enum and converting between them felt off, but I'm happy to go
back to this approach since you think it reads better.
>
>> +static int get_concern_threshold(const char *name, struct concern_stat_threshold *thresholds)
>
> I think this should return a `size_t` as `thresholds[i].threshold` is a `size_t`
Ok.
>
>> +{
>> + for (size_t i = 0; thresholds[i].name; i++) {
>> + if (!strcmp(thresholds[i].name, name))
>> + return thresholds[i].threshold;
>> + }
>> + return -1;
>
> We could just BUG() here instead of doing so in the caller.
Ok.
>
>> +}
>> +
>> +static int repo_structure_concern_level(const char *concern_name,
>> + size_t value,
>> + struct concern_stat_threshold *thresholds,
>> + bool show_concern)
>
> This function could also return a `size_t` instead of an `int` as it
> never returns a negative value.
Ok.
>> +{
>> + if (show_concern) {
>> + size_t log_value;
>> + const int threshold = get_concern_threshold(concern_name, thresholds);
>> + if (threshold < 0)
>> + BUG("unexpected repository stat threshold: '%s'", concern_name);
>> + log_value = (size_t)log2u(value);
>> + if (log_value > (size_t)threshold)
>> + return log_value - threshold;
>> + else
>> + return 0;
>> + } else {
>> + return 0;
>> + }
>> +}
>
> [...]
>
>> +/*
>> + * Define a symbol for 'no concern value for this stat'; this will
>> + * make the code below easier to read.
>> + */
>> +#define CONCERN_STAT_VALUE_NONE 0
>
> This could also be for example:
>
> static const size_t concern_value_none = 0;
Again, right.
Thanks for the review!
Mark
--
Mark Craig Chu-Carroll (@MarkChuCarroll at gitlab)
*** Software Tools/Math Geek - Software Engineer at Gitlab
*** Work Email: mcarroll@gitlab.com / markchucarroll@fastmail.com
*** Personal Blog: http://goodmath.org/blog / Personal email: markcc@gmail.com
next prev parent reply other threads:[~2026-11-30 15:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 13:55 [PATCH 0/3] repo: add degree-of-concern reporting to structure Mark C. Chu-Carroll
2026-10-21 13:55 ` [PATCH 1/3] repo: add level of concern reporting Mark C. Chu-Carroll
2026-10-21 13:55 ` [PATCH 2/3] repo: make concern thresholds configurable Mark C. Chu-Carroll
2026-10-21 13:55 ` [PATCH 3/3] repo: add documentation for level-of-concern Mark C. Chu-Carroll
2026-10-26 17:43 ` [PATCH v2 0/3] repo: add degree-of-concern reporting to structure Mark C. Chu-Carroll
2026-10-26 17:43 ` [PATCH v2 1/3] repo: add level of concern reporting Mark C. Chu-Carroll
2026-10-27 14:55 ` Patrick Steinhardt
2026-10-26 17:43 ` [PATCH v2 2/3] repo: make concern thresholds configurable Mark C. Chu-Carroll
2026-10-27 14:55 ` Patrick Steinhardt
2026-10-26 17:43 ` [PATCH v2 3/3] repo: add documentation for level-of-concern Mark C. Chu-Carroll
2026-10-27 14:55 ` Patrick Steinhardt
2026-10-28 13:23 ` Mark C. Chu-Carroll
2026-10-27 15:39 ` [PATCH v3 0/2] repo: add degree-of-concern reporting to structure Mark C. Chu-Carroll
2026-10-27 15:39 ` [PATCH v3 1/2] repo: add level of concern reporting Mark C. Chu-Carroll
2026-10-27 15:39 ` [PATCH v3 2/2] repo: make concern thresholds configurable Mark C. Chu-Carroll
2026-10-29 17:52 ` [PATCH v4 0/2] repo: add degree-of-concern reporting to structure Mark C. Chu-Carroll
2026-10-29 17:52 ` [PATCH v4 1/2] repo: add level of concern reporting Mark C. Chu-Carroll
2026-10-29 19:53 ` Junio C Hamano
2026-10-29 20:20 ` Mark C. Chu-Carroll
2026-10-29 17:52 ` [PATCH v4 2/2] repo: make concern thresholds configurable Mark C. Chu-Carroll
2026-11-02 16:32 ` [PATCH v5 0/2] repo: add degree-of-concern reporting to structure Mark C. Chu-Carroll
2026-11-02 16:32 ` [PATCH v5 1/2] repo: add level of concern reporting Mark C. Chu-Carroll
2026-11-18 17:34 ` Christian Couder
2026-11-30 15:44 ` Mark C. Chu-Carroll [this message]
2026-11-19 19:44 ` Junio C Hamano
2026-11-30 18:51 ` Mark C. Chu-Carroll
2026-11-02 16:32 ` [PATCH v5 2/2] repo: make concern thresholds configurable Mark C. Chu-Carroll
2026-11-18 17:36 ` Christian Couder
2026-11-30 18:48 ` Mark C. Chu-Carroll
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN8NTQVTG5OJ.3P2Y8DP4XDR8@fastmail.com \
--to=markchucarroll@fastmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox