Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> writes: >> The default diff backend tries to come up with minimal changes by spending >> extra cycles, so it is not so surprising if the file compared is large-ish >> and/or has very many similar lines in itself (in which case there are many >> potential matching line pairs between the preimage and the postimage to be >> examined to produce a minimal diff). > > But the file in this case is not that large, and "git diff" spends 30s! If the difference was literally between $ git diff branch -- file $ git show branch:file | diff -u - file that is, "file" is the name of a file in the top-level directory, I would expect that former would open the top-level tree object for the branch, read it thru until it finds "file", grabs a single blob and deflate it in core, and compare that with the contents of a single file read from the filesystem. An interesting comparison may be to run this once: $ git show branch:file >fileI and then compare between these two: $ diff -u fileI file $ git diff --no-index fileI file If the latter is slower than the former in the same way as the original experiment, that would mean that the tree traversal time does not have anything to do with it (iow, your "The way 'git diff' is now, it does that" is not just incorrect---we don't read the full tree to begin with---but irrelevant). If the "we try to come up with minimal changes by spending extra cycles" I mentioned in my messages is indeed the cause, you may see diffferences running the "git diff --no-index" version with backend options, e.g. $ git diff --no-index --patience fileI file $ git diff --no-index --histogram fileI file Another thing to try may be to run the version from "next" that has 27af01d (xdiff/xprepare: improve O(n*m) performance in xdl_cleanup_records(), 2011-08-17), without any backend options. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html