Added support for gcov, and ran gprof. Shaved 10% off the runtime of check_page by optimizing rw.c

This commit is contained in:
Sears Russell 2004-10-04 05:24:12 +00:00
parent 96e7af92a4
commit 9268b1d9cf
7 changed files with 79 additions and 31 deletions

View file

@ -6,4 +6,16 @@ docs:
doxygen doc/Doxyfile-api doxygen doc/Doxyfile-api
doxygen doc/Doxyfile-developers doxygen doc/Doxyfile-developers
.PHONY: docs precoverage :
find . -name '*.bb' | xargs rm -f
find . -name '*.bbg' | xargs rm -f
find . -name '*.da' | xargs rm -f
coverage: precoverage check
echo '(make profile requires CFLAGS="-fprofile-arcs -ftest-coverage -pg -O0")'
lcov -c --directory src/libdfa/ --directory src/lladd/ --directory test/ > tmp.info
# lcov -c --directory . > tmp.info
genhtml -o doc/coverage tmp.info
rm tmp.info
.PHONY: docs precoverage coverage

24
README
View file

@ -34,3 +34,27 @@ http://mission.base.com/peter/source/
LLADD's version of the package adds the jbhash.* files, and compiles PBL using LLADD's version of the package adds the jbhash.* files, and compiles PBL using
LLADD's make files. Currently, LLADD's hash table implementations are based upon LLADD's make files. Currently, LLADD's hash table implementations are based upon
code from PBL, and pbl is used in a number of places throughout LLADD. code from PBL, and pbl is used in a number of places throughout LLADD.
In order to use gcc's profiling and coverage tools (gprof, and gcov, respectively),
execute this command:
export CFLAGS="-fprofile-arcs -ftest-coverage -pg -O0"
./configure
make clean
make check
The 'make check' step will output profiles and test coverage that reflects the test
cases. You can simply invoke 'make' if you are interested in profiling the
library for a specific program.
To produce the gcov output, you may then run this command in src/
ls *.c logger/*.c operations/*.c page/*.c | xargs -n 1 gcov | grep executed | sort -k1,1n
Or, run this:
lcov -c --directory . > tmp.info
genhtml tmp.info
For HTML output.

View file

@ -1,10 +1,13 @@
#! /bin/sh #! /bin/sh
make distclean make distclean
rm -rf Makefile.in aclocal.m4 autom4te.cache config.h.in configure depcomp hello.c install-sh missing doc/api doc/developers rm -rf Makefile.in aclocal.m4 autom4te.cache config.h.in configure depcomp hello.c install-sh missing doc/api doc/developers doc/coverage autoscan.log configure.scan
find . | grep \~$ | xargs rm -f find . | grep \~$ | xargs rm -f
find . -name '*.bb' | xargs rm -f
find . -name '*.bbg' | xargs rm -f
find . -name '*.da' | xargs rm -f
find . | perl -ne 'print if (/\/core(\.\d+)?$/)' | xargs rm -f find . | perl -ne 'print if (/\/core(\.\d+)?$/)' | xargs rm -f
find . | perl -ne 'print if (/\/Makefile.in$/)' | xargs rm -f find . | perl -ne 'print if (/\/Makefile.in$/)' | xargs rm -f
find . | perl -ne 'print if (/\/storefile.txt$/)' | xargs rm -f find . | perl -ne 'print if (/\/storefile.txt$/)' | xargs rm -f
find . | perl -ne 'print if (/\/logfile.txt$/)' | xargs rm -f find . | perl -ne 'print if (/\/logfile.txt$/)' | xargs rm -f
find . | perl -ne 'print if (/\/blob._file.txt$/)' | xargs rm -f find . | perl -ne 'print if (/\/blob._file.txt$/)' | xargs rm -f
rm -f test/gmon.out test/lladd/gmon.out

View file

@ -11,6 +11,7 @@ functionality in a modular way.</p>
<ul> <ul>
<li><a href="api/html/index.html">User Guide (API)</a></li> <li><a href="api/html/index.html">User Guide (API)</a></li>
<li><a href="developers/html/index.html">Documentation of LLADD's internals</a></li> <li><a href="developers/html/index.html">Documentation of LLADD's internals</a></li>
<li><a href="coverage/index.html">Unit Test Coverage Report</a></li>
</ul> </ul>
<hr> <hr>

View file

@ -83,8 +83,11 @@ void downgradelock(rwl * lock) {
assert(lock->writers); assert(lock->writers);
lock->writers--; lock->writers--;
lock->readers++; lock->readers++;
pthread_cond_signal (lock->writeOK); if(lock->waiting) {
pthread_cond_broadcast(lock->readOK); pthread_cond_signal (lock->writeOK);
} else {
pthread_cond_broadcast(lock->readOK);
}
pthread_mutex_unlock(lock->mut); pthread_mutex_unlock(lock->mut);
} }
@ -92,13 +95,18 @@ void unlock(rwl * lock) {
pthread_mutex_lock (lock->mut); pthread_mutex_lock (lock->mut);
if(lock->readers) { if(lock->readers) {
lock->readers--; lock->readers--;
pthread_cond_signal (lock->writeOK); if(lock->waiting) {
pthread_cond_signal (lock->writeOK);
}
} else { } else {
assert (lock->writers); assert (lock->writers);
lock->writers--; lock->writers--;
/* Need this as well (in case there's another writer, which is blocking the all of the readers. */ /* Need this as well (in case there's another writer, which is blocking the all of the readers. */
pthread_cond_signal (lock->writeOK); if(lock->waiting) {
pthread_cond_broadcast (lock->readOK); pthread_cond_signal (lock->writeOK);
} else {
pthread_cond_broadcast (lock->readOK);
}
} }
pthread_mutex_unlock (lock->mut); pthread_mutex_unlock (lock->mut);
} }

