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

[PATCH 5/4] Minimum fixups to cache-tree

From
Junio C Hamano <junkio@cox.net>
Date
Apr 24, 2006, 03:03 UTC
Message-ID
<7v8xpvd69s.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7vodyrdas9.fsf@assigned-by-dhcp.cox.net>

The first hunk is the repeat of the previous "oops". The second is a real fix.

With this applied, 100-patch series (going from present to past at the Linux 2.6 kernel tip) applies correctly with the following stats:

Trying w/o the patch... 24.57user 4.48system 0:34.47elapsed 84%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+322156minor)pagefaults 0swaps Trying w/ the patch... 15.81user 3.00system 0:20.84elapsed 90%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+252063minor)pagefaults 0swaps

So there definitely is an improvement.  *Grin*.

The script used to bench this is attached at the end. "linus" is the tracking branch and currently it points at v2.6.17-rc2-g6b426e7 $HOME/git-master/bin is where I installed the "master" version, and $J (aka ../git.junio/) is the freshly compiled area with the patch series applied (all five of four ;-).

-- >8 -- Minimum fixups to make things usable.

---
diff --git a/apply.c b/apply.c
index 5fa2c1e..e283df3 100644
--- a/apply.c
+++ b/apply.c
@@ -1935,8 +1935,6 @@ static int apply_patch(int fd, const cha
 				  active_cache_sha1) ||
 		    commit_index_file(&cache_file))
 			die("Unable to write new cachefile");
-		cache_tree_update(active_cache_tree,
-				  active_cache, active_nr, 1);
 		write_cache_tree(active_cache_sha1, active_cache_tree);
 	}
 
diff --git a/cache-tree.c b/cache-tree.c
index 4dbdb65..f6d1dd1 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -348,10 +348,7 @@ #endif
 	}
 	for (i = 0; i < it->subtree_nr; i++) {
 		struct cache_tree_sub *down = it->down[i];
-		int len = pathlen + down->namelen;
-		memcpy(path + pathlen, down->name, down->namelen);
-		path[len] = '/';
-		buffer = write_one(down->cache_tree, path, len+1,
+		buffer = write_one(down->cache_tree, down->name, down->namelen,
 				   buffer, size, offset);
 	}
 	return buffer;

--

#!/bin/sh
J=../git.junio
M=$HOME/git-master/bin
export J M

git reset --hard linus

previous=
git rev-list -n 100 HEAD |
while read commit
do
	if test -n "$previous"
	then
		git-diff-tree -p "$previous" "$commit" >"$commit-$previous"
		echo "$commit $previous"
	fi
	previous="$commit"
done >series

git reset --hard linus
echo "Trying w/o the patch..."
/usr/bin/time sh -c '
	while read commit previous
	do
		$M/git-apply --whitespace=nowarn --index "$commit-$previous"
		$M/git-write-tree
	done <series
' >out-1
tree1=`git write-tree`

git reset --hard linus
echo "Trying w/ the patch..."
$J/git-write-tree
/usr/bin/time sh -c '
	while read commit previous
	do
		$J/git-apply --whitespace=nowarn --index "$commit-$previous"
		$J/git-write-tree
	done <series
' >out-2
tree2=`git write-tree`
test "$tree1" = "$tree2" || exit 1
cmp out-1 out-2
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 8 in “Invalidate cache-tree entries for touched paths in git-apply.”
  1. 4/4 Invalidate cache-tree entries for touched paths in git-apply.Junio C Hamano, Apr 23, 2006
  2. Junio C HamanoApr 24, 2006
  3. Junio C HamanoApr 24, 2006
  4. 5/4 Minimum fixups to cache-treeJunio C Hamano, Apr 24, 2006
  5. 50% speed-up of "git-apply && git-write-tree" sequence.Junio C Hamano, Apr 24, 2006
  6. maintenance of cache-tree dataJunio C Hamano, Apr 24, 2006
  7. Junio C HamanoApr 24, 2006
  8. Junio C HamanoApr 25, 2006

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.