[krbdev.mit.edu #2791] CVS Commit

Ken Raeburn via RT rt-comment at krbdev.mit.edu
Mon Dec 6 17:00:32 EST 2004


Finish the hooks (left disabled by default) for logging somewhere the recorded
timing behavior relating to the use of locks in the krb5 code.

Currently, "reporting" means writing to /dev/tty or stderr, and the data is the
number of times a mutex is locked, file and line where it was created,
min/avg/max/stddev wait times to acquire the lock and hold times, and stats are
only written out for locks that were locked a certain minimum number of times
and with a minimum average wait time.

The criteria are all controlled in threads.c, and k5-thread.h just has the
hooks for gathering data.  So turning on/off the data gathering requires a full
rebuild, but tweaking the reporting is mostly just a relinking pass.  (May also
require adding a dependence on the math library to the support library; for a
static build that may impact a lot of makefiles.)

* include/k5-thread.h [DEBUG_THREADS_STATS]: Include string.h and inttypes.h.
(get_current_time) [DEBUG_THREADS_STATS]: Define as inline.
(k5_mutex_init_stats) [DEBUG_THREADS_STATS]: Save away current time as creation
time.
(k5_mutex_stats_tmp): New typedef, k5_debug_time_t if recording stats, dummy
int otherwise.
(k5_mutex_stats_start): New macro, get current time if recording, zero
otherwise.
(krb5int_mutex_lock_update_stats, krb5int_mutex_unlock_update_stats,
krb5int_mutex_report_stats) [DEBUG_THREADS_STATS]: Declare.
(krb5int_mutex_report_stats) [! DEBUG_THREADS_STATS]: New macro, does nothing.
(k5_mutex_lock_update_stats, k5_mutex_unlock_update_stats): New macros, map to
krb5int_ functions if recording, dummy statements otherwise.
(k5_mutex_destroy): Call krb5int_mutex_report_stats.
(k5_mutex_lock, k5_mutex_lock_1): Call k5_mutex_stats_start and
k5_mutex_lock_update_stats.
(k5_mutex_unlock_1): Call k5_mutex_unlock_update_stats.

* util/support/threads.c [DEBUG_THREADS_STATS]: Include stdio.h.
(stats_logfile) [DEBUG_THREADS_STATS]: New variable.
(krb5int_thread_support_init) [DEBUG_THREADS_STATS]: Set it to point to a file
on /dev/tty or stderr.
(krb5int_thread_support_fini) [DEBUG_THREADS_STATS]: Flush it.
(k5_mutex_lock_update_stats, krb5int_mutex_unlock_update_stats, get_stddev,
krb5int_mutex_report_stats) [DEBUG_THREADS_STATS]: New functions.
* util/support/libkrb5support.exports: Add krb5int_mutex_*_stats.


To generate a diff of this commit:



	cvs diff -r1.476 -r1.477 krb5/src/include/ChangeLog
	cvs diff -r1.22 -r1.23 krb5/src/include/k5-thread.h
		krb5/src/util/support/ChangeLog
	cvs diff -r1.13 -r1.14 krb5/src/util/support/Makefile.in
	cvs diff -r1.4 -r1.5 krb5/src/util/support/libkrb5support.exports
	cvs diff -r1.12 -r1.13 krb5/src/util/support/threads.c 


More information about the krb5-bugs mailing list