[systemd-commits] 3 commits - .gitignore src/journal

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Jul 8 20:18:12 PDT 2014


 .gitignore                  |    2 ++
 src/journal/compress.c      |   14 ++++++++++++--
 src/journal/journal-def.h   |    2 +-
 src/journal/journal-file.c  |    2 +-
 src/journal/test-compress.c |    2 +-
 5 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 1930eed2a7855d2df06ccf51f9e394428bf547e2
Author: Jon Severinsson <jon at severinsson.net>
Date:   Tue Jul 8 18:29:46 2014 +0200

    journal/compress: improve xz compression performance
    
    The new lzma2 compression options at the top of compress_blob_xz are
    equivalent to using preset "0", exept for using a 1 MiB dictionary
    (the same as preset "1"). This makes the memory usage at most 7.5 MiB
    in the compressor, and 1 MiB in the decompressor, instead of the
    previous 92 MiB in the compressor and 8 MiB in the decompressor.
    
    According to test-compress-benchmark this commit makes XZ compression
    20 times faster, with no increase in compressed data size.
    Using more realistic test data (an ELF binary rather than repeating
    ASCII letters 'a' through 'z' in order) it only provides a factor 10
    speedup, and at a cost if a 10% increase in compressed data size.
    But that is still a worthwhile trade-off.
    
    According to test-compress-benchmark XZ compression is still 25 times
    slower than LZ4, but the compressed data is one eighth the size.
    Using more realistic test data XZ compression is only 18 times slower
    than LZ4, and the compressed data is only one quarter the size.
    
    $ ./test-compress-benchmark
    XZ: compressed & decompressed 2535300963 bytes in 42.30s (57.15MiB/s), mean compresion 99.95%, skipped 3570 bytes
    LZ4: compressed & decompressed 2535303543 bytes in 1.60s (1510.60MiB/s), mean compresion 99.60%, skipped 990 bytes

diff --git a/src/journal/compress.c b/src/journal/compress.c
index 49d694a..93ac92a 100644
--- a/src/journal/compress.c
+++ b/src/journal/compress.c
@@ -49,6 +49,13 @@ DEFINE_STRING_TABLE_LOOKUP(object_compressed, int);
 
 int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size) {
 #ifdef HAVE_XZ
+        static const lzma_options_lzma opt = {
+                1u << 20u, NULL, 0, LZMA_LC_DEFAULT, LZMA_LP_DEFAULT,
+                LZMA_PB_DEFAULT, LZMA_MODE_FAST, 128, LZMA_MF_HC3, 4};
+        static const lzma_filter filters[2] = {
+                {LZMA_FILTER_LZMA2, (lzma_options_lzma*) &opt},
+                {LZMA_VLI_UNKNOWN, NULL}
+        };
         lzma_ret ret;
         size_t out_pos = 0;
 
@@ -60,8 +67,11 @@ int compress_blob_xz(const void *src, uint64_t src_size, void *dst, uint64_t *ds
         /* Returns < 0 if we couldn't compress the data or the
          * compressed result is longer than the original */
 
-        ret = lzma_easy_buffer_encode(LZMA_PRESET_DEFAULT, LZMA_CHECK_NONE, NULL,
-                                      src, src_size, dst, &out_pos, src_size - 1);
+        if (src_size < 80)
+                return -ENOBUFS;
+
+        ret = lzma_stream_buffer_encode((lzma_filter*) filters, LZMA_CHECK_NONE, NULL,
+                                        src, src_size, dst, &out_pos, src_size - 1);
         if (ret != LZMA_OK)
                 return -ENOBUFS;
 

commit 92261977d81fd6a5bfb1418eddd86582d8a57fcd
Author: Ronny Chevalier <chevalier.ronny at gmail.com>
Date:   Tue Jul 8 09:22:25 2014 +0200

    fix #ifdef

diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h
index ecfa9a2..089dd98 100644
--- a/src/journal/journal-def.h
+++ b/src/journal/journal-def.h
@@ -180,7 +180,7 @@ enum {
 };
 
 #define HEADER_COMPATIBLE_ANY HEADER_COMPATIBLE_SEALED
-#if HAVE_GCRYPT
+#ifdef HAVE_GCRYPT
 #  define HEADER_COMPATIBLE_SUPPORTED HEADER_COMPATIBLE_SEALED
 #else
 #  define HEADER_COMPATIBLE_SUPPORTED 0
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index b6de502..d3535d2 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2476,7 +2476,7 @@ int journal_file_open(
         f->flags = flags;
         f->prot = prot_from_flags(flags);
         f->writable = (flags & O_ACCMODE) != O_RDONLY;
-#if defined(HAVE_LZ)
+#if defined(HAVE_LZ4)
         f->compress_lz4 = compress;
 #elif defined(HAVE_XZ)
         f->compress_xz = compress;
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index 6ac8373..4c0a9a0 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -27,7 +27,7 @@
 # define XZ_OK -EPROTONOSUPPORT
 #endif
 
-#ifdef HAVE_XZ
+#ifdef HAVE_LZ4
 # define LZ4_OK 0
 #else
 # define LZ4_OK -EPROTONOSUPPORT

commit da625e4b80ba8b03e68ce1782753acd34cf19bd5
Author: Ronny Chevalier <chevalier.ronny at gmail.com>
Date:   Mon Jul 7 10:04:33 2014 +0200

    update .gitignore

diff --git a/.gitignore b/.gitignore
index 52b78ae..3cf7006 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@
 .deps/
 .dirstamp
 .libs/
+/*.gcda
+/*.gcno
 /*.tar.bz2
 /*.tar.gz
 /*.tar.xz



More information about the systemd-commits mailing list