summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore/DB.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/BorgRestore/DB.pm')
-rw-r--r--lib/App/BorgRestore/DB.pm11
1 files changed, 11 insertions, 0 deletions
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");
}