test - Add lockmgr1, lockmgr2, lockmgr3 tests
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Oct 2017 01:59:18 +0000 (18:59 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 31 Oct 2017 17:49:48 +0000 (10:49 -0700)
* Add tests which perform various system calls intended to exercise
  lockmgr() locks.

* Generally shows a roughly 40% improvement in SMP performance
  from the recent lockmgr changes when shared locks have high
  collision rates.

test/sysperf/Makefile
test/sysperf/lockmgr1.c [new file with mode: 0644]
test/sysperf/lockmgr2.c [new file with mode: 0644]
test/sysperf/lockmgr3.c [new file with mode: 0644]

index d5bd58b..b8e7aa4 100644 (file)
@@ -11,6 +11,7 @@ TARGETS=/tmp/sc1 /tmp/sc2 /tmp/sc3 /tmp/sc4 /tmp/sc5 /tmp/sc6 /tmp/sc7 \
        /tmp/mem1 /tmp/mem2 \
        /tmp/cld1 \
        /tmp/rr1 \
+       /tmp/lockmgr1 /tmp/lockmgr2 /tmp/lockmgr3 \
        /tmp/loop900k /tmp/pipe900k /tmp/sleep900k
 
 .if defined(NO_OPTIMIZE)
@@ -130,6 +131,15 @@ all:       $(TARGETS)
 /tmp/rr1: randread.c blib.c
        $(CC) $(CFLAGS) randread.c blib.c -o /tmp/rr1
 
+/tmp/lockmgr1: lockmgr1.c blib.c
+       $(CC) lockmgr1.c blib.c -o /tmp/lockmgr1
+
+/tmp/lockmgr2: lockmgr2.c blib.c
+       $(CC) lockmgr2.c blib.c -o /tmp/lockmgr2
+
+/tmp/lockmgr3: lockmgr3.c blib.c
+       $(CC) lockmgr3.c blib.c -o /tmp/lockmgr3
+
 /tmp/loop900k: loop900k.c
        $(CC) $(CFLAGS) loop900k.c -o /tmp/loop900k -static
 
diff --git a/test/sysperf/lockmgr1.c b/test/sysperf/lockmgr1.c
new file mode 100644 (file)
index 0000000..2bde240
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * varsym..c
+ *
+ * varsym [threads]
+ *
+ * tests shared lock using varsym_get()
+ */
+
+#include "blib.h"
+#include <sys/varsym.h>
+
+int
+main(int ac, char **av)
+{
+       long long count = 0;
+       long long max;
+       char c;
+       int n;
+       int i;
+       int j;
+       int status;
+       char buf[256];
+
+       printf("timing standard varsym_get() syscall, VARSYM_SYS\n");
+
+       start_timing();
+       while (stop_timing(0, NULL) == 0) {
+               varsym_get(VARSYM_SYS_MASK, "fubar", buf, sizeof(buf));
+               ++count;
+       }
+       max = count * 4;
+
+       if (ac > 1)
+               n = strtol(av[1], NULL, 0);
+       else
+               n = 1;
+
+       start_timing();
+       for (i = 0; i < n; ++i) {
+               if (fork() == 0) {
+                       for (count = 0; count < max; ++count) {
+                               varsym_get(VARSYM_SYS_MASK, "fubar",
+                                          buf, sizeof(buf));
+                       }
+                       _exit(0);
+               }
+       }
+       while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
+               ;
+       stop_timing(max * n, "varsym1");
+
+       return(0);
+}
diff --git a/test/sysperf/lockmgr2.c b/test/sysperf/lockmgr2.c
new file mode 100644 (file)
index 0000000..435486d
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * varsym..c
+ *
+ * varsym [threads]
+ *
+ * tests shared lock using varsym_get()
+ */
+
+#include "blib.h"
+#include <sys/file.h>
+#include <assert.h>
+
+int
+main(int ac, char **av)
+{
+       long long count = 0;
+       long long max;
+       char c;
+       int n;
+       int i;
+       int j;
+       int fd;
+       int status;
+       char *path;
+       char buf[256];
+       struct stat st;
+
+       printf("timing standard fstat() syscall\n");
+
+       close(open("/tmp/lockmgr2.test", O_RDWR|O_CREAT, 0666));
+       start_timing();
+       while (stop_timing(0, NULL) == 0) {
+               fd = open("/tmp/lockmgr2.test", O_RDONLY, 0666);
+               assert(fd >= 0);
+               fstat(fd, &st);
+               close(fd);
+               ++count;
+       }
+       max = count;
+       close(fd);
+
+       if (ac > 1)
+               n = strtol(av[1], NULL, 0);
+       else
+               n = 1;
+
+       start_timing();
+       for (i = 0; i < n; ++i) {
+               asprintf(&path, "/tmp/lockmgr.test");
+               close(open(path, O_RDWR|O_CREAT, 0666));
+               if (fork() == 0) {
+                       for (count = 0; count < max; ++count) {
+                               fd = open(path, O_RDONLY, 0666);
+                               assert(fd >= 0);
+                               fstat(fd, &st);
+                               close(fd);
+                       }
+                       _exit(0);
+               }
+       }
+       while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
+               ;
+       stop_timing(max * n, "lockmgr2");
+
+       return(0);
+}
diff --git a/test/sysperf/lockmgr3.c b/test/sysperf/lockmgr3.c
new file mode 100644 (file)
index 0000000..edbded9
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * varsym..c
+ *
+ * varsym [threads]
+ *
+ * tests shared lock using varsym_get()
+ */
+
+#include "blib.h"
+#include <sys/file.h>
+#include <assert.h>
+
+int
+main(int ac, char **av)
+{
+       long long count = 0;
+       long long max;
+       char c;
+       int n;
+       int i;
+       int j;
+       int fd;
+       int status;
+       char *path;
+       char buf[256];
+       struct stat st;
+
+       printf("timing standard fstat() syscall\n");
+
+       fd = open("/tmp/lockmgr3.test", O_RDWR|O_CREAT, 0666);
+       assert(fd >= 0);
+       start_timing();
+       while (stop_timing(0, NULL) == 0) {
+               fstat(fd, &st);
+               fstat(fd, &st);
+               fstat(fd, &st);
+               fstat(fd, &st);
+               ++count;
+       }
+       max = count * 4;
+       close(fd);
+
+       if (ac > 1)
+               n = strtol(av[1], NULL, 0);
+       else
+               n = 1;
+
+       start_timing();
+       for (i = 0; i < n; ++i) {
+               if (fork() == 0) {
+                       asprintf(&path, "/tmp/lockmgr.test");
+                       fd = open(path, O_RDWR|O_CREAT, 0666);
+                       assert(fd >= 0);
+                       for (count = 0; count < max; ++count) {
+                               fstat(fd, &st);
+                               fstat(fd, &st);
+                               fstat(fd, &st);
+                               fstat(fd, &st);
+                       }
+                       _exit(0);
+               }
+       }
+       while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
+               ;
+       stop_timing(max * n * 4, "lockmgr3");
+
+       return(0);
+}