From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 140EE1F55F for ; Fri, 29 Sep 2023 02:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1695955486; bh=x+V7mR4SpiOczrseAgYm66JH6zQ5x2lSulxmYzyHvsU=; h=From:To:Subject:Date:From; b=W9NGKG50tAn4lbS/U9YJQye0FKnHNx2EDDpsi/wlMKCsq6MQfqyiwkg2eiCsY+nCs NV1ZC7YXPi1UN3PTYLHiEWncjRMNlgYZUirT5fuFmR8bZIxK/UVpVeS7KPaq3CCE0P 2KptYckvqDSV8/p4ldjrES8wXQDYde4+hGBxY4vw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] git: calculate MAX_INFLIGHT properly in Perl Date: Fri, 29 Sep 2023 02:44:06 +0000 Message-ID: <20230929024406.88926-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Unlike C, Perl automatically converts quotients to double-precision floating point even with UV/IV numerators and denominators. So force the intermediate quotient to be an integer before multiplying it by the size of each inflight array element. This bug was inconsequential for all platforms since d4ba8828ab23f278 (git: fix asynchronous batching for deep pipelines, 2023-01-04) and inconsequential on most (or all?) Linux even before that due to the larger 4096-byte PIPE_BUF on Linux. --- lib/PublicInbox/Git.pm | 4 ++-- t/git.t | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 764e38d7..53887e3d 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -35,10 +35,10 @@ my @MODIFIED_DATE = qw[for-each-ref --sort=-committerdate --format=%(committerdate:raw) --count=1]; # 512: POSIX PIPE_BUF minimum (see pipe(7)) -# 3: @$inflight is flattened [ $OID, $cb, $arg ] # 65: SHA-256 hex size + "\n" in preparation for git using non-SHA1 +# 3: @$inflight is flattened [ $OID, $cb, $arg ] use constant { - MAX_INFLIGHT => 512 * 3 / (65 + length('contents ')), + MAX_INFLIGHT => int(512 / (65 + length('contents '))) * 3, BATCH_CMD_VER => v2.36.0, # git 2.36+ }; diff --git a/t/git.t b/t/git.t index dfa5eab2..bde6d35b 100644 --- a/t/git.t +++ b/t/git.t @@ -8,6 +8,8 @@ my ($dir, $for_destroy) = tmpdir(); use PublicInbox::Import; use POSIX qw(strftime); use PublicInbox::Git; +is(PublicInbox::Git::MAX_INFLIGHT, + int(PublicInbox::Git::MAX_INFLIGHT), 'MAX_INFLIGHT is an integer'); { PublicInbox::Import::init_bare($dir, 'master');