crcutil as library

Skip to first unread message

fermat

unread,
May 16, 2012, 6:33:27 AM5/16/12
to crcutil
Hello,

I would like to integrate your code in an application I am writing.
Therefore I would like to build your code as an library to link it
statically. I know from the INSTALL file that your suggestion is to
compile your code directly in the application, but this would be very
difficult, as I have a completly different build process. I also would
prefer not to mix the code.

Is there a way to build crcutil as a library, so I can just use it by
accessing the interface.h?

bests

Sascha

Andrew Kadatch

unread,
May 16, 2012, 12:46:18 PM5/16/12
to crc...@googlegroups.com
Hi Sascha,


Yes -- if you are willing to use interface.h then it should be no problem.

Interface.h was more of a demo how to convert crcutil (and all the C++ templates)
into a library, and for that reason it exposes only the most essential CRC
functionality. Additional features may be added on as-needed basis though,
in similar fashion.


Thank you,

Andrew

fermat

unread,
May 21, 2012, 9:03:22 AM5/21/12
to crcutil
Hello,

I did it by building it by hand as I am not familar with the autobuild
toolchain. Therefore my scipts does the following steps with an
archive:


tar -zxf crcutil-1.0.tar.gz
cd crcutil-1.0
./configure --prefix=/usr/local
mkdir build
for i in code/*.cc ; do g++ -DHAVE_CONFIG_H -I. -
DCRCUTIL_USE_MM_CRC32=1 -Wall -msse2 -Icode -g -O3 -fomit-frame-
pointer -c -o build/`basename $i .cc`.o $i ; done
g++ -DHAVE_CONFIG_H -I. -Iexamples -Itests -
DCRCUTIL_USE_MM_CRC32=1 -Wall -msse2 -Icode -g -O3 -fomit-frame-
pointer -c -o build/interface.o examples/interface.cc
cd build
ar rcs libcrcutil.a *.o
cp libcrcutil.a /usr/local/lib
cd ..
cp code/*.h /opt/dedupv1/include
cp examples/interface.h /opt/dedupv1/include
cp tests/aligned_alloc.h /opt/dedupv1/include
ldconfig


This works for me.

I compared your CRC with the CRC of libcrypto. Therefore I created
100,000 messages of 2K size. with libcrypto this took me about 400 ms.
My first implementation with crcutil took 4 seconds, as I created each
time a new CRC object. This was no problem with libcrypto. After
changing this behaviour and using each time the same object I could do
10 100,000 messages in 75 ms with crcutil, libcrypto needed about the
same as before.

I am using crcutil in a multithreaded environment. So I have another
question: If I create a CRC, is it threadsafe? Or do I have to create
for each thread an own object?


bests

Sascha

Andrew Kadatch

unread,
May 21, 2012, 1:07:53 PM5/21/12
to crc...@googlegroups.com
Cool! -- so crcutil is a little bit faster, right?

crcutil is thread-safe: it creates a lot of tables on initialization (and that path
is not optimized so it may be slow) and then it uses these tables in read-only
mode (I hope I didn't forget to specify "const" attributes).

So you did everything correctly.


Thank you,

Andrew

fermat

unread,
May 22, 2012, 5:00:12 AM5/22/12
to crcutil
Great. I integrated it into our dedupe and it works. It is much
faster. Very good work, thanks.

bests

Sascha
Reply all
Reply to author
Forward
0 new messages