Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonasschneider/952da7e518ad218a5159 to your computer and use it in GitHub Desktop.
Save jonasschneider/952da7e518ad218a5159 to your computer and use it in GitHub Desktop.
From bdd045842757f316123d295e4d71591b71e00b7f Mon Sep 17 00:00:00 2001
From: Jonas Schneider <mail@jonasschneider.com>
Date: Wed, 11 Mar 2015 10:25:35 +0100
Subject: [PATCH] Improve backup performance by initializing the
CodedOutputStream only once.
---
backup_creator.cc | 2 +-
backup_creator.hh | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/backup_creator.cc b/backup_creator.cc
index a4857fb..8f6c26d 100644
--- a/backup_creator.cc
+++ b/backup_creator.cc
@@ -22,7 +22,7 @@ BackupCreator::BackupCreator( Config const & config,
chunkIndex( chunkIndex ), chunkStorageWriter( chunkStorageWriter ),
ringBufferFill( 0 ),
chunkToSaveFill( 0 ),
- backupDataStream( new google::protobuf::io::StringOutputStream( &backupData ) ),
+ backupDataStream( new google::protobuf::io::CodedOutputStream( new google::protobuf::io::StringOutputStream( &backupData ) ) ),
chunkIdGenerated( false )
{
// In our ring buffer we have enough space to store one chunk plus an extra
diff --git a/backup_creator.hh b/backup_creator.hh
index 2146ec7..7ddfd56 100644
--- a/backup_creator.hh
+++ b/backup_creator.hh
@@ -49,7 +49,8 @@ class BackupCreator: ChunkIndex::ChunkInfoInterface, NoCopy
RollingHash rollingHash;
string backupData;
- sptr< google::protobuf::io::StringOutputStream > backupDataStream;
+
+ sptr< google::protobuf::io::CodedOutputStream > backupDataStream;
/// Sees if the current block in the ring buffer exists in the chunk store.
/// If it does, the reference is emitted and the ring buffer is cleared
--
2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment