summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-01-24 15:03:45 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-01-24 15:03:45 +0100
commit5a0d80e685a0172500bf17dbb1e0c27037e58b0b (patch)
tree4916c3bad7d09e6e883bcc23b6f87c004b1e07da
parentcee0cd7762090f0531b4cc64e4188b619533ca31 (diff)
downloadApp-BorgRestore-5a0d80e685a0172500bf17dbb1e0c27037e58b0b.tar.gz
App-BorgRestore-5a0d80e685a0172500bf17dbb1e0c27037e58b0b.tar.xz
Only increase sqlite cache size during update
While not all operations fill the cache, --list does. However, for read operations it doesn't actually appear to help performance. Limit the large cache setting to update operations only because there it does really increase performance. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/BorgRestore.pm2
-rw-r--r--lib/App/BorgRestore/DB.pm11
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm
index c3b37fd..964ea48 100644
--- a/lib/App/BorgRestore.pm
+++ b/lib/App/BorgRestore.pm
@@ -532,6 +532,8 @@ method update_cache() {
my $borg_archives = $self->{borg}->borg_list();
+ # write operations benefit from the large cache so set the cache size here
+ $self->{db}->set_cache_size();
$self->_handle_removed_archives($borg_archives);
$self->_handle_added_archives($borg_archives);
diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm
index 1f1427e..177df27 100644
--- a/lib/App/BorgRestore/DB.pm
+++ b/lib/App/BorgRestore/DB.pm
@@ -32,23 +32,26 @@ method new($class: $db_path, $cache_size) {
# ensure the cache directory exists
path($db_path)->parent->mkpath({mode => oct(700)});
- my $db = $self->_open_db($db_path, $cache_size);
+ my $db = $self->_open_db($db_path);
$self->initialize_db();
} else {
- $self->_open_db($db_path, $cache_size);
+ $self->_open_db($db_path);
}
$self->{cache_size} = $cache_size;
return $self;
}
-method _open_db($dbfile, $cache_size) {
+method _open_db($dbfile) {
$log->debugf("Opening database at %s", $dbfile);
$self->{dbh} = DBI->connect("dbi:SQLite:dbname=$dbfile","","", {RaiseError => 1, Taint => 1});
- $self->{dbh}->do("PRAGMA cache_size=-".$cache_size);
$self->{dbh}->do("PRAGMA strict=ON");
}
+method set_cache_size() {
+ $self->{dbh}->do("PRAGMA cache_size=-".$self->{cache_size});
+}
+
method initialize_db() {
$log->debug("Creating initial database");
$self->{dbh}->do('create table `files` (`path` text, primary key (`path`)) without rowid;');