From 9268b1d9cf881e10c2c87813062212a0cf0064de Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Mon, 4 Oct 2004 05:24:12 +0000 Subject: [PATCH] Added support for gcov, and ran gprof. Shaved 10% off the runtime of check_page by optimizing rw.c --- Makefile.am | 14 ++++++++++- README | 24 +++++++++++++++++++ clean.sh | 7 ++++-- doc/index.html | 1 + src/libdfa/rw.c | 18 ++++++++++---- test/lladd/check_blobRecovery.c | 42 ++++++++++++++++----------------- test/lladd/check_logWriter.c | 4 ++-- 7 files changed, 79 insertions(+), 31 deletions(-) diff --git a/Makefile.am b/Makefile.am index c699ace..83e9517 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,4 +6,16 @@ docs: doxygen doc/Doxyfile-api doxygen doc/Doxyfile-developers -.PHONY: docs \ No newline at end of file +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 \ No newline at end of file diff --git a/README b/README index af2e1ea..f6c6726 100644 --- a/README +++ b/README @@ -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 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. + +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. \ No newline at end of file diff --git a/clean.sh b/clean.sh index 06b9f2e..ed08e1a 100755 --- a/clean.sh +++ b/clean.sh @@ -1,10 +1,13 @@ #! /bin/sh 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 . -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 (/\/Makefile.in$/)' | 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 (/\/blob._file.txt$/)' | xargs rm -f - +rm -f test/gmon.out test/lladd/gmon.out diff --git a/doc/index.html b/doc/index.html index 56332a3..02e368d 100644 --- a/doc/index.html +++ b/doc/index.html @@ -11,6 +11,7 @@ functionality in a modular way.


diff --git a/src/libdfa/rw.c b/src/libdfa/rw.c index f7ca7a5..c03f6c1 100644 --- a/src/libdfa/rw.c +++ b/src/libdfa/rw.c @@ -83,8 +83,11 @@ void downgradelock(rwl * lock) { assert(lock->writers); lock->writers--; lock->readers++; - pthread_cond_signal (lock->writeOK); - pthread_cond_broadcast(lock->readOK); + if(lock->waiting) { + pthread_cond_signal (lock->writeOK); + } else { + pthread_cond_broadcast(lock->readOK); + } pthread_mutex_unlock(lock->mut); } @@ -92,13 +95,18 @@ void unlock(rwl * lock) { pthread_mutex_lock (lock->mut); if(lock->readers) { lock->readers--; - pthread_cond_signal (lock->writeOK); + if(lock->waiting) { + pthread_cond_signal (lock->writeOK); + } } else { assert (lock->writers); lock->writers--; /* Need this as well (in case there's another writer, which is blocking the all of the readers. */ - pthread_cond_signal (lock->writeOK); - pthread_cond_broadcast (lock->readOK); + if(lock->waiting) { + pthread_cond_signal (lock->writeOK); + } else { + pthread_cond_broadcast (lock->readOK); + } } pthread_mutex_unlock (lock->mut); } diff --git a/test/lladd/check_blobRecovery.c b/test/lladd/check_blobRecovery.c index e3ee2ca..092385a 100644 --- a/test/lladd/check_blobRecovery.c +++ b/test/lladd/check_blobRecovery.c @@ -129,15 +129,15 @@ END_TEST @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 j; int k; recordid rid; - /* if(1) { + / * if(1) { return; - } */ + } * / fail_unless(0, "Need to write this test..."); Tinit(); @@ -161,7 +161,7 @@ START_TEST (recoverBlob__exactlyOnce) { Tdeinit(); - Tinit(); /* Runs recovery.. */ + Tinit(); / * Runs recovery.. * / k = 12312; @@ -180,7 +180,7 @@ START_TEST (recoverBlob__exactlyOnce) { } END_TEST - +*/ /** @test Makes sure that aborted idempotent operations are correctly undone. @@ -266,15 +266,15 @@ END_TEST @todo logical operations on blobs. */ -START_TEST (recoverBlob__exactlyOnceAbort) { +/* START_TEST (recoverBlob__exactlyOnceAbort) { int xid; int j; int k; recordid rid; - /* if(1) + / * if(1) return ; - */ + * / fail_unless(0, "Need to write this test..."); Tinit(); @@ -311,20 +311,20 @@ START_TEST (recoverBlob__exactlyOnceAbort) { } END_TEST - +*/ /** @test Check the CLR mechanism with an aborted logical operation, and multipl Tinit()/Tdeinit() cycles. @todo Devise a way of implementing this for blobs. */ -START_TEST(recoverBlob__clr) { +/*START_TEST(recoverBlob__clr) { recordid rid; int xid; int j; int k; - /* if(1) return; */ + / * if(1) return; * / fail_unless(0, "Need to write this test..."); @@ -381,7 +381,7 @@ START_TEST(recoverBlob__clr) { } END_TEST - +*/ void simulateBufferManagerCrash(); extern int numActiveXactions; /** @@ -550,22 +550,22 @@ Suite * check_suite(void) { Suite *s = suite_create("recovery_suite"); /* Begin a new test */ 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 */ tcase_add_test(tc, recoverBlob__idempotent); - /* tcase_add_test(tc, recoverBlob__exactlyOnce); */ - foobar = (void*)&recoverBlob__exactlyOnce; + /* tcase_add_test(tc, recoverBlob__exactlyOnce); + foobar = (void*)&recoverBlob__exactlyOnce; */ tcase_add_test(tc, recoverBlob__idempotentAbort); - /* tcase_add_test(tc, recoverBlob__exactlyOnceAbort); */ - foobar = (void*)&recoverBlob__exactlyOnceAbort; + /* tcase_add_test(tc, recoverBlob__exactlyOnceAbort); + foobar = (void*)&recoverBlob__exactlyOnceAbort; - /* tcase_add_test(tc, recoverBlob__clr); */ - foobar = (void*)&recoverBlob__clr; + tcase_add_test(tc, recoverBlob__clr); + foobar = (void*)&recoverBlob__clr; */ tcase_add_test(tc, recoverBlob__crash); - /* tcase_add_test(tc, recoverBlob__multiple_xacts); */ - foobar = (void*)&recoverBlob__multiple_xacts; + tcase_add_test(tc, recoverBlob__multiple_xacts); + /*foobar = (void*)&recoverBlob__multiple_xacts; */ /* --------------------------------------------- */ tcase_add_checked_fixture(tc, setup, teardown); diff --git a/test/lladd/check_logWriter.c b/test/lladd/check_logWriter.c index e8bce97..826c4c9 100644 --- a/test/lladd/check_logWriter.c +++ b/test/lladd/check_logWriter.c @@ -240,7 +240,7 @@ START_TEST(logWriterTruncate) { } END_TEST -#define ENTRIES_PER_THREAD 1000 +#define ENTRIES_PER_THREAD 2000 pthread_mutex_t random_mutex; @@ -318,7 +318,7 @@ START_TEST(logWriterCheckWorker) { START_TEST(logWriterCheckThreaded) { -#define THREAD_COUNT 50 +#define THREAD_COUNT 100 pthread_t workers[THREAD_COUNT]; int i; pthread_mutex_init(&random_mutex, NULL);