All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Mironov via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Derrick Stolee <stolee@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Alex Mironov <alexandrfox@gmail.com>,
	Alex Mironov <alexandrfox@gmail.com>
Subject: [PATCH v2] name-hash: don't add sparse directories in threaded lazy init
Date: Wed, 21 May 2025 20:16:25 +0000	[thread overview]
Message-ID: <pull.1970.v2.git.git.1747858585623.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1970.git.git.1747827645129.gitgitgadget@gmail.com>

From: Alex Mironov <alexandrfox@gmail.com>

Ensure that logic added in 5f11669586 (name-hash: don't add directories
to name_hash, 2021-04-12) also applies in multithreaded hashtable init
path.

Sparse directory entries represent a directory that is outside the
sparse-checkout definition. These are not paths to blobs, so should not
be added to the name_hash table as they must never be queried.

Signed-off-by: Alex Mironov <alexandrfox@gmail.com>
---
    name-hash: don't add sparse directories in threaded lazy init
    
    Changes since v1:
    
     * addressed feedback (code-style)

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1970%2Falexandrfox%2Ffix-threaded-hash-name-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1970/alexandrfox/fix-threaded-hash-name-v2
Pull-Request: https://github.com/git/git/pull/1970

Range-diff vs v1:

 1:  d12ebc612c2 ! 1:  fb378147c73 name-hash: don't add sparse directories in threaded lazy init
     @@ Metadata
       ## Commit message ##
          name-hash: don't add sparse directories in threaded lazy init
      
     -    Similarly to 5f116695864788d1fe45ff06bfad7a71a8d98d0a
     -    make sure to avoid placing sparse directories into the name_hash
     -    hashtable whenever multithreaded initialization is performed.
     +    Ensure that logic added in 5f11669586 (name-hash: don't add directories
     +    to name_hash, 2021-04-12) also applies in multithreaded hashtable init
     +    path.
      
          Sparse directory entries represent a directory that is outside the
          sparse-checkout definition. These are not paths to blobs, so should not
     @@ name-hash.c: static void *lazy_name_thread_proc(void *_data)
       	for (k = 0; k < d->istate->cache_nr; k++) {
       		struct cache_entry *ce_k = d->istate->cache[k];
       		ce_k->ce_flags |= CE_HASHED;
     -+		if (S_ISSPARSEDIR(ce_k->ce_mode)) {
     -+			continue;
     +-		hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
     +-		hashmap_add(&d->istate->name_hash, &ce_k->ent);
     ++		if (!S_ISSPARSEDIR(ce_k->ce_mode)) {
     ++			hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
     ++			hashmap_add(&d->istate->name_hash, &ce_k->ent);
      +		}
     - 		hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
     - 		hashmap_add(&d->istate->name_hash, &ce_k->ent);
       	}
     + 
     + 	return NULL;


 name-hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/name-hash.c b/name-hash.c
index d66de1cdfd5..b91e2762678 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -492,8 +492,10 @@ static void *lazy_name_thread_proc(void *_data)
 	for (k = 0; k < d->istate->cache_nr; k++) {
 		struct cache_entry *ce_k = d->istate->cache[k];
 		ce_k->ce_flags |= CE_HASHED;
-		hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
-		hashmap_add(&d->istate->name_hash, &ce_k->ent);
+		if (!S_ISSPARSEDIR(ce_k->ce_mode)) {
+			hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
+			hashmap_add(&d->istate->name_hash, &ce_k->ent);
+		}
 	}
 
 	return NULL;

base-commit: 8613c2bb6cd16ef530dc5dd74d3b818a1ccbf1c0
-- 
gitgitgadget

  parent reply	other threads:[~2025-05-21 20:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 11:40 [PATCH] name-hash: don't add sparse directories in threaded lazy init Alex Mironov via GitGitGadget
2025-05-21 17:17 ` Derrick Stolee
2025-05-21 18:32   ` Junio C Hamano
2025-05-21 20:07   ` Alex Mironov
2025-05-21 20:16 ` Alex Mironov via GitGitGadget [this message]
2025-05-21 20:32   ` [PATCH v2] " Junio C Hamano
2025-05-21 20:37     ` Alex Mironov
2025-05-21 21:12       ` Junio C Hamano
2025-05-21 21:23         ` Junio C Hamano
2025-05-21 21:40           ` Alex Mironov
2025-05-21 21:29   ` [PATCH v3] " Alex Mironov via GitGitGadget
2025-05-21 21:47     ` Junio C Hamano
2025-05-22  1:48       ` Derrick Stolee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1970.v2.git.git.1747858585623.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=alexandrfox@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.