Slightly increase XZ block-size.
Make slightly bigger random-access blocks to save space.
Bug: 110133331
Change-Id: I6192236b5094283854641d89be352d742fd2e936
diff --git a/libelffile/elf/xz_utils.cc b/libelffile/elf/xz_utils.cc
index 0d47171..87c9a7b 100644
--- a/libelffile/elf/xz_utils.cc
+++ b/libelffile/elf/xz_utils.cc
@@ -32,7 +32,7 @@
namespace art {
-constexpr size_t kChunkSize = kPageSize;
+constexpr size_t kChunkSize = 16 * KB;
static void XzInitCrc() {
static std::once_flag crc_initialized;
@@ -42,12 +42,12 @@
});
}
-void XzCompress(ArrayRef<const uint8_t> src, std::vector<uint8_t>* dst) {
+void XzCompress(ArrayRef<const uint8_t> src, std::vector<uint8_t>* dst, int level) {
// Configure the compression library.
XzInitCrc();
CLzma2EncProps lzma2Props;
Lzma2EncProps_Init(&lzma2Props);
- lzma2Props.lzmaProps.level = 1; // Fast compression.
+ lzma2Props.lzmaProps.level = level;
lzma2Props.lzmaProps.reduceSize = src.size(); // Size of data that will be compressed.
lzma2Props.blockSize = kChunkSize;
Lzma2EncProps_Normalize(&lzma2Props);
diff --git a/libelffile/elf/xz_utils.h b/libelffile/elf/xz_utils.h
index 2b11584..df5cb56 100644
--- a/libelffile/elf/xz_utils.h
+++ b/libelffile/elf/xz_utils.h
@@ -23,7 +23,7 @@
namespace art {
-void XzCompress(ArrayRef<const uint8_t> src, std::vector<uint8_t>* dst);
+void XzCompress(ArrayRef<const uint8_t> src, std::vector<uint8_t>* dst, int level = 1 /* speed */);
void XzDecompress(ArrayRef<const uint8_t> src, std::vector<uint8_t>* dst);
} // namespace art