Skip to contentSkip to conversation

Use watchman to reduce index refresh time

PATCH In review Nguyễn Thái Ngọc Duy 4 participants 17 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Use watchman to reduce index refresh time

This series builds on top of the index-helper series I just sent and uses watchman to keep track of file changes in order to avoid lstat() at refresh time. The series can also be found at [1]

When I started this work, watchman did not support Windows yet. It does now, even if still experimental [2]. So Windows people, please try it out if you have time.

To put all pieces so far together, we have split-index to reduce index write time, untracked cache to reduce I/O as well as computation for .gitignore, index-helper for index read time and this series for lstat() at refresh time. The remaining piece is killing lstat() from untracked cache, but right now it's just some idea and incomplete code.

[1] https://github.com/pclouds/git/commits/refresh-with-watchman
[2] https://github.com/facebook/watchman/issues/19

Nguyễn Thái Ngọc Duy (5):
read-cache: add watchman 'WAMA' extension
Add watchman support to reduce index refresh cost
read-cache: allow index-helper to prepare shm before git reads it
index-helper: use watchman to avoid refreshing index with lstat()
update-index: enable/disable watchman support

 Makefile                 |  12 +++++
 builtin/update-index.c   |  11 +++++
 cache.h                  |   7 +++
 config.c                 |   5 ++
 configure.ac             |   8 +++
 environment.c            |   3 ++
 index-helper.c           |  84 +++++++++++++++++++++++++++++--
 read-cache.c             | 126 ++++++++++++++++++++++++++++++++++++++++++++---
 watchman-support.c (new) | 108 ++++++++++++++++++++++++++++++++++++++++
 watchman-support.h (new) |   7 +++
 10 files changed, 361 insertions(+), 10 deletions(-)
 create mode 100644 watchman-support.c
 create mode 100644 watchman-support.h
Signature · 1 line
2.2.0.513.g477eb31
#1 lore raw

PATCH 1/5 read-cache: add watchman 'WAMA' extension

The extension contains a bitmap, one bit for each entry in the index. If the n-th bit is zero, the n-th entry is considered unchanged, we can ce_mark_uptodate() it without refreshing. If the bit is non-zero and we found out the corresponding file is clean after refresh, we can clear the bit.

The 'skipping refresh' bit is not in this patch yet as we would need watchman. More details in later patches.

---
 cache.h      |  4 ++++
 read-cache.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 73 insertions(+), 2 deletions(-)
