Skip to content

Instantly share code, notes, and snippets.

@maurorappa
Created October 9, 2024 06:50
Show Gist options
  • Save maurorappa/edfea54d4c1565ac9fa41d2e68903aed to your computer and use it in GitHub Desktop.
Save maurorappa/edfea54d4c1565ac9fa41d2e68903aed to your computer and use it in GitHub Desktop.
Testing LZO
https://www.ele.uri.edu/research/hpcl/2012/SBAC.pdf
how it compiled:
objdump -s --section .gnu.build.attributes /usr/lib64/liblzo2.so.2.0.0
or check the spec file! face with tongue
GLIBCXX_ASSERTION
cf_protection (https://news.ycombinator.com/item?id=26060978)
omit-frame-pointer
-fstack-clash-protection
Build it:
rpmbuild -bb lzo.spec
CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
Oh, no!
error: ACC conformance test failed. Stop.
the fix is:
export CFLAGS="$CFLAGS -std=c90 -fPIC"
now we can test few options from:
Let’s make a file
dd if=/dev/urandom of=bigfile bs=1M count=1024
let’s get some baseline:
./lzotest -m1 bigfile
LZO real-time data compression library (v2.06, Aug 12 2011).
Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
262144 block-size
File bigfile: 67108864 bytes (0x60e6e6b6, 0xf09d9b8c)
compressing 67108864 bytes (1/1/1 loops, 262144 block-size)
LZO1B-1
compressed into 67145523 bytes, 100% (8.004 bits/byte)
compress 1: 67108864 bytes, 0.85 secs, 78.789 MB/sec
decompress 1: 67108864 bytes, 0.01 secs, 7979.651 MB/sec
LZO1B-1 | bigfile 67108864 256 67145523 100 78.789 7979.651 |
other compression options
[root@vmx196 lzotest]# ./lzotest -m992 bigfile
LZO1Z-999
compressed into 67378075 bytes, 100% (8.032 bits/byte)
compress 1: 67108864 bytes, 9.77 secs, 6.869 MB/sec
decompress 1: 67108864 bytes, 0.01 secs, 10289.614 MB/sec
LZO1Z-999 | bigfile 67108864 256 67378075 100 6.869 10289.614 |
better…
[root@vmx196 lzotest]# ./lzotest -m21 bigfile
LZO1-1
compressed into 67206349 bytes, 100% (8.012 bits/byte)
compress 1: 67108864 bytes, 0.86 secs, 78.441 MB/sec
decompress 1: 67108864 bytes, 0.01 secs, 11094.208 MB/sec
LZO1-1 | bigfile 67108864 256 67206349 100 78.441 11094.208 |
even better…
[root@vmx196 lzotest]# ./lzotest -m111 bigfile
compressed into 67373056 bytes, 100% (8.031 bits/byte)
compress 1: 67108864 bytes, 0.23 secs, 290.001 MB/sec
decompress 1: 67108864 bytes, 0.00 secs, 13902.810 MB/sec
let’s now test O3 (also turns on the -finline-functions, -funswitch-loops and -fgcse-after-reload options.)
export CFLAGS="$CFLAGS -std=c90 -fPIC -O3"
[root@vmx196 lzotest]# ./lzotest -m111 bigfile
compress 1: 67108864 bytes, 0.01 secs, 9690.811 MB/sec
decompress 1: 67108864 bytes, 0.00 secs, 21655.006 MB/sec
LZO1X-1(11) | bigfile 67108864 256 67373056 100 9690.811 21655.006 |
wow!
Let’s compare with a simple O2 (not all flags specified in the spec file)
export CFLAGS="-std=c90 -fPIC -O2"
[root@vmx196 lzotest]# ./lzotest -m111 bigfile
compress 1: 67108864 bytes, 0.04 secs, 1538.876 MB/sec
decompress 1: 67108864 bytes, 0.00 secs, 19463.128 MB/sec
ok they are very close… O3 is slighly better, which extra flag is beneificial?
export CFLAGS="-std=c90 -fPIC -O2 -funswitch-loops"
[root@vmx196 lzotest]# ./lzotest -m111 bigfile
compress 1: 67108864 bytes, 0.04 secs, 1535.075 MB/sec
decompress 1: 67108864 bytes, 0.00 secs, 19901.798 MB/sec
LZO1X-1(11) | bigfile 67108864 256 67373056 100 1535.075 19901.798 |
Cool! Now we need to buid a system library and swap the default one:
./configure --disable-static --enable-shared
make
/root/lzo/lzo-2.06/src/.libs/liblzo2.so
Job done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment