Skip to content

Commit c87fbcf

Browse files
Alex Vandivergitster
authored andcommitted
fsmonitor: don't bother pretty-printing JSON from watchman
This provides modest performance savings. Benchmarking with the following program, with and without `--no-pretty`, we find savings of 23% (0.316s -> 0.242s) in the git repository, and savings of 8% (5.24s -> 4.86s) on a large repository with 580k files in the working copy. #!/usr/bin/perl use strict; use warnings; use IPC::Open2; use JSON::XS; my $pid = open2(\*CHLD_OUT, \*CHLD_IN, "watchman -j @ARGV") or die "open2() failed: $!\n" . "Falling back to scanning...\n"; my $query = qq|["query", "$ENV{PWD}", {}]|; print CHLD_IN $query; close CHLD_IN; my $response = do {local $/; <CHLD_OUT>}; JSON::XS->new->utf8->decode($response); Signed-off-by: Alex Vandiver <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 11cf33b commit c87fbcf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/hooks--fsmonitor-watchman.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ launch_watchman();
4949

5050
sub launch_watchman {
5151

52-
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j')
52+
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
5353
or die "open2() failed: $!\n" .
5454
"Falling back to scanning...\n";
5555

0 commit comments

Comments
 (0)