cache.h +4 -0
index 9633acc..a05fd31 100644
@@ -163,6 +163,8 @@ struct cache_entry {
 #define CE_VALID     (0x8000)
 #define CE_STAGESHIFT 12
 
+#define CE_NO_WATCH  (0x0001)
+
 /*
  * Range 0xFFFF0FFF in ce_flags is divided into
  * two parts: in-memory flags and on-disk ones.
@@ -298,6 +300,7 @@ static inline unsigned int canon_mode(unsigned int mode)
 #define CACHE_TREE_CHANGED	(1 << 5)
 #define SPLIT_INDEX_ORDERED	(1 << 6)
 #define UNTRACKED_CHANGED	(1 << 7)
+#define WATCHMAN_CHANGED	(1 << 8)
 
 struct split_index;
 struct untracked_cache;
@@ -322,6 +325,7 @@ struct index_state {
 	struct untracked_cache *untracked;
 	void *mmap;
 	size_t mmap_size;
+	char *last_update;
 };
 
 extern struct index_state the_index;
read-cache.c +69 -2

118 lines not on this page · raw message

Signature · 1 line
2.2.0.513.g477eb31
#5 lore raw

PATCH 2/5 Add watchman support to reduce index refresh cost

In reply to Nguyễn Thái Ngọc Duy

The previous patch has the logic to clear bits in 'WAMA' bitmap. This patch has logic to set bits as told by watchman. The missing bit, _using_ these bits, are not here yet.

A lot of this code is written by David Turner originally, mostly from [1]. I'm just copying and polishing it a bit.

[1] http://article.gmane.org/gmane.comp.version-control.git/248006

---
 Makefile                 |   7 +++
 cache.h                  |   1 +
 config.c                 |   5 +++
 configure.ac             |   8 ++++
 environment.c            |   3 ++
 watchman-support.c (new) | 108 +++++++++++++++++++++++++++++++++++++++++++++++
 watchman-support.h (new) |   8 ++++
 7 files changed, 140 insertions(+)
 create mode 100644 watchman-support.c
 create mode 100644 watchman-support.h
Makefile +7 -0
index c01cd2e..761acb6 100644
@@ -1389,6 +1389,12 @@ else
 	LIB_OBJS += thread-utils.o
 endif
 
+ifdef USE_WATCHMAN
+	LIB_H += watchman-support.h
+	LIB_OBJS += watchman-support.o
+	BASIC_CFLAGS += -DUSE_WATCHMAN
+endif
+
 ifdef HAVE_PATHS_H
 	BASIC_CFLAGS += -DHAVE_PATHS_H
 endif
@@ -2135,6 +2141,7 @@ GIT-BUILD-OPTIONS: FORCE
 	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
 	@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
 	@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
+	@echo USE_WATCHMAN=\''$(subst ','\'',$(subst ','\'',$(USE_WATCHMAN)))'\' >>$@+
 ifdef TEST_OUTPUT_DIRECTORY
 	@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
 endif
cache.h +1 -0
index a05fd31..572299c 100644
@@ -648,6 +648,7 @@ extern char *git_replace_ref_base;
 
 extern int fsync_object_files;
 extern int core_preload_index;
+extern int core_watchman_sync_timeout;
 extern int core_apply_sparse_checkout;
 extern int precomposed_unicode;
 extern int protect_hfs;
config.c +5 -0
index 248a21a..6b63f66 100644
@@ -881,6 +881,11 @@ static int git_default_core_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "core.watchmansynctimeout")) {
+		core_watchman_sync_timeout = git_config_int(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "core.createobject")) {
 		if (!strcmp(value, "rename"))
 			object_creation_mode = OBJECT_CREATION_USES_RENAMES;
configure.ac +8 -0
index 76170ad..9772f79 100644
@@ -1092,6 +1092,14 @@ AC_COMPILE_IFELSE([BSD_SYSCTL_SRC],
 	HAVE_BSD_SYSCTL=])
 GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
 
+#
+# Check for watchman client library
+
+AC_CHECK_LIB([watchman], [watchman_connect],
+	[USE_WATCHMAN=YesPlease],
+	[USE_WATCHMAN=])
+GIT_CONF_SUBST([USE_WATCHMAN])
+
 ## Other checks.
 # Define USE_PIC if you need the main git objects to be built with -fPIC
 # in order to build and link perl/Git.so.  x86-64 seems to need this.
environment.c +3 -0
index 2da7fe2..84df431 100644
@@ -87,6 +87,9 @@ int auto_comment_line_char;
 /* Parallel index stat data preload? */
 int core_preload_index = 1;
 
+int core_watchman_sync_timeout = 300;
+
+
 /* This is set by setup_git_dir_gently() and/or git_default_config() */
 char *git_work_tree_cfg;
 static char *work_tree;
watchman-support.c new file +108 -0

108 lines not on this page · raw message

watchman-support.h new file +8 -0
new file mode 100644
index 0000000..5610409
@@ -0,0 +1,8 @@
+#ifndef WATCHMAN_SUPPORT_H
+#define WATCHMAN_SUPPORT_H
+
+struct index_state;
+int check_watchman(struct index_state *index);
+
+
+#endif /* WATCHMAN_SUPPORT_H */
Signature · 1 line
2.2.0.513.g477eb31
#7 lore raw

PATCH 3/5 read-cache: allow index-helper to prepare shm before git reads it

In reply to Nguyễn Thái Ngọc Duy

If index-helper puts 'W' before pid in $GIT_DIR/index-helper.pid, then git will sleep for a while, expecting to be waken up by SIGUSR1 when index-helper has done shm preparation, or after the timeout.

---
 read-cache.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
read-cache.c +12 -2
index 893223e..ae33951 100644
@@ -1591,14 +1591,24 @@ static void do_poke(struct strbuf *sb, int refresh_cache)
 	PostMessage(hwnd, refresh_cache ? WM_USER : WM_USER + 1, 0, 0);
 }
 #else
