diff options
author | sra@chromium.org <sra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 21:18:48 +0000 |
---|---|---|
committer | sra@chromium.org <sra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 21:18:48 +0000 |
commit | 6db3cd4ebccf65c9bbe1bb6d6239ec103caaf518 (patch) | |
tree | c2ab9d415c80ae62ff06fdbb8be3472271daacb0 /courgette/streams.h | |
parent | ce910b9d066453ea491473c4ef9e73b163a58d6d (diff) | |
download | chromium_src-6db3cd4ebccf65c9bbe1bb6d6239ec103caaf518.zip chromium_src-6db3cd4ebccf65c9bbe1bb6d6239ec103caaf518.tar.gz chromium_src-6db3cd4ebccf65c9bbe1bb6d6239ec103caaf518.tar.bz2 |
Improved memory usage while applying patch.
Reduced total size of allocations from 520MB to 318MB.
The general technique is to allocate the correct size rather than grow into
the correct size and overshoot.
1. Find file sizes and allocate buffers of that size for the input files.
2. Pre-allocate a buffer for the collected inputs for the final diff.
3. Calculate the size for (2) during compression and include it in the patch
header.
The courgette.exe command line tool now calls the same ApplyEnsemblePatch
entry point that is called by the installer. This ensures measurements of
courgette.exe are a better reflection of the installer.
BUG=72459
Review URL: http://codereview.chromium.org/6546008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/streams.h')
-rw-r--r-- | courgette/streams.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/courgette/streams.h b/courgette/streams.h index 144dca7..3dbc2b7 100644 --- a/courgette/streams.h +++ b/courgette/streams.h @@ -147,6 +147,9 @@ class SinkStream { // Hints that the stream will grow by an additional |length| bytes. void Reserve(size_t length) { buffer_.reserve(length + buffer_.length()); } + // Finished with this stream and any storage it has. + void Retire(); + private: std::string buffer_; // Use a string to manage the stream's memory. @@ -187,6 +190,11 @@ class SourceStreamSet { DISALLOW_COPY_AND_ASSIGN(SourceStreamSet); }; +// A SinkStreamSet is a set of SinkStreams. Data is collected by writing to the +// component streams. When data collection is complete, it is destructively +// transferred, either by flattening into one stream (CopyTo), or transfering +// data pairwise into another SinkStreamSet by calling that SinkStreamSet's +// WriteSet method. class SinkStreamSet { public: SinkStreamSet(); @@ -199,8 +207,8 @@ class SinkStreamSet { // Returns a pointer to a substream. SinkStream* stream(size_t id) { return id < count_ ? &streams_[id] : NULL; } - // CopyTo serializes the streams in the SinkStreamSet into a single target - // stream or file. The serialized format may be re-read by initializing a + // CopyTo serializes the streams in this SinkStreamSet into a single target + // stream. The serialized format may be re-read by initializing a // SourceStreamSet with a buffer containing the data. bool CopyTo(SinkStream* combined_stream); |