From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.149 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796053493; b=P/Td616UfL3V5nfO1vbjWvFbL2oMW+jCnW3Gvgpn1HshJauOsdyUtvlLhrPzx+Qtk7gO u4kU5eDtBSIbcF2zuvBdTCS4M8yBFxZPEdSofhrxnyyanHRMHSQ3JxneKPZYpRVDgCA6E 6e7MVx/4clS885uKqZwoUSoDt4FVi2U24+uQAJxkYTLf/YKYU7NdsVjn8CQ5vWNI1dLt3 PFZY9jDv0uJVxPyr7TvR7DKwmJfB23pbmJ95m59hu56kt2r8IWAwTxXu7dU9BOKT56FB6 vZtKLWu0gvIqKRZWNE0TLUFPa5PKkl4qsaBpKL+PbOcjP3Fl5RZ0HoVV2/E+cma37LA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053493; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Mime-Version:Content-Transfer-Encoding:Content-Type:Date: Message-Id:Cc:Subject:From:To:X-Mailer:References:In-Reply-To; bh=kXNtzB4PynWPj3w0uBDfIsmGWlj7jO1HVyoPzt0Ya2Q=; b=AK+i4IN5+bYo43hfi119qkzT1rGPtYxv1ZXCvQ7hF5OOWpDBidOars/0cJE4jiBR1JQg aH1vX9JoFroWbw08wZqcf6pLdL1lbt3Rc6DHmIj0A+31HVmG+jic7gZX9BJQG91kH7ePn RBERnFajIBsQyWiNfu79zP/KH0JoUmu9MFQhLtPKmi1rFqISMDVyk0dsxCIBFCeopbZa/ OyTZCdCDY5bqJOl/oV83ZQuWTeyfbbSMtKeZxYaC4uj7InlKyWKPM9U0xU1Cheuo+hNMX RiL2nN7WGNdo4+s/RHGpRd9Kc9Af1vqoi3okcjCoGZY0Leid52hhQpnq+A6Z0fZmLpw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=fastmail.com; spf=pass smtp.mailfrom=fastmail.com; dkim=pass header.d=fastmail.com header.i=@fastmail.com header.a=rsa-sha256 header.s=fm3 header.b=cnzBMakk; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=CnE8Ccyh; arc=none smtp.remote-ip=202.12.124.149 Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13464606A320 for ; Mon, 30 Nov 2026 15:44:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13464606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=fastmail.com header.i=@fastmail.com header.a=rsa-sha256 header.s=fm3 header.b=cnzBMakk; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=CnE8Ccyh Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 692C91D00441 for ; Mon, 30 Nov 2026 10:44:51 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 30 Nov 2026 10:44:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1796053490; x=1796139890; bh=kXNtzB4PynWPj3w0uBDfIsmGWlj7jO1HVyoPzt0Ya2Q=; b= cnzBMakkTkwdLQzfjm+T73KrKORu6l8cbTccRURXiATlxS9hofzdLQe3x6Jf6k25 XK1g3J6FfeNAaBiNFPXpTkEdY37nVjPaCAGpJICYbu2MABjwUPKJ8ijS3TC5pAbX a42/qUeEYEf6RLAKZp4ufm4onAX5L17w3aRAieGdNU+gP5pQ+of9K1XCNQOsgvl8 uGBG/l5nmHLx5dqxhtwJhBILZozzbjfgHbOrWO1JWQn9vUztQELpHXvIU+N8yhfx A8kKbcNM0+lihizmViA8ZYxduEUlyuIZrk+iuqT6akEFeSGswsTbZQgq60UCiA5d YAmLifRhIFpgXAb/qgDuqQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1796053490; x= 1796139890; bh=kXNtzB4PynWPj3w0uBDfIsmGWlj7jO1HVyoPzt0Ya2Q=; b=C nE8Ccyhk0dLq/7CZYeug6aL0HX+qruvlsme+tWVsmNiFAMRe89KHqnie1cPABHXZ oh2r2yubG3JU4SJc/pEOKhVABBDfuQxn53kgw5EqMji4Nc+yzz2o+0c1Xo6/tEDm 33oPICZ+123fZ73QfkycFtveXb3kVD0AOPGaoXvjivO2fBWQP5yvcwNrN++a49EC G4wu8T9QLWzPS9vczWLaWMHAIsTsOeMedmN6fnsQxuAwUDH1+SkzBvV/iQFaEkN8 roGP5GCMNsAcuzp652K17qmMQ3BNRXy9NDQvTd2rmcdKNz4NcOZER4gT0PLTBkbK W5AV/9gyhlOIr2uu5oKBQ== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=fastmail.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796053490; d=fastmail.com; mf=PG1hcmtjaHVjYXJyb2xsQGZhc3RtYWlsLmNvbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:ZSv8pfIvKeQoSSu6+mFD54QqJVIXqyIORqi0doHH3CR0iZp A12lcIIdVc4L7NkBK9i6t9mf1rOYI46XhTr7IJeWpiOLf1jPiSQ4NiLJeAgMN6x2 sjw83mehn8+SLwzCAx6NfD4Tlg3j3cTeOrLBZnTDxRdp/gVK7H0X3rX/dTaiZ0QE RX7Oi4FVXEhCB1/0BnT/qWi9NL+rarQ/HVBRcEMQaVJMlglQlwX/+G4EMtdq6Pfb ko3nRUNMhZvsZ2yDFyRWt7X+Fa+WvWGB5VczU+btthrDVHsRElt+IZWwzTKw2ilE OAQhjNQgxPL+7FdUa23XqPnbZg1ju/Y2Wb2tJ+A==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:cWuqtBu+tf0qruaqW5lbcVui0gK9YZpTMHbx005bYac=:4xHmquZGDOrNRpcHVYbUR2mj5TgbMj92opGDtddwnzw=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGGJDQXTwP8kGLtIdKAyBQ8zgpA2Rsq5Ff3ARaMWARpV4dRRLE64ViiQkTX/MkOAz P0makkAJw32nEZjJZawwp6wJDVNQZ0Sr5cb+oUYVLNwHI5yXnQqf1HzOxo00PA7NxrCQiE 4AmsGDIf8YJoU+zA3LKcyslGA5GEx6258ymjp1Yi5iy62oWwCP7W+wwawyX5soNAQ+A4pQ M8SdXn7maSXQQClUTpxAupGKHCO8hfRim7cyeRMjobD/pTAMlDddrlKHOlUMyqwlLste8j TqUzDMceW7l55U7HfDeXmOigh3k8d6XclL7bWvOnMIrQbK629ANR7wyyTB8mEESu9I1qpF hnADY7JG/bjve7iJJp+aLTvjlCxIWdvt940YgaI16QDRQ4QMOSQrmxNGPvAGlFnreefkE1 Vrkh5c1VpTElD8/MnJ1Ux76yko0qzEad3hJu6WlZPTKuqBrbx41EavooIfGgMKa76Nhauj zQ2wxbeZIW3+1cplOB3m4pMQgolRpd3yB5SQAZB2/CmOVvp0TS1Zb0VqkUhh7YGZeHKW81 yIYrVmEutcV95zdayyMbT2i70kFN7LSGPX1YcuPx6WFssnXeehsk3LAiqo46zpr++IS2bi wXg1Y+qycksIsyow25nVdM+AZ9Hz/maiGiqjSMSuc0H5wG1sDEwArwfqc+Ww X-ME-Proxy: Feedback-ID: id2564aa6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Nov 2026 10:44:50 -0500 (EST) X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 30 Nov 2026 10:44:50 -0500 Message-Id: Cc: Subject: Re: [PATCH v5 1/2] repo: add level of concern reporting From: "Mark C. Chu-Carroll" To: "Christian Couder" , "Mark C. Chu-Carroll" X-Mailer: aerc 0.21.0 References: <20261102-b4-repo-structure-concern-v5-0-2d8f37b70b75@fastmail.com> <20261102-b4-repo-structure-concern-v5-1-2d8f37b70b75@fastmail.com> In-Reply-To: On Wed Nov 18, 2026 at 12:34 PM EST, Christian Couder wrote: > On Mon, Nov 2, 2026 at 9:52=E2=80=AFPM Mark C. Chu-Carroll > 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=3D(lines|nul) | -z] [--all | ...]"= , \ >> "git repo info --keys [--format=3D(lines|nul) | -z]" >> >> #define REPO_STRUCTURE_USAGE \ >> - "git repo structure [--format=3D(table|lines|nul) | -z]" >> + "git repo structure [--format=3D(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[] =3D "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=20 changing them is out of scope. It's probably a good change, but=20 I don't think it belongs here. For the prefix, I'll change it. >> static const char *const repo_usage[] =3D { >> 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 th= e size >> + * at which the statistic becomes concerning. The default values for th= e >> + * threshold were selected based on observed values from a collection o= f >> + * representative-ish repositories of varying size, by finding the mean= log_2 >> + * value and standard deviation (sigma) for each statistic over the col= lection. >> + * 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[] =3D "tag-inflated-size"; Yup, will do. >> +static struct concern_stat_threshold repo_structure_concern_thresholds[= ] =3D { >> + { .name =3D CONCERN_STAT_COMMIT_COUNT, .threshold =3D 19 }, >> + { .name =3D CONCERN_STAT_TREE_COUNT, .threshold =3D 21 }, >> + { .name =3D CONCERN_STAT_BLOB_COUNT, .threshold =3D 22 }, >> + { .name =3D CONCERN_STAT_TAG_COUNT, .threshold =3D 15 }, >> + { .name =3D CONCERN_STAT_COMMIT_SIZE, .threshold =3D 28 }, >> + { .name =3D CONCERN_STAT_TREE_SIZE, .threshold =3D 27 }, >> + { .name =3D CONCERN_STAT_BLOB_SIZE, .threshold =3D 36 }, >> + { .name =3D CONCERN_STAT_TAG_SIZE, .threshold =3D 18 }, >> + { .name =3D CONCERN_STAT_COMMIT_LARGEST, .threshold =3D 18 }, >> + { .name =3D CONCERN_STAT_TREE_LARGEST, .threshold =3D 18 }, >> + { .name =3D CONCERN_STAT_BLOB_LARGEST, .threshold =3D 26 }, >> + { .name =3D CONCERN_STAT_TAG_LARGEST, .threshold =3D 15 }, >> + { .name =3D CONCERN_STAT_COMMIT_INFLATED_SIZE, .threshold =3D 28= }, >> + { .name =3D CONCERN_STAT_TREE_INFLATED_SIZE, .threshold =3D 32 }= , >> + { .name =3D CONCERN_STAT_BLOB_INFLATED_SIZE, .threshold =3D 34 }= , >> + { .name =3D CONCERN_STAT_TAG_INFLATED_SIZE, .threshold =3D 25 }, >> + { 0 } >> +}; > > Actually it might be better to use enums like for example: > > enum concern_stat { > CONCERN_COMMIT_COUNT =3D 0, > CONCERN_TREE_COUNT, > ... > CONCERN_TAG_INFLATED_SIZE, > CONCERN_STAT_NR > }; > > static const char *concern_stat_names[CONCERN_STAT_NR] =3D { > [CONCERN_COMMIT_COUNT] =3D "commit-count", > [CONCERN_TREE_COUNT] =3D "tree-count", > ... > [CONCERN_TAG_INFLATED_SIZE] =3D "tag-inflated-size", > }; > > static const size_t default_concern_thresholds[CONCERN_STAT_NR] =3D { > [CONCERN_COMMIT_COUNT] =3D 19, > [CONCERN_TREE_COUNT] =3D 21, > ... > [CONCERN_TAG_INFLATED_SIZE] =3D 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=20 in an early version of the change. Using the strings the way I landed=20 on isn't great; but the amount of duplication in having the strings and=20 the enum and converting between them felt off, but I'm happy to go=20 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 =3D 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 *t= hresholds, >> + 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 =3D get_concern_threshold(concern_na= me, thresholds); >> + if (threshold < 0) >> + BUG("unexpected repository stat threshold: '%s'"= , concern_name); >> + log_value =3D (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 =3D 0; Again, right. Thanks for the review! Mark --=20 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