This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Bug 16104: Print statistics about nscd client-local cache searches.


How much of a pseudo-ABI is the output of `nscd -g'?

There are some tools which consider the output of their tools
to be sacrosanct and not subject to major change.

My opinion is that `nscd -g' output is fair game to change
as much as we want.

In bug 16104 I'm proposing we add a new statistic to be collected
and printed by nscd. It would add a new line to the output.

The problem at hand is that nscd allows a client to request
an fd which it then uses to mmap the entire cache RO into client-local
memory and perform the cache search itself. Obviously in this case
the client can't update the server statistics.

However, the server can record that such a request for an fd was made,
and that's the statistic I'm suggesting we record and report for each

I've stolen 64-bits from the extra_data field e.g. entries 3
and 4 which we don't use. This means that the persistent db storage
header remains the same size even after upgrade to the new nscd
and this field was previously zero so that works.

We would print "client-side cache searches" as the new statistic.


Is this even an acceptable thing to do?

I don't see any easier way to provide some honesty to the statistics
that doesn't slow down nscd...

2013-11-02  Carlos O'Donell  <>

	* nscd/connections.c (handle_request): Record request
	for client-side cache search.
	* nscd/nscd-client.h (struct database_pers_head):
	Shrink extra_data and add shmemuse keeping struct the
	same size.
	* nscd/nscd_stat.c (struct dbstat): Add shmemuse.
	(send_stats): Copy shmemuse.
	(receive_print_stats): Print shmemuse.

diff --git a/nscd/connections.c b/nscd/connections.c
index e54d4f2..31b0d65 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -1391,6 +1391,8 @@ request from '%s' [%ld] not handled due to missing permission"),
     case GETFDSERV:
     case GETFDNETGR:
 #ifdef SCM_RIGHTS
+      /* Record the client-side request to search the cache.  */
+      ++reqinfo[req->type].db->head->shmemuse;
       send_ro_fd (reqinfo[req->type].db, key, fd);
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index 360852b..0810afb 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -278,7 +278,11 @@ struct database_pers_head
   volatile int32_t nscd_certainly_running;
   volatile nscd_time_t timestamp;
   /* Room for extensions.  */
-  volatile uint32_t extra_data[4];
+  volatile uint32_t extra_data[2];
+  /* The number of times a client requests shared-memory
+     access to the cache.  */
+  uint64_t shmemuse;
   nscd_ssize_t module;
   nscd_ssize_t data_size;
diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c
index 3df4273..462c0eb 100644
--- a/nscd/nscd_stat.c
+++ b/nscd/nscd_stat.c
@@ -66,6 +66,13 @@ struct dbstat
   uintmax_t wrlockdelayed;
   uintmax_t addfailed;
+  /* The number of times the client has requested
+     a read-only shared memory map of the database
+     in order to do it's own searching. The server
+     statistics can't be updated in this case, but
+     we can track how many times this has happened.  */
+  uintmax_t shmemuse;
 /* Record for transmitting statistics.  */
@@ -129,6 +136,7 @@ send_stats (int fd, struct database_dyn dbs[lastdb])
 	  data.dbs[cnt].rdlockdelayed = dbs[cnt].head->rdlockdelayed;
 	  data.dbs[cnt].wrlockdelayed = dbs[cnt].head->wrlockdelayed;
 	  data.dbs[cnt].addfailed = dbs[cnt].head->addfailed;
+	  data.dbs[cnt].shmemuse = dbs[cnt].head->shmemuse;
@@ -286,6 +294,7 @@ receive_print_stats (void)
 		"%15" PRIuMAX "  cache misses on positive entries\n"
 		"%15" PRIuMAX "  cache misses on negative entries\n"
 		"%15lu%% cache hit rate\n"
+		"%15" PRIuMAX "  client-side cache searches\n"
 		"%15zu  current number of cached values\n"
 		"%15zu  maximum number of cached values\n"
 		"%15zu  maximum chain length searched\n"
@@ -300,6 +309,7 @@ receive_print_stats (void)
 	      data.dbs[i].poshit, data.dbs[i].neghit,
 	      data.dbs[i].posmiss, data.dbs[i].negmiss,
 	      (100 * hit) / all,
+	      data.dbs[i].shmemuse,
 	      data.dbs[i].nentries, data.dbs[i].maxnentries,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]