summaryrefslogtreecommitdiff
path: root/git-cvsserver.perl
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-29 00:15:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-10-29 17:22:40 (GMT)
commit412e4caee387d825903bf1252aefbd5cf995a599 (patch)
tree3a2104c1ac2fd9c9630d2ab02ea1dfc7ea8cadc8 /git-cvsserver.perl
parentaf6d1d602a8f64164b266364339c4e936d5bbc33 (diff)
downloadgit-412e4caee387d825903bf1252aefbd5cf995a599.zip
git-412e4caee387d825903bf1252aefbd5cf995a599.tar.gz
git-412e4caee387d825903bf1252aefbd5cf995a599.tar.bz2
tests: disable fsync everywhere
The "GIT_TEST_FSYNC" environment variable now exists for disabling fsync() even on packfiles and other "critical" data. Running "make test -j8 NO_SVN_TESTS=1" on a noisy 8-core system on an HDD, test runtime drops from ~4 minutes down to ~3 minutes. Using "GIT_TEST_FSYNC=1" re-enables fsync() for comparison purposes. SVN interopability tests are minimally affected since SVN will still use fsync in various places. This will also be useful for 3rd-party tools which create throwaway git repositories of temporary data, but remains undocumented for end users. Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-cvsserver.perl')
-rwxr-xr-xgit-cvsserver.perl19
1 files changed, 19 insertions, 0 deletions
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 64319be..4c81180 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -3607,6 +3607,22 @@ package GITCVS::updater;
use strict;
use warnings;
use DBI;
+our $_use_fsync;
+
+# n.b. consider using Git.pm
+sub use_fsync {
+ if (!defined($_use_fsync)) {
+ my $x = $ENV{GIT_TEST_FSYNC};
+ if (defined $x) {
+ local $ENV{GIT_CONFIG};
+ delete $ENV{GIT_CONFIG};
+ my $v = ::safe_pipe_capture('git', '-c', "test.fsync=$x",
+ qw(config --type=bool test.fsync));
+ $_use_fsync = defined($v) ? ($v eq "true\n") : 1;
+ }
+ }
+ $_use_fsync;
+}
=head1 METHODS
@@ -3676,6 +3692,9 @@ sub new
$self->{dbuser},
$self->{dbpass});
die "Error connecting to database\n" unless defined $self->{dbh};
+ if ($self->{dbdriver} eq 'SQLite' && !use_fsync()) {
+ $self->{dbh}->do('PRAGMA synchronous = OFF');
+ }
$self->{tables} = {};
foreach my $table ( keys %{$self->{dbh}->table_info(undef,undef,undef,'TABLE')->fetchall_hashref('TABLE_NAME')} )