summaryrefslogtreecommitdiff
path: root/userdiff.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-04-02 00:12:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-04-02 07:05:31 (GMT)
commitd9bae1a178f0f8b198ea611e874975214ad6f990 (patch)
tree33918127aca49cf9c33f9d83371e4725641f5333 /userdiff.h
parent840383b2c2bd7179604f5c2595bf95e22a4e0c84 (diff)
downloadgit-d9bae1a178f0f8b198ea611e874975214ad6f990.zip
git-d9bae1a178f0f8b198ea611e874975214ad6f990.tar.gz
git-d9bae1a178f0f8b198ea611e874975214ad6f990.tar.bz2
diff: cache textconv output
Running a textconv filter can take a long time. It's particularly bad for a large file which needs to be spooled to disk, but even for small files, the fork+exec overhead can add up for something like "git log -p". This patch uses the notes-cache mechanism to keep a fast cache of textconv output. Caches are stored in refs/notes/textconv/$x, where $x is the userdiff driver defined in gitattributes. Caching is enabled only if diff.$x.cachetextconv is true. In my test repo, on a commit with 45 jpg and avi files changed and a textconv to show their exif tags: [before] $ time git show >/dev/null real 0m13.724s user 0m12.057s sys 0m1.624s [after, first run] $ git config diff.mfo.cachetextconv true $ time git show >/dev/null real 0m14.252s user 0m12.197s sys 0m1.800s [after, subsequent runs] $ time git show >/dev/null real 0m0.352s user 0m0.148s sys 0m0.200s So for a slight (3.8%) cost on the first run, we achieve an almost 40x speed up on subsequent runs. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.h')
-rw-r--r--userdiff.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/userdiff.h b/userdiff.h
index c315159..942d594 100644
--- a/userdiff.h
+++ b/userdiff.h
@@ -1,6 +1,8 @@
#ifndef USERDIFF_H
#define USERDIFF_H
+#include "notes-cache.h"
+
struct userdiff_funcname {
const char *pattern;
int cflags;
@@ -13,6 +15,8 @@ struct userdiff_driver {
struct userdiff_funcname funcname;
const char *word_regex;
const char *textconv;
+ struct notes_cache *textconv_cache;
+ int textconv_want_cache;
};
int userdiff_config(const char *k, const char *v);