View file

@ -129,15 +129,15 @@ END_TEST
@todo: Until we have a non-idempotent operation on blobs, this test can't be written. @todo: Until we have a non-idempotent operation on blobs, this test can't be written.
*/ */
START_TEST (recoverBlob__exactlyOnce) { /* START_TEST (recoverBlob__exactlyOnce) {
int xid; int xid;
int j; int j;
int k; int k;
recordid rid; recordid rid;
/* if(1) { / * if(1) {
return; return;
} */ } * /
fail_unless(0, "Need to write this test..."); fail_unless(0, "Need to write this test...");
Tinit(); Tinit();
@ -161,7 +161,7 @@ START_TEST (recoverBlob__exactlyOnce) {
Tdeinit(); Tdeinit();
Tinit(); /* Runs recovery.. */ Tinit(); / * Runs recovery.. * /
k = 12312; k = 12312;
@ -180,7 +180,7 @@ START_TEST (recoverBlob__exactlyOnce) {
} }
END_TEST END_TEST
*/
/** /**
@test @test
Makes sure that aborted idempotent operations are correctly undone. Makes sure that aborted idempotent operations are correctly undone.
@ -266,15 +266,15 @@ END_TEST
@todo logical operations on blobs. @todo logical operations on blobs.
*/ */
START_TEST (recoverBlob__exactlyOnceAbort) { /* START_TEST (recoverBlob__exactlyOnceAbort) {
int xid; int xid;
int j; int j;
int k; int k;
recordid rid; recordid rid;
/* if(1) / * if(1)
return ; return ;
*/ * /
fail_unless(0, "Need to write this test..."); fail_unless(0, "Need to write this test...");
Tinit(); Tinit();
@ -311,20 +311,20 @@ START_TEST (recoverBlob__exactlyOnceAbort) {
} }
END_TEST END_TEST
*/
/** /**
@test @test
Check the CLR mechanism with an aborted logical operation, and multipl Tinit()/Tdeinit() cycles. Check the CLR mechanism with an aborted logical operation, and multipl Tinit()/Tdeinit() cycles.
@todo Devise a way of implementing this for blobs. @todo Devise a way of implementing this for blobs.
*/ */
START_TEST(recoverBlob__clr) { /*START_TEST(recoverBlob__clr) {
recordid rid; recordid rid;
int xid; int xid;
int j; int j;
int k; int k;
/* if(1) return; */ / * if(1) return; * /
fail_unless(0, "Need to write this test..."); fail_unless(0, "Need to write this test...");
@ -381,7 +381,7 @@ START_TEST(recoverBlob__clr) {
} END_TEST } END_TEST
*/
void simulateBufferManagerCrash(); void simulateBufferManagerCrash();
extern int numActiveXactions; extern int numActiveXactions;
/** /**
@ -550,22 +550,22 @@ Suite * check_suite(void) {
Suite *s = suite_create("recovery_suite"); Suite *s = suite_create("recovery_suite");
/* Begin a new test */ /* Begin a new test */
TCase *tc = tcase_create("recovery"); TCase *tc = tcase_create("recovery");
void * foobar; /* used to supress warnings. */ /* void * foobar; */ /* used to supress warnings. */
/* Sub tests are added, one per line, here */ /* Sub tests are added, one per line, here */
tcase_add_test(tc, recoverBlob__idempotent); tcase_add_test(tc, recoverBlob__idempotent);
/* tcase_add_test(tc, recoverBlob__exactlyOnce); */ /* tcase_add_test(tc, recoverBlob__exactlyOnce);
foobar = (void*)&recoverBlob__exactlyOnce; foobar = (void*)&recoverBlob__exactlyOnce; */
tcase_add_test(tc, recoverBlob__idempotentAbort); tcase_add_test(tc, recoverBlob__idempotentAbort);
/* tcase_add_test(tc, recoverBlob__exactlyOnceAbort); */ /* tcase_add_test(tc, recoverBlob__exactlyOnceAbort);
foobar = (void*)&recoverBlob__exactlyOnceAbort; foobar = (void*)&recoverBlob__exactlyOnceAbort;
/* tcase_add_test(tc, recoverBlob__clr); */ tcase_add_test(tc, recoverBlob__clr);
foobar = (void*)&recoverBlob__clr; foobar = (void*)&recoverBlob__clr; */
tcase_add_test(tc, recoverBlob__crash); tcase_add_test(tc, recoverBlob__crash);
/* tcase_add_test(tc, recoverBlob__multiple_xacts); */ tcase_add_test(tc, recoverBlob__multiple_xacts);
foobar = (void*)&recoverBlob__multiple_xacts; /*foobar = (void*)&recoverBlob__multiple_xacts; */
/* --------------------------------------------- */ /* --------------------------------------------- */
tcase_add_checked_fixture(tc, setup, teardown); tcase_add_checked_fixture(tc, setup, teardown);

View file

@ -240,7 +240,7 @@ START_TEST(logWriterTruncate) {
} END_TEST } END_TEST
#define ENTRIES_PER_THREAD 1000 #define ENTRIES_PER_THREAD 2000
pthread_mutex_t random_mutex; pthread_mutex_t random_mutex;
@ -318,7 +318,7 @@ START_TEST(logWriterCheckWorker) {
START_TEST(logWriterCheckThreaded) { START_TEST(logWriterCheckThreaded) {
#define THREAD_COUNT 50 #define THREAD_COUNT 100
pthread_t workers[THREAD_COUNT]; pthread_t workers[THREAD_COUNT];
int i; int i;
pthread_mutex_init(&random_mutex, NULL); pthread_mutex_init(&random_mutex, NULL);