summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2015-02-24 15:19:20 +1100
committerDan Pasette <dan@mongodb.com>2015-02-24 07:29:33 -0500
commit96315ab194016300a663e61c8ba797d0416c23aa (patch)
tree265e49629170af8d8954368e92692d269725bcd5
parentc0ab0fb653ddb391d2781a0c4974dbe5787bb0f8 (diff)
downloadmongo-96315ab194016300a663e61c8ba797d0416c23aa.tar.gz
SERVER-17299 Eliminate memory allocation from snappy_compress.
(cherry picked from commit c614b21cc563dbb400f7258124fc5d2ed58b4dce)
-rw-r--r--src/third_party/snappy-1.1.2/snappy-internal.h2
-rw-r--r--src/third_party/snappy-1.1.2/snappy.cc18
2 files changed, 10 insertions, 10 deletions
diff --git a/src/third_party/snappy-1.1.2/snappy-internal.h b/src/third_party/snappy-1.1.2/snappy-internal.h
index c99d33130b1..dd6888bd96b 100644
--- a/src/third_party/snappy-1.1.2/snappy-internal.h
+++ b/src/third_party/snappy-1.1.2/snappy-internal.h
@@ -47,7 +47,7 @@ class WorkingMemory {
uint16* GetHashTable(size_t input_size, int* table_size);
private:
- uint16 small_table_[1<<10]; // 2KB
+ uint16 small_table_[1<<14]; // 32KB
uint16* large_table_; // Allocated only when needed
DISALLOW_COPY_AND_ASSIGN(WorkingMemory);
diff --git a/src/third_party/snappy-1.1.2/snappy.cc b/src/third_party/snappy-1.1.2/snappy.cc
index 8414d2581fe..776a045cce9 100644
--- a/src/third_party/snappy-1.1.2/snappy.cc
+++ b/src/third_party/snappy-1.1.2/snappy.cc
@@ -940,16 +940,16 @@ size_t Compress(Source* reader, Sink* writer) {
// Compress input_fragment and append to dest
const int max_output = MaxCompressedLength(num_to_read);
- // Need a scratch buffer for the output, in case the byte sink doesn't
- // have room for us directly.
- if (scratch_output == NULL) {
- scratch_output = new char[max_output];
- } else {
- // Since we encode kBlockSize regions followed by a region
- // which is <= kBlockSize in length, a previously allocated
- // scratch_output[] region is big enough for this iteration.
- }
+ // If the byte sink doesn't have room for us directly, allocate a scratch
+ // buffer.
+ //
+ // Since we encode kBlockSize regions followed by a region
+ // which is <= kBlockSize in length, a previously allocated
+ // scratch_output[] region is big enough for this iteration.
char* dest = writer->GetAppendBuffer(max_output, scratch_output);
+ if (dest == NULL) {
+ dest = scratch_output = new char[max_output];
+ }
char* end = internal::CompressFragment(fragment, fragment_size,
dest, table, table_size);
writer->Append(dest, end - dest);