+static void do_nothing(int sig)
+{
+}
+
 static void do_poke(struct strbuf *sb, int refresh_cache)
 {
-	char	*start = sb->buf;
+	int	 wait  = sb->buf[0] == 'W';
+	char	*start = wait ? sb->buf + 1 : sb->buf;
 	char	*end   = NULL;
 	pid_t	 pid   = strtoul(start, &end, 10);
+	int	 ret;
 	if (!end || end != sb->buf + sb->len)
 		return;
-	kill(pid, refresh_cache ? SIGHUP : SIGUSR1);
+	ret = kill(pid, refresh_cache ? SIGHUP : SIGUSR1);
+	if (!refresh_cache && !ret && wait) {
+		signal(SIGHUP, do_nothing);
+		sleep(1);
+	}
 }
 #endif
 
Signature · 1 line
2.2.0.513.g477eb31
#8 lore raw

PATCH 4/5 index-helper: use watchman to avoid refreshing index with lstat()

In reply to Nguyễn Thái Ngọc Duy

Watchman is hidden behind index-helper. Before git tries to read the index from shm, it notifies index-helper with SIGHUP and sleep, waiting for index-helper to prepare shm. index-helper then contacts watchman, updates 'WAMA' extension and put it in a separate shm and wakes git up with SIGHUP.

Git uses this extension to not lstat unchanged entries. Git only trust 'WAMA' extension when it's received from the separate shm, not from disk. Unmarked entries are "clean". Marked entries are dirty from watchman point of view. If it finds out some entries are 'watchman-dirty', but are really unchanged (e.g. the file was changed, then reverted back), then Git will clear the marking in 'WAMA' before writing it down.

Hiding watchman behind index-helper means you need both daemons. You can't run watchman alone. Not so good. But on the other hand, 'git' binary is not linked to watchman/json libraries, which is good for packaging. Core git package will run fine without watchman-related packages. If they need watchman, they can install git-index-helper and dependencies.

Another reason for tying watchman to index-helper is, when used with untracked cache, we need to keep track of $GIT_WORK_TREE file listing. That kind of list can be kept in index-helper.

---
 Makefile           |  5 ++++
 cache.h            |  2 ++
 index-helper.c     | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 read-cache.c       | 43 ++++++++++++++++++++++++++--
 watchman-support.h |  1 -
 5 files changed, 127 insertions(+), 8 deletions(-)
Makefile +5 -0
index 761acb6..3f5eac8 100644
@@ -434,6 +434,7 @@ MSGFMT = msgfmt
 CURL_CONFIG = curl-config
 PTHREAD_LIBS = -lpthread
 PTHREAD_CFLAGS =
+WATCHMAN_LIBS =
 GCOV = gcov
 
 export TCL_PATH TCLTK_PATH
@@ -1392,6 +1393,7 @@ endif
 ifdef USE_WATCHMAN
 	LIB_H += watchman-support.h
 	LIB_OBJS += watchman-support.o
+	WATCHMAN_LIBS = -lwatchman
 	BASIC_CFLAGS += -DUSE_WATCHMAN
 endif
 
@@ -2005,6 +2007,9 @@ git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
 	$(VCSSVN_LIB)
 
+git-index-helper$X: index-helper.o GIT-LDFLAGS $(GITLIBS)
+	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) $(WATCHMAN_LIBS)
+
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	$(QUIET_LNCP)$(RM) $@ && \
 	ln $< $@ 2>/dev/null || \
cache.h +2 -0
index 572299c..c04141b 100644
@@ -518,6 +518,7 @@ extern int daemonize(int *);
 
 /* Initialize and use the cache information */
 struct lock_file;
