From 8a3056e4865063e4b2c2dce9d3316ae5526839da Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sat, 30 Oct 2004 05:43:18 +0000 Subject: [PATCH] call stat less often on krb5.conf Changes suggested by lxs to reduce stat frequency to once per second. In parallel loops creating and destroying krb5 contexts on Mac OS X, this seems to improve performance by 10%, though it's hard to be sure because the times are variable. * prof_int.h (STAT_ONCE_PER_SECOND): Define. (struct _prf_data_t) [STAT_ONCE_PER_SECOND]: New field LAST_STAT. * prof_file.c (scan_shared_trees_locked, scan_shared_trees_unlocked): Redefine to do nothing for now. (profile_update_file_data) [STAT_ONCE_PER_SECOND]: If the current time is the same time as the last stat of the file, just return; otherwise, save away the current time. ticket: new status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16847 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 10 ++++++++++ src/util/profile/prof_file.c | 22 ++++++++++++++++++++++ src/util/profile/prof_int.h | 5 +++++ 3 files changed, 37 insertions(+) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 1366bd4d1..79a263f95 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,13 @@ +2004-10-30 Ken Raeburn + + * prof_int.h (STAT_ONCE_PER_SECOND): Define. + (struct _prf_data_t) [STAT_ONCE_PER_SECOND]: New field LAST_STAT. + * prof_file.c (scan_shared_trees_locked, + scan_shared_trees_unlocked): Redefine to do nothing for now. + (profile_update_file_data) [STAT_ONCE_PER_SECOND]: If the current + time is the same time as the last stat of the file, just return; + otherwise, save away the current time. + 2004-10-26 Ken Raeburn Permit exporting profile file data into a buffer. diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index f47e5404b..028253720 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -66,6 +66,8 @@ void profile_library_finalizer(void) static void profile_free_file_data(prf_data_t); +#if 0 + #define scan_shared_trees_locked() \ { \ prf_data_t d; \ @@ -89,6 +91,13 @@ static void profile_free_file_data(prf_data_t); k5_mutex_unlock(&g_shared_trees_mutex); \ } +#else + +#define scan_shared_trees_locked() { ; } +#define scan_shared_trees_unlocked() { ; } + +#endif + static int rw_access(const_profile_filespec_t filespec) { #ifdef HAVE_ACCESS @@ -295,6 +304,9 @@ errcode_t profile_update_file_data(prf_data_t data) errcode_t retval; #ifdef HAVE_STAT struct stat st; +#ifdef STAT_ONCE_PER_SECOND + time_t now; +#endif #endif FILE *f; @@ -303,11 +315,21 @@ errcode_t profile_update_file_data(prf_data_t data) return retval; #ifdef HAVE_STAT +#ifdef STAT_ONCE_PER_SECOND + now = time(0); + if (now == data->last_stat) { + k5_mutex_unlock(&data->lock); + return 0; + } +#endif if (stat(data->filespec, &st)) { retval = errno; k5_mutex_unlock(&data->lock); return retval; } +#ifdef STAT_ONCE_PER_SECOND + data->last_stat = now; +#endif if (st.st_mtime == data->timestamp) { k5_mutex_unlock(&data->lock); return 0; diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index d2761228c..b7c90961e 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -14,6 +14,8 @@ #include "com_err.h" #include "profile.h" +#define STAT_ONCE_PER_SECOND + #if defined(_WIN32) #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 @@ -36,6 +38,9 @@ struct _prf_data_t { k5_mutex_t lock; char *comment; struct profile_node *root; +#ifdef STAT_ONCE_PER_SECOND + time_t last_stat; +#endif time_t timestamp; /* time tree was last updated from file */ int flags; /* r/w, dirty */ int upd_serial; /* incremented when data changes */ -- 2.26.2