From patchwork Tue Oct 2 14:58:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 10623811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A862015A6 for ; Tue, 2 Oct 2018 14:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995A720246 for ; Tue, 2 Oct 2018 14:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DD1A20408; Tue, 2 Oct 2018 14:58:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F12C0203B9 for ; Tue, 2 Oct 2018 14:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729077AbeJBVmh (ORCPT ); Tue, 2 Oct 2018 17:42:37 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38816 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728979AbeJBVmg (ORCPT ); Tue, 2 Oct 2018 17:42:36 -0400 Received: by mail-pl1-f196.google.com with SMTP id b5-v6so1824333plr.5 for ; Tue, 02 Oct 2018 07:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=rDJX4HTSVABF8MGpNvGjFcQY2O4XlSDRvIpNMXEFdhw=; b=q7d7BdWibBdUlJrXfWJFRFWXiV0sqdIMyNXsW0aERLXb2NbrBufNpKyDEXgPI1tq3q vQpjVrnV894G8gQE9UtxKl/YjXS/SzgyYC6dYA23pKXCjnUgf44AgbM7754lxtioWGyv naU3xbIQ276HGIDNKKyIR9oI0ZSVcN7lbYRWDs+sDCK9OZAHa8Df+poP/PEUM7uaHdxY ylOSVoPl2sjz5W/gu+O7UM9Q/U6K9FuOpD+5vnL3Fi1xlW1krhYZDs3/0Ixabg5nmcWr Rn6/vGIzTunuE6KVQZVV9UdUzeZ+bzVg9LNoqkxJT8v89DOxyKCscOyZWuxxXDMCgJKW ANwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=rDJX4HTSVABF8MGpNvGjFcQY2O4XlSDRvIpNMXEFdhw=; b=nZRycoLZ7F2qIgxu+AH9eswUyE6z9smMr2NSCWeC1prDe85y/zW9Eak6mfFujOEsVO E5weLpP66l/uwLrECfzL0mIs/F4iJFcvcA9mXKsnOjwm/xvhhP+vHFcRBR/GdQq2Fa06 /dFKschUmFAtmxxWC7jW6i96fzt5PwLnaciejFkJ9PGrOrSk5EtgcyX0fo1OV20mLI/V G4yPXPu0Fq+LX6XVGYAwJSKOOKik/CyCmaaWsiMmx6Qv7kg9inJtLihrM8n8rT20qF0N B3cJ4Ne8Rx7YLJnvZHUk1TJm2LSrQcWD3dh18rueJMlgsj+Tu4fiHjKZdYiz8NU4/3/4 qGKQ== X-Gm-Message-State: ABuFfojKYQVzn0VMnpXlvZBhrTgXFLXPGi2FPSPoTRj+CwcG1pS3r65o 82El44nak3YuvDOW2Pg6CVcXmjgy X-Google-Smtp-Source: ACcGV620r87VSW6/HN5S2eaGmCbQ3rZdeF37JOVrSr+0yhX68rVPKA8oct3LLklmmiwHy347RtjnaQ== X-Received: by 2002:a17:902:29e3:: with SMTP id h90-v6mr17174015plb.215.1538492327531; Tue, 02 Oct 2018 07:58:47 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id w23-v6sm22060861pgi.18.2018.10.02.07.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 07:58:46 -0700 (PDT) Date: Tue, 02 Oct 2018 07:58:46 -0700 (PDT) X-Google-Original-Date: Tue, 02 Oct 2018 14:58:41 GMT Message-Id: In-Reply-To: References: From: "Derrick Stolee via GitGitGadget" Subject: [PATCH 2/2] commit-graph: reduce initial oid allocation Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Derrick Stolee While writing a commit-graph file, we store the full list of commits in a flat list. We use this list for sorting and ensuring we are closed under reachability. The initial allocation assumed that (at most) one in four objects is a commit. This is a dramatic over-count for many repos, especially large ones. Since we grow the repo dynamically, reduce this count by a factor of eight. We still set it to a minimum of 1024 before allocating. Signed-off-by: Derrick Stolee --- commit-graph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-graph.c b/commit-graph.c index 7226bd6b58..a24cceb55f 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -721,7 +721,7 @@ void write_commit_graph(const char *obj_dir, struct progress *progress = NULL; oids.nr = 0; - oids.alloc = approximate_object_count() / 4; + oids.alloc = approximate_object_count() / 32; oids.progress = NULL; oids.progress_done = 0;