diff options
author | Benoît Lizé <lizeb@chromium.org> | 2019-01-11 09:33:45 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-01-11 09:33:45 +0000 |
commit | e080c76be8c127cd977e49d64246fd98e67b35e6 (patch) | |
tree | c6b1c12f8b610e7a92eb175f31229600d90b272f /google/compression_utils.h | |
parent | f8556a76361473e81dd9a157e65d17aa2024d83a (diff) | |
download | zlib-e080c76be8c127cd977e49d64246fd98e67b35e6.tar.gz |
blink/bindings: Use PartitionAlloc for compressing strings.
ParkableString compression allocates a temporary buffer inside GzipCompress
using UncheckedMalloc(). From a finch experiment (see bug), there is a
statistically significant increase in malloc() footprint on Android, even though
the only allocations are temporary.
To mitigate the regression, use PartitionAlloc to allocate the temporary data.
This changes:
- compression_utils.cc: take an external output buffer for compression.
- parkable_string.cc: Allocate the temporary buffer with PartitionAlloc, on the
buffer partition.
Bug: 920194
Change-Id: I57c42f67ea0b09e1ae9137beade4dd0d3c6ef258
Reviewed-on: https://chromium-review.googlesource.com/c/1404083
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Benoit L <lizeb@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#621954}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 83ca30af3b48d17cbd19267f6f76f2d6609084fa
Diffstat (limited to 'google/compression_utils.h')
-rw-r--r-- | google/compression_utils.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/google/compression_utils.h b/google/compression_utils.h index a29f5b1..e84bfc4 100644 --- a/google/compression_utils.h +++ b/google/compression_utils.h @@ -11,18 +11,31 @@ namespace compression { +// Compresses the data in |input| using gzip, storing the result in +// |output_buffer|, of size |output_buffer_size|. If the buffer is large enough +// and compression succeeds, |compressed_size| points to the compressed data +// size after the call. +// Returns true for success. +bool GzipCompress(base::StringPiece input, + char* output_buffer, + size_t output_buffer_size, + size_t* compressed_size); + // Compresses the data in |input| using gzip, storing the result in |output|. // |input| and |output| are allowed to point to the same string (in-place // operation). +// Returns true for success. bool GzipCompress(base::StringPiece input, std::string* output); // Uncompresses the data in |input| using gzip, storing the result in |output|. // |input| and |output| are allowed to be the same string (in-place operation). +// Returns true for success. bool GzipUncompress(const std::string& input, std::string* output); // Like the above method, but uses base::StringPiece to avoid allocations if // needed. |output|'s size must be at least as large as the return value from // GetUncompressedSize. +// Returns true for success. bool GzipUncompress(base::StringPiece input, base::StringPiece output); // Returns the uncompressed size from GZIP-compressed |compressed_data|. |