+extern int verify_index(const struct index_state *);
 extern int read_index(struct index_state *);
 extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
 extern int do_read_index(struct index_state *istate, const char *path,
@@ -525,6 +526,7 @@ extern int do_read_index(struct index_state *istate, const char *path,
 extern int read_index_from(struct index_state *, const char *path);
 extern int is_index_unborn(struct index_state *);
 extern int read_index_unmerged(struct index_state *);
+extern void write_watchman_ext(struct strbuf *sb, struct index_state* istate);
 #define COMMIT_LOCK		(1 << 0)
 #define CLOSE_LOCK		(1 << 1)
 #define REFRESH_DAEMON		(1 << 2)
index-helper.c +80 -4

142 lines not on this page · raw message

read-cache.c +40 -3

73 lines not on this page · raw message

watchman-support.h +0 -1
index 5610409..ee1ef2c 100644
@@ -4,5 +4,4 @@
 struct index_state;
 int check_watchman(struct index_state *index);
 
-
 #endif /* WATCHMAN_SUPPORT_H */
Signature · 1 line
2.2.0.513.g477eb31
#9 lore raw

PATCH 5/5 update-index: enable/disable watchman support

In reply to Nguyễn Thái Ngọc Duy
---
 builtin/update-index.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
builtin/update-index.c +11 -0
index 7431938..86aec21 100644
@@ -903,6 +903,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 {
 	int newfd, entries, has_errors = 0, line_termination = '\n';
 	int untracked_cache = -1;
+	int use_watchman = -1;
 	int read_from_stdin = 0;
 	int prefix_length = prefix ? strlen(prefix) : 0;
 	int preferred_index_format = 0;
@@ -998,6 +999,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 			N_("enable/disable untracked cache")),
 		OPT_SET_INT(0, "force-untracked-cache", &untracked_cache,
 			    N_("enable untracked cache without testing the filesystem"), 2),
+		OPT_BOOL(0, "watchman", &use_watchman,
+			N_("use or not use watchman to reduce refresh cost")),
 		OPT_END()
 	};
 
@@ -1127,6 +1130,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 		the_index.cache_changed |= UNTRACKED_CHANGED;
 	}
 
