pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/will-it-scale-git: import will-it-scale-0nb20180303



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Mar 3 01:23:55 2018 +0100
Changeset:	d534c166e018ba921598e9a58e43a37325b2635a

Added Files:
	will-it-scale-git/DESCR
	will-it-scale-git/Makefile
	will-it-scale-git/PLIST
	will-it-scale-git/distinfo
	will-it-scale-git/patches/patch-Makefile
	will-it-scale-git/patches/patch-main.c
	will-it-scale-git/patches/patch-tests_eventfd1.c
	will-it-scale-git/patches/patch-tests_fallocate1.c
	will-it-scale-git/patches/patch-tests_futex1.c
	will-it-scale-git/patches/patch-tests_futex2.c
	will-it-scale-git/patches/patch-tests_futex3.c
	will-it-scale-git/patches/patch-tests_futex4.c

Log Message:
wip/will-it-scale-git: import will-it-scale-0nb20180303

Will It Scale takes a testcase and runs it from 1 through to n parallel copies
to see if the testcase will scale. It builds both a process and threads based
test in order to see any differences between the two.

We rely on hwloc for a platform independent way of laying out tasks on cores.
It can be found at www.open-mpi.org/projects/hwloc/.

Care is taken to try and reduce run to run variability. By using hwloc we ensure
each task is on its own core and won't get bounced around by the scheduler. The
wrapper script (runtest.py) turns off address space randomisation which can
cause huge differences in pagetable related benchmarks (one run may fit within
one pte page, the next may span two). There is a warmup period before which an
average is taken. The averaging period can be changed with the -s option, which
by default is 5 seconds.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d534c166e018ba921598e9a58e43a37325b2635a

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 will-it-scale-git/DESCR                            |  14 ++
 will-it-scale-git/Makefile                         |  17 +++
 will-it-scale-git/PLIST                            |   1 +
 will-it-scale-git/distinfo                         |  10 ++
 will-it-scale-git/patches/patch-Makefile           |  21 +++
 will-it-scale-git/patches/patch-main.c             | 150 +++++++++++++++++++++
 will-it-scale-git/patches/patch-tests_eventfd1.c   |  20 +++
 will-it-scale-git/patches/patch-tests_fallocate1.c |  20 +++
 will-it-scale-git/patches/patch-tests_futex1.c     |  19 +++
 will-it-scale-git/patches/patch-tests_futex2.c     |  19 +++
 will-it-scale-git/patches/patch-tests_futex3.c     |  22 +++
 will-it-scale-git/patches/patch-tests_futex4.c     |  19 +++
 12 files changed, 332 insertions(+)

