summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpanfile1
-rw-r--r--lib/App/BorgRestore.pm3
-rw-r--r--lib/App/BorgRestore/DB.pm11
3 files changed, 15 insertions, 0 deletions
diff --git a/cpanfile b/cpanfile
index 58c6a0e..bf9f726 100644
--- a/cpanfile
+++ b/cpanfile
@@ -19,6 +19,7 @@ requires 'perl', 'v5.14.0';
requires 'Version::Compare';
requires 'JSON';
requires 'Date::Parse';
+requires 'Number::Bytes::Human';
on configure => sub {
requires 'Devel::CheckBin';
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm
index b26c88d..828838c 100644
--- a/lib/App/BorgRestore.pm
+++ b/lib/App/BorgRestore.pm
@@ -438,6 +438,7 @@ method _handle_removed_archives($borg_archives) {
$self->{db}->remove_archive($archive);
$self->{db}->commit;
$self->{db}->vacuum;
+ $self->{db}->verify_cache_fill_rate_ok();
}
my $end = Time::HiRes::gettimeofday();
@@ -476,6 +477,7 @@ method _handle_added_archives($borg_archives) {
$self->_save_node($archive_id, undef, $lookuptable);
$self->{db}->commit;
$self->{db}->vacuum;
+ $self->{db}->verify_cache_fill_rate_ok();
my $end = Time::HiRes::gettimeofday();
$log->debugf("Adding archive finished after: %.5fs (parsing borg output took %.5fs)", $end - $start, $borg_time - $start);
@@ -519,6 +521,7 @@ method update_cache() {
$self->_handle_added_archives($borg_archives);
$log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count());
+ $self->{db}->verify_cache_fill_rate_ok();
}
diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm
index 0bc5214..3fddbf1 100644
--- a/lib/App/BorgRestore/DB.pm
+++ b/lib/App/BorgRestore/DB.pm
@@ -9,6 +9,7 @@ use autodie;
use DBI;
use Function::Parameters;
use Log::Any qw($log);
+use Number::Bytes::Human qw(format_bytes);
use Path::Tiny;
=encoding utf-8
@@ -36,6 +37,7 @@ method new($class: $db_path, $cache_size) {
} else {
$self->_open_db($db_path, $cache_size);
}
+ $self->{cache_size} = $cache_size;
return $self;
}
@@ -166,6 +168,15 @@ method commit() {
$self->{dbh}->commit();
}
+method verify_cache_fill_rate_ok() {
+ my $used = $self->{dbh}->sqlite_db_status()->{cache_used}->{current};
+ $log->debugf("sqlite page cache usage: %s", format_bytes($used, si=>1));
+ if ($used > $self->{cache_size} * 1024 * 0.95) {
+ $log->warnf("sqlite cache usage is %s of %s", format_bytes($used, si=>1), format_bytes($self->{cache_size} * 1024, si => 1));
+ $log->warn("Consider increasing the sqlite cache (see documentation of App::BorgRestore::Settings)");
+ }
+}
+
method vacuum() {
$self->{dbh}->do("vacuum");
}