+	if (use_watchman > 0) {
+		the_index.last_update    = xstrdup("");
+		the_index.cache_changed |= WATCHMAN_CHANGED;
+	} else if (!use_watchman) {
+		the_index.last_update    = NULL;
+		the_index.cache_changed |= WATCHMAN_CHANGED;
+	}
+
 	if (active_cache_changed) {
 		if (newfd < 0) {
 			if (refresh_args.flags & REFRESH_QUIET)
Signature · 1 line
2.2.0.513.g477eb31
#2 lore raw

Re: [PATCH 1/5] read-cache: add watchman 'WAMA' extension

In reply to Nguyễn Thái Ngọc Duy
Quoted 2 lines · Nguyễn Thái Ngọc Duy

+#define CE_NO_WATCH (0x0001)

This name seems very confusing to me. CE_NO_WATCHMAN_STAT? CE_UNKNOWN_TO_WATCHMAN?

(one reason it may seem more confusing to me than to others is that Twitter's code has a concept of files that we don't watch at all e.g. Intellij's .idea dir).

cache.h struct index_state { · line 328

Quoted 5 lines
cache.h +1 -0
@@ -322,6 +325,7 @@ struct index_state {
 	struct untracked_cache *untracked;
 	void *mmap;
 	size_t mmap_size;
+	char *last_update;

Might be worth a comment explaining what this is.

#6 lore raw

Re: [PATCH 2/5] Add watchman support to reduce index refresh cost

In reply to Nguyễn Thái Ngọc Duy
Quoted 8 lines · Nguyễn Thái Ngọc Duy

The previous patch has the logic to clear bits in 'WAMA' bitmap. This patch has logic to set bits as told by watchman. The missing bit, _using_ these bits, are not here yet.

A lot of this code is written by David Turner originally, mostly from [1]. I'm just copying and polishing it a bit.

[1] http://article.gmane.org/gmane.comp.version-control.git/248006

Our code has evolved somewhat from there[1]. It looks like you've incorporated some of these updates. But I wanted to call out one thing in particular that it doesn't look like this patch handles: there's some real ugliness on at least OSX around case-changing renames.

You probably won't be able to use our code directly as-is, but we'll want to do something about this situation. This is thicket of TOCTOU issues. For instance, watchman learns that a file called FOO has changed, but by the time it goes to the filesystem to look up the canonical case, FOO has been renamed to foo already (or renamed and then deleted).

I won't say for sure that your code is insufficient as I haven't yet tried it out, but we should ensure this case is handled before this is merged.

[1] https://github.com/dturner-tw/git/tree/dturner/watchman

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+		pos = index_name_pos(istate, wm->name, strlen(wm->name));

This is the bit where case matters.

#10 lore raw
In reply to Nguyễn Thái Ngọc Duy

On Sun, Nov 1, 2015 at 2:55 PM, Nguyễn Thái Ngọc Duy <[email protected]> wrote:

Hi Duy,

Quoted 8 lines

This series builds on top of the index-helper series I just sent and uses watchman to keep track of file changes in order to avoid lstat() at refresh time. The series can also be found at [1]

When I started this work, watchman did not support Windows yet. It does now, even if still experimental [2]. So Windows people, please try it out if you have time.

Quoted 6 lines

To put all pieces so far together, we have split-index to reduce index write time, untracked cache to reduce I/O as well as computation for .gitignore, index-helper for index read time and this series for lstat() at refresh time. The remaining piece is killing lstat() from untracked cache, but right now it's just some idea and incomplete code.

Did you manage to measure the speedup introduced by this series?

Ciao,

Signature · 1 line
Paolo
author
#11 lore raw
Quoted 12 lines · Paolo Ciarrocchi

On Sun, Nov 1, 2015 at 2:55 PM, Nguyễn Thái Ngọc Duy <[email protected]> wrote:

Hi Duy,

Quoted 8 lines

This series builds on top of the index-helper series I just sent and uses watchman to keep track of file changes in order to avoid lstat() at refresh time. The series can also be found at [1]

When I started this work, watchman did not support Windows yet. It does now, even if still experimental [2]. So Windows people, please try it out if you have time.

Quoted 8 lines
Quoted 6 lines

To put all pieces so far together, we have split-index to reduce index write time, untracked cache to reduce I/O as well as computation for .gitignore, index-helper for index read time and this series for lstat() at refresh time. The remaining piece is killing lstat() from untracked cache, but right now it's just some idea and incomplete code.

Did you manage to measure the speedup introduced by this series?

It was from last year. I may have measured it but because I didn't save it in the commit message, it was lost anyway. Installing watchman and measuring with webkit.git soon..

Signature · 1 line
Duy
author
#3 lore raw

Re: [PATCH 1/5] read-cache: add watchman 'WAMA' extension

In reply to David Turner
Quoted 6 lines · David Turner
Quoted 2 lines · Nguyễn Thái Ngọc Duy

+#define CE_NO_WATCH (0x0001)

This name seems very confusing to me. CE_NO_WATCHMAN_STAT? CE_UNKNOWN_TO_WATCHMAN?

Files that are known updated. Maybe CE_WATCHMAN_DIRTY?

Quoted 11 lines

(one reason it may seem more confusing to me than to others is that Twitter's code has a concept of files that we don't watch at all e.g. Intellij's .idea dir).

cache.h struct index_state { · line 328

Quoted 5 lines
cache.h +1 -0
@@ -322,6 +325,7 @@ struct index_state {
      struct untracked_cache *untracked;
      void *mmap;
      size_t mmap_size;
+     char *last_update;

Might be worth a comment explaining what this is.

It's the clock value from watchman when we query file status. Will make a note. Or maybe I should just rename it to watchman_clock.

Signature · 1 line
Duy
#4 lore raw

Re: [PATCH 1/5] read-cache: add watchman 'WAMA' extension

Quoted 9 lines · Duy Nguyen
Quoted 6 lines · David Turner
Quoted 2 lines · Nguyễn Thái Ngọc Duy

+#define CE_NO_WATCH (0x0001)

This name seems very confusing to me. CE_NO_WATCHMAN_STAT? CE_UNKNOWN_TO_WATCHMAN?

Files that are known updated. Maybe CE_WATCHMAN_DIRTY?

+1

Quoted 12 lines
Quoted 11 lines

(one reason it may seem more confusing to me than to others is that Twitter's code has a concept of files that we don't watch at all e.g. Intellij's .idea dir).

cache.h struct index_state { · line 328

Quoted 5 lines
cache.h +1 -0
@@ -322,6 +325,7 @@ struct index_state {
      struct untracked_cache *untracked;
      void *mmap;
      size_t mmap_size;
+     char *last_update;

Might be worth a comment explaining what this is.

Quoted 2 lines

It's the clock value from watchman when we query file status. Will make a note. Or maybe I should just rename it to watchman_clock.

Either way would work for me.

author
#12 lore raw
In reply to Duy Nguyen
Quoted 21 lines · Duy Nguyen
Quoted 19 lines · Paolo Ciarrocchi

On Sun, Nov 1, 2015 at 2:55 PM, Nguyễn Thái Ngọc Duy <[email protected]> wrote:

Hi Duy,

Quoted 14 lines

This series builds on top of the index-helper series I just sent and uses watchman to keep track of file changes in order to avoid lstat() at refresh time. The series can also be found at [1]

When I started this work, watchman did not support Windows yet. It does now, even if still experimental [2]. So Windows people, please try it out if you have time.

To put all pieces so far together, we have split-index to reduce index write time, untracked cache to reduce I/O as well as computation for .gitignore, index-helper for index read time and this series for lstat() at refresh time. The remaining piece is killing lstat() from untracked cache, but right now it's just some idea and incomplete code.

Quoted 5 lines
Quoted 1 line

Did you manage to measure the speedup introduced by this series?

It was from last year. I may have measured it but because I didn't save it in the commit message, it was lost anyway. Installing watchman and measuring with webkit.git soon..

Test repo: webkit.git with 104665 tracked files, 5615 untracked, 3517 dirs. Best numbers out of a few tries. This is best case scenario. Normal usage could have worse numbers.

There is something strange about the "-uno" measurements. I don't think watchman+untracked cache can beat -uno.. Maybe I did something wrong.

0m0.383s   index v2
0m0.351s   index v4
0m0.352s   v2 split-index
0m0.309s   v2 split index-helper
0m0.159s   v2 split helper untracked-cache
0m0.123s   v2 split helper "status -uno"
0m0.098s   v2 split helper untracked watchman
0m0.071s   v2 split helper watchman "status -uno"

Note, the watchman series needs s/free_watchman_shm/release_watchman_shm/ (I didn't do a good job of testing after rebase). And there's a small bug in index-helper --detach code writing incorrect PID..

Signature · 1 line
Duy
#13 lore raw
Quoted 21 lines · Duy Nguyen
Quoted 3 lines

It was from last year. I may have measured it but because I didn't save it in the commit message, it was lost anyway. Installing watchman and measuring with webkit.git soon..

Test repo: webkit.git with 104665 tracked files, 5615 untracked, 3517 dirs. Best numbers out of a few tries. This is best case scenario. Normal usage could have worse numbers.

There is something strange about the "-uno" measurements. I don't think watchman+untracked cache can beat -uno.. Maybe I did something wrong.

0m0.383s   index v2
0m0.351s   index v4
0m0.352s   v2 split-index
0m0.309s   v2 split index-helper
0m0.159s   v2 split helper untracked-cache
0m0.123s   v2 split helper "status -uno"
0m0.098s   v2 split helper untracked watchman
0m0.071s   v2 split helper watchman "status -uno"
Quoted 4 lines

Note, the watchman series needs s/free_watchman_shm/release_watchman_shm/ (I didn't do a good job of testing after rebase). And there's a small bug in index-helper --detach code writing incorrect PID..

Impressive improvements!

Ciao,
Paolo

Signature · 1 line
Paolo
#14 lore raw
In reply to Duy Nguyen
Quoted 24 lines · Duy Nguyen
Quoted 23 lines · Duy Nguyen
Quoted 20 lines · Paolo Ciarrocchi

On Sun, Nov 1, 2015 at 2:55 PM, Nguyễn Thái Ngọc Duy <[email protected]> wrote:

Hi Duy,

Quoted 8 lines

This series builds on top of the index-helper series I just sent and uses watchman to keep track of file changes in order to avoid lstat() at refresh time. The series can also be found at [1]

When I started this work, watchman did not support Windows yet. It does now, even if still experimental [2]. So Windows people, please try it out if you have time.

Quoted 6 lines

To put all pieces so far together, we have split-index to reduce index write time, untracked cache to reduce I/O as well as computation for .gitignore, index-helper for index read time and this series for lstat() at refresh time. The remaining piece is killing lstat() from untracked cache, but right now it's just some idea and incomplete code.

Did you manage to measure the speedup introduced by this series?

Quoted 7 lines
Quoted 3 lines

It was from last year. I may have measured it but because I didn't save it in the commit message, it was lost anyway. Installing watchman and measuring with webkit.git soon..

Test repo: webkit.git with 104665 tracked files, 5615 untracked, 3517 dirs. Best numbers out of a few tries. This is best case scenario. Normal usage could have worse numbers.

Thank you for the tests!

I tried to replicate your results on webkit.git with 184672 tracked files, 5631 untracked, 9330 dirs. Also best numbers out of a few tries.

Quoted 4 lines

There is something strange about the "-uno" measurements. I don't think watchman+untracked cache can beat -uno.. Maybe I did something wrong.

Quoted 8 lines
0m0.383s   index v2
0m0.351s   index v4
0m0.352s   v2 split-index
0m0.309s   v2 split index-helper
0m0.159s   v2 split helper untracked-cache
0m0.123s   v2 split helper "status -uno"
0m0.098s   v2 split helper untracked watchman
0m0.071s   v2 split helper watchman "status -uno"

I got the following results from "time git status ...":

0m0.774s
0m0.799s split
0m0.766s split helper
0m0.335s split helper untracked
0m0.232s split helper untracked -uno
0m0.284s split helper untracked watchman
0m0.188s split helper untracked watchman -uno

Using David's series I get worse results than all of the above but I guess it's because his series is based on an ancient git version (v2.0.0-rc0).

Quoted 4 lines

Note, the watchman series needs s/free_watchman_shm/release_watchman_shm/ (I didn't do a good job of testing after rebase). And there's a small bug in index-helper --detach code writing incorrect PID..

I did the s/free_watchman_shm/release_watchman_shm/ change, but I didn't notice the index-helper bug.

Thanks,
Christian.

#15 lore raw
Quoted 3 lines · Christian Couder

Using David's series I get worse results than all of the above but I guess it's because his series is based on an ancient git version (v2.0.0-rc0).

My more-recent series is on top of 2.4, but (for webkit):
mine: 0m0.206s
duy's: 0m0.107s

However, I'm getting occasional index-helper segfaults due to istate->last_update being NULL. (I'm using Duy's index-helper branch from his github + this patchset + a function signature fix due to a newer version of libwatchman). I haven't looked into why this is -- maybe accidentally mixing git versions while testing?

Also, after messing around for a while (on Duy's branch), I ended up in a state where git status would take ~2.5s every time. The index helper was alive but evidently not working right. Killing and restarting it worked. Actually, I think I can repro this more easily: "git rm Changelog" seems to put the index-helper into this state.

#16 lore raw
Quoted 8 lines · David Turner
Quoted 3 lines · Christian Couder

Using David's series I get worse results than all of the above but I guess it's because his series is based on an ancient git version (v2.0.0-rc0).

My more-recent series is on top of 2.4, but (for webkit):
mine: 0m0.206s
duy's: 0m0.107s

I tried using your more recent series and I get basically no change compared to the current git (without using untracked cache) on Webkit with around 5600 untracked files. Maybe I am doing something wrong.

I compiled watchman and installed it. It is in /usr/local/bin/watchman but I am not sure it is actually being used though I have configured "core.usewatchman" to "true".

Quoted 11 lines

However, I'm getting occasional index-helper segfaults due to istate->last_update being NULL. (I'm using Duy's index-helper branch from his github + this patchset + a function signature fix due to a newer version of libwatchman). I haven't looked into why this is -- maybe accidentally mixing git versions while testing?

Also, after messing around for a while (on Duy's branch), I ended up in a state where git status would take ~2.5s every time. The index helper was alive but evidently not working right. Killing and restarting it worked. Actually, I think I can repro this more easily: "git rm Changelog" seems to put the index-helper into this state.

Thanks for this. I have also seen strange things happening with the index-helper.
When it is working I found that it provides around 10% improvement on git rebase time.