From patchwork Fri Jan 24 03:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EAB5921 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35BC324125 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GLL5khmF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730040AbgAXDfm (ORCPT ); Thu, 23 Jan 2020 22:35:42 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:48328 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgAXDfl (ORCPT ); Thu, 23 Jan 2020 22:35:41 -0500 Received: by mail-pg1-f202.google.com with SMTP id c8so570168pgl.15 for ; Thu, 23 Jan 2020 19:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WvPVNv9YPSMDwsZTnnax5OM3yhXCWMqhegtg+6rIqyk=; b=GLL5khmFkHOPmi8XMuUXvxjIrVk+OXNLZm1bGZy1ET8XAScgkvlsP+IGB1p31nRyS6 qJHxpMsKJoHIuqD/BPwlwuxYae7Y34FttthLssSljyxFzclCfCy50U/q+9LxgvQxaBet zBpJgbrylbbShAmhqUT1mFzooQJQcNPxVSXUKTWY2KED7/4lvC1Z4jbZfW93RORpDpBl /2lYqt7timKa+ApTM9ImKdUgqItCT+mm4PzRCo4LBFko/18IvWuOaB4dofQ1PqRW0yS5 8riJcBS4O2BVxlE5pWnsdycZFJcYrBQisUdUWtsGhZwEB2eElC4dR6yjmk7mcgDqiXaL GhDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WvPVNv9YPSMDwsZTnnax5OM3yhXCWMqhegtg+6rIqyk=; b=pJubx2KrqEw9iWEdpH0Mo2X4BkW3cpG7FnFNQstcxFYQ7xsmWeP95ch1cmTKBYkBhK N5NUA2e5yQZqjUazr38QMq1Aup1OJWQYpi2yWaJW1aH7YMwXgeHSvwK42Pf4YOUyJ/eI VTuTT4ePmE7kAkevlfm3JttbfCBfyu3BiKKM/4XFrXLFvYgBGHvsmhwBOkBD5YsSWaoV 9rTlCATy38H7ry9OqeoQClZXaAf9qupJUIV1uCs0dpeb1XFi2FG2tjRW14o9O6sxJY6q mJOjxISZJKvj6hqsmojeHNZIz37BYm3+z/BscdjeY1VYbObNDXJLxFQRE7In2yKK6UMF IoCw== X-Gm-Message-State: APjAAAV3o3rDg4/bPvVW0IpQ1/Y2blHMHSEag1xLguaUZJtDKI3fQGaT 7uqlKLAPSpXr/qpIRAbw3fO91Hwzlr5rQjUCrWRoh4Dyu8f2/F+aKJvbB19ej2bS4KfrRZDBzzj Xd1DVAFUdEJ39pL8UmbUQR4McXjQx7yBKbdfU0fJz2d61eKfS2RJhuMsyeZRU71DL4ajqfcqiDQ == X-Google-Smtp-Source: APXvYqwsNUgc24Fl3LiOnezxMeoosIzmKCYYduEsohimAL/+ie4cEljT3J6zksTOfecIPSt6pCEZc019ZHZ2BWG5ztk= X-Received: by 2002:a65:4d0b:: with SMTP id i11mr1876227pgt.340.1579836941150; Thu, 23 Jan 2020 19:35:41 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:34 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-14-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 13/15] bugreport: add packed object summary From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Alongside the loose object counts, it can be useful to show the number of packs and packed objects. This way we can check whether the repo has an appropriate ratio of packed to loose objects to help determine whether it's behaving correctly. Signed-off-by: Emily Shaffer --- bugreport.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bugreport.c b/bugreport.c index bf10857183..45cc1764e0 100644 --- a/bugreport.c +++ b/bugreport.c @@ -214,6 +214,41 @@ static void get_loose_object_summary(struct strbuf *obj_info) { total_count_questionable ? " (problem during count)" : ""); } +struct packed_object_cb_data { + struct packed_git *last_pack; + int pack_count; + int object_count; +}; + +static int packed_object_cb(const struct object_id *oid, + struct packed_git *pack, + uint32_t pos, + void *data) { + struct packed_object_cb_data *cb_data = data; + + if (!cb_data) + return 1; + + if (pack && pack != cb_data->last_pack) { + cb_data->last_pack = pack; + cb_data->pack_count++; + } + + cb_data->object_count++; + + return 0; +} + +static void get_packed_object_summary(struct strbuf *obj_info) +{ + struct packed_object_cb_data cb_data = {NULL, 0, 0}; + + for_each_packed_object(packed_object_cb, &cb_data, 0); + + strbuf_addf(obj_info, "%d total packs (%d objects)\n", + cb_data.pack_count, cb_data.object_count); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -292,6 +327,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Loose Object Counts"); get_loose_object_summary(&buffer); + get_header(&buffer, "Packed Object Summary"); + get_packed_object_summary(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report);