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
+2004-10-30 Ken Raeburn <raeburn@mit.edu>
+
+ * 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 <raeburn@mit.edu>
Permit exporting profile file data into a buffer.
static void profile_free_file_data(prf_data_t);
+#if 0
+
#define scan_shared_trees_locked() \
{ \
prf_data_t d; \
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
errcode_t retval;
#ifdef HAVE_STAT
struct stat st;
+#ifdef STAT_ONCE_PER_SECOND
+ time_t now;
+#endif
#endif
FILE *f;
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;
#include "com_err.h"
#include "profile.h"
+#define STAT_ONCE_PER_SECOND
+
#if defined(_WIN32)
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
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 */