From patchwork Wed Oct 3 17:12:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jean-No=C3=ABl_Avila_via_GitGitGadget?= X-Patchwork-Id: 10625117 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 780E217E0 for ; Wed, 3 Oct 2018 17:12:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C8ED28F1C for ; Wed, 3 Oct 2018 17:12:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5154728F28; Wed, 3 Oct 2018 17:12:22 +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 EA64528F1C for ; Wed, 3 Oct 2018 17:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbeJDABh (ORCPT ); Wed, 3 Oct 2018 20:01:37 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34148 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbeJDABg (ORCPT ); Wed, 3 Oct 2018 20:01:36 -0400 Received: by mail-pl1-f194.google.com with SMTP id f18-v6so3778412plr.1 for ; Wed, 03 Oct 2018 10:12:20 -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=VuotZzHgDMRiVrQhM09A8eBcul7JL+o4OMz5phJz6yc=; b=AHP9e16/dT7bCgIGciuk7kWowsGCTSfnZsRlOU0r+fL6tcGHLeJ1SScKmCGSFlZV2P dJRsM4KuLieJwq3IDfnnLenHTXnyPyPgjk+WEs3u2t858VgZVrcrYG8ICKgjkX11WLuj wConWT2itKSvn9qgVC3eBy/aS3kbxLNRu7CorOiUrjD3MD4zNYokrR6Qy7Fw9CR7dYVI sAIsTa4af5gLsgfZineR3xcorJ3KX609ALd9mqbZ1FPKVlba9j8U+Y4RGZgzZwTjjiSH 8r0cGGKPF/Zx4az1YtWlbDz/eBiCvq0MaHbBVd+809qTrvTX71HjVv6tN4KKRIKu3V7F 2yYQ== 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=VuotZzHgDMRiVrQhM09A8eBcul7JL+o4OMz5phJz6yc=; b=CTylfgA6j2AaTrMyon4INDz4B4H3yBo3bHGvuaj0ILbDNWDxvwqDVdlsVWEAdtyln2 OkTR3wm3QmhJHtsyPZKfKmIiwCzX5A7I+R/RQaEGEsZBFQZky9RSph9E5mH/ukJ5LLAW ISvFwWwnkfX3DnHOyXybsN3ZKikDrqbDXe6mjjuP9V6WEag4m0EC40Ld27J/FgJRQer+ DkwMP2MdkntOeNt4V4pFDLStYx9R37oZqTqyZ18HEE/KOs9zuSBWrWsan7Opy02HBp+6 3tDL3QTKhysI+vOqwqeY+pmFarPPIFbpGMVdPBkbBah7+RYYcAoqZvmK/z36xY8MzS/6 5Xvg== X-Gm-Message-State: ABuFfoh4v/+SaSSjIb+vDJVK43grzNUbB5KGiB2HoDFvv0jTRgao9fEV 0Lz8ERUxGj4d/8z3Y6RJajvryO3G X-Google-Smtp-Source: ACcGV60MnCHe6eH35Swu40YPxTpz91yPq7g2MifRahqulowuNr+3HhWcNrqYSVs4v1coptpuuxmehQ== X-Received: by 2002:a17:902:447:: with SMTP id 65-v6mr2556605ple.325.1538586740047; Wed, 03 Oct 2018 10:12:20 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id g17-v6sm3437090pfe.37.2018.10.03.10.12.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 10:12:19 -0700 (PDT) Date: Wed, 03 Oct 2018 10:12:19 -0700 (PDT) X-Google-Original-Date: Wed, 03 Oct 2018 17:12:12 GMT Message-Id: <1002fd34fc57e929265d07ad6e6010116b27b7a9.1538586732.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Derrick Stolee via GitGitGadget" Subject: [PATCH v2 3/3] 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 ceca6026b0..e773703e1d 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -720,7 +720,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;