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: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id D8C771F5AE for ; Tue, 18 May 2021 07:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240896AbhERHnb (ORCPT ); Tue, 18 May 2021 03:43:31 -0400 Received: from cloud.peff.net ([104.130.231.41]:57492 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239746AbhERHnb (ORCPT ); Tue, 18 May 2021 03:43:31 -0400 Received: (qmail 11365 invoked by uid 109); 18 May 2021 07:42:12 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 18 May 2021 07:42:12 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 5470 invoked by uid 111); 18 May 2021 07:42:14 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 18 May 2021 03:42:14 -0400 Authentication-Results: peff.net; auth=none Date: Tue, 18 May 2021 03:42:11 -0400 From: Jeff King To: Derrick Stolee via GitGitGadget Cc: git@vger.kernel.org, gitster@pobox.com, stolee@gmail.com, git@jeffhostetler.com, Derrick Stolee , Derrick Stolee Subject: Re: [PATCH v2 2/4] csum-file.h: increase hashfile buffer size Message-ID: References: <9dc602f6c4221e2259778842ec3d1eda57508333.1621254292.git.gitgitgadget@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, May 18, 2021 at 03:31:28AM -0400, Jeff King wrote: > Does this have to use the same-size buffer? We could read and check > smaller chunks, like: > > while (count > 0) { > static unsigned char chunk[1024]; > unsigned int chunk_len = sizeof(chunk) < count ? sizeof(chunk) : count; > ssize_t ret = read_in_full(f->check_fd, chunk, chunk_len); > > if (ret < 0) > ... > if (ret != count) > ... > if (memcmp(buf, chunk, chunk_len)) > ... > buf += chunk_len; > count -= chunk_len; > } That should be "ret != chunk_len" in the middle conditional, of course. In case you do go this route (I typed this straight into my email, so other bugs may be lurking. But I noticed that one. :) ). -Peff