summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-08 13:53:01 +0300
committerLars Wirzenius <liw@liw.fi>2021-08-09 09:58:38 +0300
commitfc4cc8b028a6248f98fa09d28f9489a88949d45e (patch)
tree2499a11dea2cc89d7f57cf4947907fd17b9b0ead /src
parent22a4e91448b40477a8247adc7834fa62f02725c6 (diff)
downloadobnam2-fc4cc8b028a6248f98fa09d28f9489a88949d45e.tar.gz
refactor: call NascentGeneration::insert from ::insert_iter
This is a step towards getting rid of insert_iter entirely, which would make it easier to make `obnam backup` use async. I originally split insert_iter so I could use a single transaction for inserting many rows, but it seems to not be needed for speed after all. I've benchmarked backing up a large file with and without this change, and there's no real difference. I've not benchmarked with a large number of files. Even if there's a performance hit from using multiple transactions, my hope is that by being able to use more CPUs/threads for backing up will outweigh that by far. Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/generation.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/generation.rs b/src/generation.rs
index 5412ae7..45b8afa 100644
--- a/src/generation.rs
+++ b/src/generation.rs
@@ -94,7 +94,6 @@ impl NascentGeneration {
&mut self,
entries: impl Iterator<Item = Result<FsEntryBackupOutcome, BackupError>>,
) -> Result<Vec<BackupError>, NascentError> {
- let t = self.conn.transaction().map_err(NascentError::Transaction)?;
let mut warnings = vec![];
for r in entries {
match r {
@@ -108,12 +107,10 @@ impl NascentGeneration {
reason,
is_cachedir_tag,
}) => {
- self.fileno += 1;
- sql::insert_one(&t, entry, self.fileno, &ids[..], reason, is_cachedir_tag)?;
+ self.insert(entry, &ids, reason, is_cachedir_tag)?;
}
}
}
- t.commit().map_err(NascentError::Commit)?;
Ok(warnings)
}
}