{"thread":{"id":"63819","subject":"[PATCH] blame: only parse detailed commit info if needed","startedAt":"2025-07-22T11:42:34Z","lastAt":"2025-07-23T06:02:25Z","messageCount":4,"participants":["Han Young","Patrick Steinhardt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"522433","messageId":"20250722114220.87570-1-hanyang.tony@bytedance.com","threadId":"63819","inReplyTo":null,"subject":"[PATCH] blame: only parse detailed commit info if needed","fromName":"Han Young","fromEmail":"hanyang.tony@bytedance.com","sentAt":"2025-07-22T11:42:20Z","receivedAt":"2025-07-22T11:42:34Z","isPatch":true,"sender":{"key":"hanyang.tony@bytedance.com","avatar":"https://avatars.githubusercontent.com/u/108711387?v=4"},"body":"In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),\nThe function get_commit_info can terminate commit parsing early if only\nthe author information is needed. This ability is not used by callers\nwho do not require detailed commit information. Stop requesting detailed\ncommit information for these callers.\n\nSigned-off-by: Han Young <hanyang.tony@bytedance.com>\n---\n builtin/blame.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 91586e685..b6a38e530 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -471,7 +471,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int\n \tint show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);\n \tconst char *default_color = NULL, *color = NULL, *reset = NULL;\n \n-\tget_commit_info(suspect->commit, &ci, 1);\n+\tget_commit_info(suspect->commit, &ci, 0);\n \toid_to_hex_r(hex, &suspect->commit->object.oid);\n \n \tcp = blame_nth_line(sb, ent->lno);\n@@ -665,7 +665,7 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)\n \t\tif (!(suspect->commit->object.flags & METAINFO_SHOWN)) {\n \t\t\tstruct commit_info ci = COMMIT_INFO_INIT;\n \t\t\tsuspect->commit->object.flags |= METAINFO_SHOWN;\n-\t\t\tget_commit_info(suspect->commit, &ci, 1);\n+\t\t\tget_commit_info(suspect->commit, &ci, 0);\n \t\t\tif (*option & OUTPUT_SHOW_EMAIL)\n \t\t\t\tnum = utf8_strwidth(ci.author_mail.buf);\n \t\t\telse\n-- \n2.50.1.321.gea4e667e7\n\n"},{"id":"522442","messageId":"aH-dGhHm2xuY4yT3@pks.im","threadId":"63819","inReplyTo":"20250722114220.87570-1-hanyang.tony@bytedance.com","subject":"Re: [PATCH] blame: only parse detailed commit info if needed","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-22T14:15:54Z","receivedAt":"2025-07-22T14:16:02Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Jul 22, 2025 at 07:42:20PM +0800, Han Young wrote:\n> In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),\n> The function get_commit_info can terminate commit parsing early if only\n> the author information is needed. This ability is not used by callers\n> who do not require detailed commit information. Stop requesting detailed\n> commit information for these callers.\n\nOkay. I think there's two important pieces of information missing here:\n\n  - What does this buy us? I guess the answer is performance, but it\n    would be sure to quantify in which scenarios and how much of a\n    speedup this buys us.\n\n  - Any reasoning why those two callers don't need the information.\n    Reviewers can try to piece it together manually, but it would be\n    nice to hold their hand and lead them through the change.\n\nThanks!\n\nPatrick\n"},{"id":"522472","messageId":"xmqq5xfktaq7.fsf@gitster.g","threadId":"63819","inReplyTo":"aH-dGhHm2xuY4yT3@pks.im","subject":"Re: [PATCH] blame: only parse detailed commit info if needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-22T17:08:00Z","receivedAt":"2025-07-22T17:08:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Jul 22, 2025 at 07:42:20PM +0800, Han Young wrote:\n>> In commit cee7f245d (git-pickaxe: blame rewritten., 2006-10-19),\n>> The function get_commit_info can terminate commit parsing early if only\n>> the author information is needed. This ability is not used by callers\n>> who do not require detailed commit information. Stop requesting detailed\n>> commit information for these callers.\n>\n> Okay. I think there's two important pieces of information missing here:\n>\n>   - What does this buy us? I guess the answer is performance, but it\n>     would be sure to quantify in which scenarios and how much of a\n>     speedup this buys us.\n>\n>   - Any reasoning why those two callers don't need the information.\n>     Reviewers can try to piece it together manually, but it would be\n>     nice to hold their hand and lead them through the change.\n\nGood questions to ask.  \n\nIf the answer to the first question is \"well, not really?\", then\nanother thing to consider would be if we want to remove that\nshort-cut as conditionally grabbing only just some pieces of\ninformation without getting others is not helping.\n\nThanks.\n"},{"id":"522524","messageId":"CAG1j3zHn_wp-R6tOJqCFi+wKro_t0oNj+aHsnbLw+O66i2YvQQ@mail.gmail.com","threadId":"63819","inReplyTo":"aH-dGhHm2xuY4yT3@pks.im","subject":"Re: [External] Re: [PATCH] blame: only parse detailed commit info if needed","fromName":"Han Young","fromEmail":"hanyang.tony@bytedance.com","sentAt":"2025-07-23T06:02:12Z","receivedAt":"2025-07-23T06:02:25Z","isPatch":true,"sender":{"key":"hanyang.tony@bytedance.com","avatar":"https://avatars.githubusercontent.com/u/108711387?v=4"},"body":"On Tue, Jul 22, 2025 at 10:16 PM Patrick Steinhardt <ps@pks.im> wrote:\n>   - What does this buy us? I guess the answer is performance, but it\n>     would be sure to quantify in which scenarios and how much of a\n>     speedup this buys us.\nI actually ran some performance tests before submitting this patch,\nOn a 5000-line file with a fairly long history, running\n\"git blame --porcelain FILE\" for 100 times, the speedup is less\nthan 1 second. Considering the total run time is 180 seconds, I think\nthe performance gain is negligible (the speed increase could even be\ndue to system noise).\n\n> - Any reasoning why those two callers don't need the information.\n> Reviewers can try to piece it together manually, but it would be\n> nice to hold their hand and lead them through the change.\nThese two callers only access the author information part of the\ncommit_info struct, before discarding the commit_info object.\nSorry for not including this information in the patch description.\n\nOn Wed, Jul 23, 2025 at 1:08 AM Junio C Hamano <gitster@pobox.com> wrote:\n> If the answer to the first question is \"well, not really?\", then\n> another thing to consider would be if we want to remove that\n> short-cut as conditionally grabbing only just some pieces of\n> information without getting others is not helping.\nAll callers of the get_commit_info function request detailed\ncommit information. Removing the shortcut would reduce the\ncomplexity of the codebase. I will send another patch to remove\nthe \"detailed\" param from the get_commit_info.\n\nThanks\n"}]}