From fc4cc8b028a6248f98fa09d28f9489a88949d45e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 8 Aug 2021 13:53:01 +0300 Subject: 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 --- src/generation.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') 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>, ) -> Result, 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) } } -- cgit v1.2.1