diffs:
diff --git a/will-it-scale-git/DESCR b/will-it-scale-git/DESCR
new file mode 100644
index 0000000000..68ca4d0463
--- /dev/null
+++ b/will-it-scale-git/DESCR
@@ -0,0 +1,14 @@
+Will It Scale takes a testcase and runs it from 1 through to n parallel copies
+to see if the testcase will scale. It builds both a process and threads based
+test in order to see any differences between the two.
+
+We rely on hwloc for a platform independent way of laying out tasks on cores.
+It can be found at www.open-mpi.org/projects/hwloc/.
+
+Care is taken to try and reduce run to run variability. By using hwloc we ensure
+each task is on its own core and won't get bounced around by the scheduler. The
+wrapper script (runtest.py) turns off address space randomisation which can
+cause huge differences in pagetable related benchmarks (one run may fit within
+one pte page, the next may span two). There is a warmup period before which an
+average is taken. The averaging period can be changed with the -s option, which
+by default is 5 seconds.
diff --git a/will-it-scale-git/Makefile b/will-it-scale-git/Makefile
new file mode 100644
index 0000000000..75cef596ae
--- /dev/null
+++ b/will-it-scale-git/Makefile
@@ -0,0 +1,17 @@
+# $NetBSD$
+
+DISTNAME=	will-it-scale-0
+CATEGORIES=	benchmarks
+GIT_REPO=	git%github.com@localhost:antonblanchard/will-it-scale.git
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://github.com/antonblanchard/will-it-scale/
+COMMENT=	hwloc benchmark
+#LICENSE=	# none
+
+USE_TOOLS+=	gmake
+
+.include "../../wip/mk/git-package.mk"
+
+.include "../../parallel/hwloc/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/will-it-scale-git/PLIST b/will-it-scale-git/PLIST
new file mode 100644
index 0000000000..48d96a5493
--- /dev/null
+++ b/will-it-scale-git/PLIST
@@ -0,0 +1 @@
+@comment $NetBSD$
diff --git a/will-it-scale-git/distinfo b/will-it-scale-git/distinfo
new file mode 100644
index 0000000000..97e515e50c
--- /dev/null
+++ b/will-it-scale-git/distinfo
@@ -0,0 +1,10 @@
+$NetBSD$
+
+SHA1 (patch-Makefile) = fdf09838fe367c554f108aa92aef76264b790512
+SHA1 (patch-main.c) = 9646ce29dca1269597d77c06c695fcbfecf34414
+SHA1 (patch-tests_eventfd1.c) = 290598658b7cbf564b0b34317f0f2c550b243fde
+SHA1 (patch-tests_fallocate1.c) = b6820c120ce5b8e1ddf7bbc925a17f567d5a9df5
+SHA1 (patch-tests_futex1.c) = a45ffd09e0300e5f6c2b70d95fb3a2454112e588
+SHA1 (patch-tests_futex2.c) = ef36e22c01b00ea486bd139a361313c3269a3c2d
+SHA1 (patch-tests_futex3.c) = 6df2ef0e44085aa8829d66a9b7d591fc18b2adf7
+SHA1 (patch-tests_futex4.c) = cb80519781bd1b8f5539f3080379159f36b2476a
diff --git a/will-it-scale-git/patches/patch-Makefile b/will-it-scale-git/patches/patch-Makefile
new file mode 100644
index 0000000000..20445a6f6a
--- /dev/null
+++ b/will-it-scale-git/patches/patch-Makefile
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- Makefile.orig	2018-03-02 23:24:04.000000000 +0000
++++ Makefile
+@@ -1,5 +1,5 @@
+-CFLAGS=-Wall -O2 -g
+-LDFLAGS=-lhwloc
++CFLAGS+=-Wall -O2 -g
++LDFLAGS+=-lhwloc
+ 
+ processes := $(patsubst tests/%.c,%_processes,$(wildcard tests/*.c))
+ threads := $(patsubst tests/%.c,%_threads,$(wildcard tests/*.c))
+@@ -10,7 +10,7 @@ processes: $(processes)
+ 
+ threads: $(threads)
+ 
+-posix_semaphore1_processes_FLAGS=-lpthread
++posix_semaphore1_processes_FLAGS+=-lpthread
+ 
+ $(processes): %_processes: tests/%.o main.c
+ 	$(CC) $(CFLAGS) main.c $< $($@_FLAGS) $(LDFLAGS) -o $@
diff --git a/will-it-scale-git/patches/patch-main.c b/will-it-scale-git/patches/patch-main.c
new file mode 100644
index 0000000000..022d2344f3
--- /dev/null
+++ b/will-it-scale-git/patches/patch-main.c
@@ -0,0 +1,150 @@
+$NetBSD$
+
+--- main.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ main.c
+@@ -15,11 +15,31 @@
+ #include <string.h>
+ #include <sys/mman.h>
+ #include <hwloc.h>
++#if __linux__
+ #include <hwloc/glibc-sched.h>
++#endif
+ #include <sys/types.h>
+ #include <signal.h>
+ #include <poll.h>
+ 
++#ifdef __NetBSD__
++#define cpu_set_t cpuset_t
++#define sched_setaffinity sched_setaffinity_np
++#define sched_getaffinity sched_getaffinity_np
++static inline int
++hwloc_cpuset_to_glibc_sched_affinity(hwloc_topology_t topology __unused, hwloc_const_cpuset_t hwlocset,
++				    cpu_set_t *schedset, size_t schedsetsize)
++{
++  unsigned cpu;
++  cpuset_zero(schedset);
++  hwloc_bitmap_foreach_begin(cpu, hwlocset)
++    cpuset_set(cpu, schedset);
++  hwloc_bitmap_foreach_end();
++
++  return 0;
++}
++#endif
++
+ #define MAX_TASKS 1024
+ #define CACHELINE_SIZE 128
+ #define WARMUP_ITERATIONS 5
+@@ -103,11 +123,27 @@ void new_task(void *(func)(void *), void
+ 	pthread_create(&tid, NULL, func, arg);
+ }
+ 
++#ifdef __NetBSD__
++struct nb_args {
++	struct args *args;
++	cpuset_t *mask;
++};
++
++void *
++testcase_trampoline_nb(void *a)
++{
++	struct nb_args *A = (struct nb_args *)a;
++	pthread_setaffinity_np(pthread_self(), cpuset_size(A->mask), A->mask);
++	return testcase_trampoline(A->args);
++}
++#endif
++
+ void new_task_affinity(struct args *args,
+ 		       size_t cpuset_size, cpu_set_t *mask)
+ {
+-	pthread_attr_t attr;
+ 	pthread_t tid;
++#ifdef __linux__
++	pthread_attr_t attr;
+ 
+ 	pthread_attr_init(&attr);
+ 
+@@ -116,6 +152,13 @@ void new_task_affinity(struct args *args
+ 	pthread_create(&tid, &attr, testcase_trampoline, args);
+ 
+ 	pthread_attr_destroy(&attr);
++#else
++	struct nb_args nba = {
++		.args = args,
++		.mask = mask
++	};
++	pthread_create(&tid, NULL, testcase_trampoline_nb, &nba);
++#endif
+ }
+ 
+ /* All threads will die when we exit */
+@@ -169,10 +212,18 @@ void new_task(void *(func)(void *), void
+ void new_task_affinity(struct args *args,
+ 		       size_t cpuset_size, cpu_set_t *mask)
+ {
++#ifdef __linux__
+ 	cpu_set_t old_mask;
++#elif defined(__NetBSD__)
++	cpu_set_t *old_mask = cpuset_create();
++#endif
+ 	int pid;
+ 
+-	sched_getaffinity(0, sizeof(old_mask), &old_mask);
++	sched_getaffinity(0, sizeof(old_mask),
++#ifdef __linux__
++	&
++#endif
++	old_mask);
+ 	sched_setaffinity(0, cpuset_size, mask);
+ 
+ 	parent_pid = getpid();
+@@ -195,7 +246,15 @@ void new_task_affinity(struct args *args
+ 		testcase_trampoline(args);
+ 	}
+ 
+-	sched_setaffinity(0, sizeof(old_mask), &old_mask);
++	sched_setaffinity(0, sizeof(old_mask),
++#ifdef __linux__
++	&
++#endif
++	old_mask);
++
++#ifdef __NetBSD__
++	cpuset_destroy(old_mask);
++#endif
+ 
+ 	pids[nr_pids++] = pid;
+ }
+@@ -273,7 +332,11 @@ int main(int argc, char *argv[])
+ 			smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE);
+ 	for (i = 0; i < opt_tasks; i++) {
+ 		hwloc_obj_t obj;
++#if __linux__
+ 		cpu_set_t mask;
++#elif defined(__NetBSD__)
++		cpuset_t *mask = cpuset_create();
++#endif
+ 		struct args *args;
+ 
+ 		args = malloc(sizeof(struct args));
+@@ -290,8 +353,19 @@ int main(int argc, char *argv[])
+ 				smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE,
+ 				i % n);
+ 		hwloc_cpuset_to_glibc_sched_affinity(topology,
+-				obj->cpuset, &mask, sizeof(mask));
+-		new_task_affinity(args, sizeof(mask), &mask);
++				obj->cpuset,
++#ifdef	__linux__
++				&
++#endif
++				mask, sizeof(mask));
++		new_task_affinity(args, sizeof(mask),
++#ifdef __linux__
++				&
++#endif
++				mask);
++#ifdef __NetBSD__
++		cpuset_destroy(mask);
++#endif
+ 	}
+ 
+ 	if (write(fd[1], &i, 1) != 1) {
diff --git a/will-it-scale-git/patches/patch-tests_eventfd1.c b/will-it-scale-git/patches/patch-tests_eventfd1.c
new file mode 100644
index 0000000000..a94a097549
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_eventfd1.c
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- tests/eventfd1.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/eventfd1.c
+@@ -1,3 +1,4 @@
++#ifdef __linux__
+ #include <string.h>
+ #include <unistd.h>
+ #include <errno.h>
+@@ -31,3 +32,10 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
++#else
++char *testcase_description = "eventfd read/write of 8 bytes";
++
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif
diff --git a/will-it-scale-git/patches/patch-tests_fallocate1.c b/will-it-scale-git/patches/patch-tests_fallocate1.c
new file mode 100644
index 0000000000..a124c86c43
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_fallocate1.c
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- tests/fallocate1.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/fallocate1.c
+@@ -1,3 +1,4 @@
++#if __linux__
+ #define _GNU_SOURCE             /* See feature_test_macros(7) */
+ #include <errno.h>
+ #include <fcntl.h>
+@@ -32,4 +33,9 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
+-
++#else
++char *testcase_description = "Separate file fallocate ";
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif
diff --git a/will-it-scale-git/patches/patch-tests_futex1.c b/will-it-scale-git/patches/patch-tests_futex1.c
new file mode 100644
index 0000000000..b8e521a883
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_futex1.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- tests/futex1.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/futex1.c
+@@ -1,3 +1,4 @@
++#ifdef __linux__
+ #define _GNU_SOURCE
+ #include <unistd.h>
+ #include <sys/syscall.h>
+@@ -17,3 +18,9 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
++#else
++char *testcase_description = "futex(FUTEX_WAKE)";
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif
diff --git a/will-it-scale-git/patches/patch-tests_futex2.c b/will-it-scale-git/patches/patch-tests_futex2.c
new file mode 100644
index 0000000000..8c131a17b4
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_futex2.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- tests/futex2.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/futex2.c
+@@ -1,3 +1,4 @@
++#ifdef __linux__
+ #define _GNU_SOURCE
+ #include <unistd.h>
+ #include <sys/syscall.h>
+@@ -17,3 +18,9 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
++#else
++char *testcase_description = "futex(FUTEX_WAIT)";
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif
diff --git a/will-it-scale-git/patches/patch-tests_futex3.c b/will-it-scale-git/patches/patch-tests_futex3.c
new file mode 100644
index 0000000000..6958d5ebba
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_futex3.c
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- tests/futex3.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/futex3.c
+@@ -1,5 +1,7 @@
++#ifdef __linux__
+ #define _GNU_SOURCE
+ #include <unistd.h>
++
+ #include <sys/syscall.h>
+ #include <linux/futex.h>
+ 
+@@ -17,3 +19,9 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
++#else
++char *testcase_description = "futex(FUTEX_WAKE_PRIVATE)";
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif
diff --git a/will-it-scale-git/patches/patch-tests_futex4.c b/will-it-scale-git/patches/patch-tests_futex4.c
new file mode 100644
index 0000000000..b5e9398ae4
--- /dev/null
+++ b/will-it-scale-git/patches/patch-tests_futex4.c
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- tests/futex4.c.orig	2018-03-02 23:24:04.000000000 +0000
++++ tests/futex4.c
+@@ -1,3 +1,4 @@
++#ifdef __linux__
+ #define _GNU_SOURCE
+ #include <unistd.h>
+ #include <sys/syscall.h>
+@@ -17,3 +18,9 @@ void testcase(unsigned long long *iterat
+ 		(*iterations)++;
+ 	}
+ }
++#else
++char *testcase_description = "futex(FUTEX_WAIT_PRIVATE)";
++void testcase(unsigned long long *iterations, unsigned long nr)
++{
++}
++#endif


Home | Main Index | Thread Index | Old Index