Fix bug #8395 - optimize serverid_exists() for Solaris.
authorIra Cooper <ira@wakeful.net>
Mon, 22 Aug 2011 19:46:41 +0000 (12:46 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 23 Aug 2011 18:29:56 +0000 (20:29 +0200)
jra asked:

    Do you have any idea on how many calls it saves,
    and what help the optimization gives ?

As far as calls: Not 100% sure, dtrace pointed the issue out to me, and when I
saw 10-50%(Or more), I looked for an easy fix.

The real expense here is the fnctl locks on the database.  That's pretty
painful.  1000ns per call, and probably 3-4 calls in that chain.  So it doesn't
take much to come out ahead was my math.

source3/lib/serverid.c

index b1f6a5711ef65abac9d7939f600c9cca143066bf..8cd7f5a82c881e8fba63b0c7a3154b9cdf16afb5 100644 (file)
@@ -233,7 +233,11 @@ bool serverid_exists(const struct server_id *id)
        struct serverid_key key;
        TDB_DATA tdbkey;
 
-       if (lp_clustering() && !process_exists(*id)) {
+       if (procid_is_me(id)) {
+               return true;
+       }
+
+       if (!process_exists(*id)) {
                return false;
        }