[Openais] corosync trunk patch - use strlen inside macro definitions for logging

Steven Dake sdake at redhat.com
Sat Mar 6 16:35:32 PST 2010


The logsys implementation uses 3 strlen() api calls during any recording
of a log record into the circular buffer.  strlen is expensive, and in
all cases can be avoided.  Currently we use strlen() to determine the
length of the subsys, the length of the function name, and the length of
the file name.

Most modern compilers will replace strlen(MACRO) with the appropriate
string length from the expansion of the macro.  This allows us to pass
strlen (__FILE__), allowing the C preprocessor to calculate it at
compile time rather the the potentially millions of times per day it
could be calculated during normal operation.

The attached patch adds new "internal ABI" calls to logsys as to
preserve ABI compatibility with older applications that use the current
macros.  As a result, this patch also changes the SO micro version for
the logsys shared object name.

Benchmarks pre-change via test/logsysbench:
[root at bigiron test]# ./logsysbench
heating up cache with logrec functionality
log_rec 1 arguments:			10508153.276 operations/sec
log_rec 2 arguments:			10610912.687 operations/sec
log_rec 3 arguments:			8346019.283 operations/sec
log_rec 4 arguments:			7135181.726 operations/sec

Benchmarks post-change:
[root at bigiron test]# ./logsysbench
heating up cache with logrec functionality
log_rec 1 arguments:			11758895.605 operations/sec
log_rec 2 arguments:			12229902.601 operations/sec
log_rec 3 arguments:			9585770.116 operations/sec
log_rec 4 arguments:			8095592.759 operations/sec

As can be seen, about a 10% performance improvement.

Regards
-steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: corosync-trunk-logsys-strlen-optimize.patch
Type: text/x-patch
Size: 10169 bytes
Desc: not available
Url : http://lists.linux-foundation.org/pipermail/openais/attachments/20100306/ad807ebb/attachment-0001.bin 


More information about the Openais mailing list