Usage / performance of zlib memory. With 500 KB of data

Is zLib this? Are there other more suitable compressors?

I am using the embedded system. Often I only have 3 MB of RAM or less available for my application. Therefore, I am considering using zlib to compress my buffers. However, I am concerned about overhead.

The average buffer size will be 30 KB. It will probably not be compressed by zlib . Does anyone know of a good compressor for extremely limited memory environments?

However , I will experience periodic maximum buffer sizes of 700 KB, with 500 KB being much more common. Is zlib worth it in this case? Or too much cost to justify?

My only consideration for compression: algorithm RAM and performance are at least as good as zlib.

LICENSE . I prefer the compressor licensed under BSD, zLib, or an equivalent license.

+3
source share
3 answers

If you initialize zlib using lm_init()with 1, 2or 3, a deflate()routine will be used instead deflate_fast()that will use smaller runtime buffers and faster algorithms. Compromise is worse than compression. It is probably worth it.

zlib SMALL_MEM, - . ( deflate.c) :

/* Compile with MEDIUM_MEM to reduce the memory requirements or
 * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the
 * entire input file can be held in memory (not possible on 16 bit systems).
 * Warning: defining these symbols affects HASH_BITS (see below) and thus
 * affects the compression ratio. The compressed output
 * is still correct, and might even be smaller in some cases.
 */

, zlib . , . - , , , zlib - .

zlib, SMALL_MEM, , 600k, :

$ ls -l abi-2.6.31-14-generic
-rw-r--r-- 1 sarnold sarnold 623709 2011-03-18 18:09 abi-2.6.31-14-generic
$ for i in `seq 1 9` ; do /usr/bin/time ./gzip -c -${i} abi-2.6.31-14-generic | wc -c ; done
0.02user 0.00system 0:00.02elapsed 76%CPU (0avgtext+0avgdata 2816maxresident)k
0inputs+0outputs (0major+213minor)pagefaults 0swaps
162214
0.01user 0.00system 0:00.01elapsed 52%CPU (0avgtext+0avgdata 2800maxresident)k
0inputs+0outputs (0major+212minor)pagefaults 0swaps
158817
0.02user 0.00system 0:00.02elapsed 95%CPU (0avgtext+0avgdata 2800maxresident)k
0inputs+0outputs (0major+212minor)pagefaults 0swaps
156708
0.02user 0.00system 0:00.02elapsed 76%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+211minor)pagefaults 0swaps
143843
0.03user 0.00system 0:00.03elapsed 96%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+212minor)pagefaults 0swaps
140706
0.03user 0.00system 0:00.03elapsed 81%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+211minor)pagefaults 0swaps
140126
0.04user 0.00system 0:00.04elapsed 95%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+211minor)pagefaults 0swaps
138801
0.05user 0.00system 0:00.05elapsed 84%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+212minor)pagefaults 0swaps
138446
0.06user 0.00system 0:00.06elapsed 96%CPU (0avgtext+0avgdata 2768maxresident)k
0inputs+0outputs (0major+210minor)pagefaults 0swaps
138446

gzip 2,6 , ; , , , gzip , , .

+5

LZO.

:

  • .
  • 64 .

, ( ) , , , .

.

+3

LZS - , -. .

I wrote C and Python code to compress and decompress LZS .

+1
source

All Articles