From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BA7581F523 for ; Mon, 26 Sep 2022 10:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664187436; bh=ok6XiOetwxgaigevie1YrIlzF1k/vkFpS9dEfQkrIKw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mQV2wFpfvN59J+LAd5YAGuDdnsvRWAGRij23V9lICJQO6Ivr2mSYSvgdyk/quJ4NC xRtkLbBCLp44KPhfwU31iKu9/45qHw6GGRmMwSfzjUe6T+I0Bajnab1K842jqXsWIU uK95z04cKAcbGdA1fGdK41jfXvjo5ECHclf7J6wk= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] git: reduce early bare-bones memory use Date: Mon, 26 Sep 2022 10:17:15 +0000 Message-Id: <20220926101715.1853-5-e@80x24.org> In-Reply-To: <20220926101715.1853-1-e@80x24.org> References: <20220926101715.1853-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The {-git_path} cache can rely on auto-vivification, and {alt_st} may not be needed for short-lived repos. So don't populate those fields until they're needed, since we can expect to handle thousands of git repos, too. --- lib/PublicInbox/Git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index b2ae75c8..9140caea 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -66,7 +66,7 @@ sub new { $git_dir =~ tr!/!/!s; $git_dir =~ s!/*\z!!s; # may contain {-tmp} field for File::Temp::Dir - bless { git_dir => $git_dir, alt_st => '', -git_path => {} }, $class + bless { git_dir => $git_dir }, $class } sub git_path ($$) { @@ -90,7 +90,7 @@ sub alternates_changed { # can't rely on 'q' on some 32-bit builds, but `d' works my $st = pack('dd', $st[10], $st[7]); # 10: ctime, 7: size - return 0 if $self->{alt_st} eq $st; + return 0 if ($self->{alt_st} // '') eq $st; $self->{alt_st} = $st; # always a true value }