git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rm: only refresh entries that we may touch

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 17, 2010, 08:43 UTC
Message-ID
<1263717793-24009-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1263481341-28401-1-git-send-email-pclouds@gmail.com>

This gets rid of the whole tree cache refresh. Instead only path that we touch will get refreshed. We may still lstat() more than needed, but it'd be better playing safe.

This potentially reduces a large number of lstat() on big trees. Take gentoo-x86 tree for example, which has roughly 80k files:

Unmodified Git:

$ time git rm --cached skel.ebuild rm 'skel.ebuild'

real 0m1.441s user 0m0.821s sys 0m0.531s

Modified Git:

$ time ~/w/git/git rm --cached skel.ebuild rm 'skel.ebuild'

real 0m0.941s user 0m0.828s sys 0m0.091s

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 In the previous attempt, refresh_cache_entry() returns a new cache_entry.
 It does not modify the_index, so tests failed.
 builtin-rm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-rm.c b/builtin-rm.c
index 57975db..f3772c8 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -169,9 +169,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
 	if (read_cache() < 0)
 		die("index file corrupt");
-	refresh_cache(REFRESH_QUIET);
 
 	pathspec = get_pathspec(prefix, argv);
+	refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
+
 	seen = NULL;
 	for (i = 0; pathspec[i] ; i++)
 		/* nothing */;
-- 
1.6.6.181.g5ee6
Previous: Nguyen Thai Ngoc Duy
Message 10 of 10 in “Improve Git performance on big trees”
  1. 0/2 Improve Git performance on big treesNguyễn Thái Ngọc Duy, Jan 14, 2010
  2. 1/2 rm: only refresh entries that we may touchNguyễn Thái Ngọc Duy, Jan 14, 2010
  3. Junio C HamanoJan 16, 2010
  4. Nguyen Thai Ngoc DuyJan 16, 2010
  5. 2/2 status: only touch path we may need to checkNguyễn Thái Ngọc Duy, Jan 14, 2010
  6. Sverre RabbelierJan 14, 2010
  7. Junio C HamanoJan 16, 2010
  8. Martin LanghoffJan 14, 2010
  9. Nguyen Thai Ngoc DuyJan 15, 2010
  10. rm: only refresh entries that we may touchNguyễn Thái Ngọc Duy, Jan 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.