From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78610231A23 for ; Fri, 7 Aug 2026 21:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786137462; cv=none; b=S9H6hO5areC4P8AlGb4GDHifEFJHdw8ub4HVgH2rSKaZI8ae2WzyjlfSCAdbzDWl/YkFVVKi8FUN7vlGyAvyVR4pIHHigB4Yq63SZw45UQJqW9F6VBWOofZt3tLrerJwUPuc1wmu0vqKI7LZd1CqjhjduZ0sNcvBncM8aZ55SVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786137462; c=relaxed/simple; bh=ZF8Hyt1Wo60sI8DJhjULORtIoCTfCuYQ4G9jo+fyX1E=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=bw9LKiWzvik//EhMoqiy1lt4EvatAPFJQm/MzjoZoipbLr3xlIaRF+N4tXA9BDFYvOWdiouOgbTBRvkSVNhnS6RpxV1B5l3C1qxkSbgQ7Lkpjzq4Ale0I+pq+D9lHEcU8/+cR6ZqYJWjeFAxA01NNMx79/lLUIydgLoF7xYsc8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=DOiOADVX; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mXIPDEx5; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="DOiOADVX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mXIPDEx5" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id B658A7A015A; Fri, 7 Aug 2026 17:17:40 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-01.internal (MEProxy); Fri, 07 Aug 2026 17:17:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1786137460; x=1786223860; bh=T74NvYepvk CY+XotSOI7NmVp56ABSOi2sZWL2NTMJXU=; b=DOiOADVXTb0IvHdVDH7fZKHCK8 yOsaQkq2JDasFG8xgXSudcagG3s+DIK3NKrZfQOkk6MmPSzrgr15N2w8E83rb1Oy NSZU2y8fybHX8VBj29jR1+uVlL2Abjm7SZLtkmlvAAR7GwY4zYgncvowr9rHH9/Y 9bSt9Hor4Cm0bXGM8IfFHb6QurMNK3QGctovQz1jfcYTElCW5Q885Im1579xSLny 5aWqA/JpBJwydjzFU5HfnMlKlIqSYD4AVd3tC9nnhQQ4b/hCoFccXLq6WOb4iWsG VeDXE6EzJAh1ULHLV4H+NwRazzuWIlYFbLi/+LfL5xIGfqJ9z4rc2Mxmb95g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1786137460; x=1786223860; bh=T74NvYepvkCY+Xot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V2r4Nk6wsl4SmhwyGkOUw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Aug 2026 17:17:40 -0400 (EDT) From: Junio C Hamano To: "D. Ben Knoble" Cc: git@vger.kernel.org, Tian Yuchen , Todd Zullinger , Patrick Steinhardt , Olamide Caleb Bello Subject: Re: [PATCH 3/3] core: convert build-time USE_NSEC into runtime core.useNanosec In-Reply-To: (D. Ben Knoble's message of "Fri, 7 Aug 2026 07:56:26 -0400") References: Date: Fri, 07 Aug 2026 14:17:39 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "D. Ben Knoble" writes: > Racy Git problems persist today, manifesting themselves in the > performance of commands like "git diff" in new worktrees [1]. We have > long had a build knob "USE_NSEC" to tell Git to use in-core nanosecond > precision when available, which mitigates most if not all racy issues, > but most builds we know about it don't use it. In part, that's because > someone distributing Git can't safely enable it at compile-time if they > don't know exactly what platforms their distribution will be used on. > > [1]: https://lore.kernel.org/git/CALnO6CADMJSixqYvL1Yo8qKX5rWhKQ+2OoSEuPUh-yoeK9TseQ@mail.gmail.com > > These days, most platforms are likely to be safe for the USE_NSEC code. > Regardless, we want to give users the ability to benefit from it. This > requires exposing the compile-time gated code as a runtime option. > > In addition, update the Racy Git documentation and other mentions of > USE_NSEC in the code. > > Best-viewed-with: --ignore-space-change Don't do this. It probably is helpful to have something like that below the three-dash lines, though. > Signed-off-by: D. Ben Knoble > --- > diff --git a/environment.c b/environment.c > index 6676e6f5ae..e6a50060e8 100644 > --- a/environment.c > +++ b/environment.c > @@ -571,6 +571,11 @@ int git_default_core_config(const char *var, const char *value, > return 0; > } > > + if (!strcmp(var, "core.usenanosec")) { > + cfg->use_nanosec = git_config_bool(var, value); > + return 0; > + } OK. > diff --git a/read-cache.c b/read-cache.c > index 6c449f393d..297646c357 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -353,15 +353,16 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st) > static int is_racy_stat(const struct index_state *istate, > const struct stat_data *sd) > { > + int use_nsec = 0; > + repo_config_get_bool(the_repository, "core.useNanosec", &use_nsec); Yeek. Isn't this a relatively hot code path? If it is, it is criminal to force string parsing and matching like this, every time somebody calls the function. Doesn't istate know what repository it is working with and in there you should be able find its repo_settings struct cheaply, no?