Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
benchmark
will-it-scale
_service:obs_scm:will-it-scale-20210112T071724....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:will-it-scale-20210112T071724.a34a85c.obscpio of Package will-it-scale
07070100000000000081A40000000000000000000000015FFCB25400000035000000000000000000000000000000000000003100000000will-it-scale-20210112T071724.a34a85c/.gitignore*_processes *_threads tests/*.o *.csv *.title *.html 07070100000001000081A40000000000000000000000015FFCB25400000075000000000000000000000000000000000000003200000000will-it-scale-20210112T071724.a34a85c/.travis.ymllanguage: c cache: ccache os: - linux - linux-ppc64le addons: apt: packages: - libhwloc-dev script: make 07070100000002000081A40000000000000000000000015FFCB2540000021C000000000000000000000000000000000000002F00000000will-it-scale-20210112T071724.a34a85c/MakefileCFLAGS+=-Wall -O2 -g LDFLAGS+=-lhwloc processes := $(patsubst tests/%.c,%_processes,$(wildcard tests/*.c)) threads := $(patsubst tests/%.c,%_threads,$(wildcard tests/*.c)) all: processes threads processes: $(processes) threads: $(threads) posix_semaphore1_processes_FLAGS+=-lpthread $(processes): %_processes: tests/%.o main.c $(CC) $(CFLAGS) main.c $< $($@_FLAGS) $(LDFLAGS) -o $@ $(threads): %_threads: tests/%.o main.c $(CC) -DTHREADS $(CFLAGS) main.c $< -pthread $(LDFLAGS) -o $@ clean: rm -f tests/*.o *_processes *_threads 07070100000003000081A40000000000000000000000015FFCB25400000A46000000000000000000000000000000000000003000000000will-it-scale-20210112T071724.a34a85c/README.mdwill-it-scale ============= Overview -------- 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. Testcase design --------------- Each test has two required components. A testcase description: char *testcase_description = "Context switch via pipes"; and a testcase() which is passed a pointer to an iteration count that the testcase should increment. This testcase is run whatever number of times the user specifies on the command line via the -t option: void testcase(unsigned long long *iterations) A (not very useful) example: #include <sys/types.h> #include <unistd.h> char *testcase_description = "getppid"; void testcase(unsigned long long *iterations) { while (1) { getppid(); (*iterations)++; } } If you need to setup something globally such as a single file for all parallel testcases to operate on, there are two functions: void testcase_prepare(unsigned long nr_tasks) void testcase_cleanup(void) Finally if you need a new task such as when you want to write a context switch benchmark between two tasks, you can use: void new_task(void *(func)(void *), void *arg) This takes care of creating a new process or a new thread depending on which version of the test is being run. Quick start: make ./runalltests Postprocessing and graphing --------------------------- The graphing scripts use plotly, a client side javascript graphing package. To generate html files for generated results: ./postprocess.py Then load the generated html file in the browser. The graphs show number of tasks run on the x axis vs performance (in operations per second) on the left y axis. We also plot the amount of idle time against the right y axis. In the ideal case we should have an X pattern, with operations per second increasing and idle time decreasing. 07070100000004000081A40000000000000000000000015FFCB25400002085000000000000000000000000000000000000002D00000000will-it-scale-20210112T071724.a34a85c/main.c/* * Copyright (C) 2010 Anton Blanchard <anton@au.ibm.com>, IBM * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #define _GNU_SOURCE #include <sched.h> #include <unistd.h> #include <stdlib.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <hwloc.h> #include <sys/types.h> #include <signal.h> #include <poll.h> #include <sys/types.h> #include <sys/wait.h> #define MAX_TASKS 2048 #define MAX_CACHELINE_SIZE 256 #define WARMUP_ITERATIONS 5 extern char *testcase_description; extern void __attribute__((weak)) testcase_prepare(unsigned long nr_tasks) { } extern void __attribute__((weak)) testcase_cleanup(void) { } extern void *testcase(unsigned long long *iterations, unsigned long nr); static char *initialise_shared_area(unsigned long size) { char template[] = "/tmp/shared_area_XXXXXX"; int fd; char *m; int page_size = getpagesize(); /* Align to page boundary */ size = (size + page_size-1) & ~(page_size-1); fd = mkstemp(template); if (fd < 0) { perror("mkstemp"); exit(1); } if (ftruncate(fd, size) == -1) { perror("ftruncate"); unlink(template); exit(1); } m = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (m == MAP_FAILED) { perror("mmap"); unlink(template); exit(1); } memset(m, 0, size); unlink(template); return m; } static void usage(char *command) { printf("Usage: %s [options]\n\n", command); printf("\t-s iterations\tNumber of iterations to run\n"); printf("\t-t tasks\tNumber of threads or processes to run\n"); printf("\t-m\t\tAffinitize tasks on SMT threads (default cores)\n"); printf("\t-n\t\tNo affinity\n"); exit(1); } struct args { void *(*func)(unsigned long long *iterations, unsigned long nr); unsigned long long *arg1; unsigned long arg2; int poll_fd; hwloc_topology_t topology; hwloc_cpuset_t cpuset; }; static void *testcase_trampoline(void *p) { struct args *args = p; struct pollfd pfd = { args->poll_fd, POLLIN, 0 }; int ret; do { ret = poll(&pfd, 1, -1); } while ((ret == -1) && (errno == EINTR)); return args->func(args->arg1, args->arg2); } static bool use_affinity = true; #ifdef THREADS #include <pthread.h> static pthread_t threads[2*MAX_TASKS]; static int nr_threads; void new_task(void *(func)(void *), void *arg) { pthread_create(&threads[nr_threads++], NULL, func, arg); } static void *pre_trampoline(void *p) { struct args *args = p; if (use_affinity && hwloc_set_thread_cpubind(args->topology, pthread_self(), args->cpuset, 0) < 0) { perror("hwloc_set_thread_cpubind"); exit(1); } pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); return testcase_trampoline(args); } void new_task_affinity(struct args *args) { pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&threads[nr_threads++], &attr, pre_trampoline, args); pthread_attr_destroy(&attr); } /* All threads will die when we exit */ static void kill_tasks(void) { int i; for (i = 0; i < nr_threads; i++) { pthread_cancel(threads[i]); } for (i = 0; i < nr_threads; i++) { pthread_join(threads[i], NULL); } } #else #include <signal.h> static int pids[2*MAX_TASKS]; static int nr_pids; /* Watchdog used to make sure all children exit when the parent does */ static int parent_pid; static void watchdog(int junk) { if (kill(parent_pid, 0) == -1) exit(0); alarm(1); } void new_task(void *(func)(void *), void *arg) { int pid; parent_pid = getpid(); pid = fork(); if (pid < 0) { perror("fork"); exit(1); } if (!pid) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = watchdog; sa.sa_flags = SA_RESTART; sigaction(SIGALRM, &sa, NULL); alarm(1); func(arg); } pids[nr_pids++] = pid; } void new_task_affinity(struct args *args) { int pid; parent_pid = getpid(); pid = fork(); if (pid < 0) { perror("fork"); exit(1); } if (!pid) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = watchdog; sa.sa_flags = SA_RESTART; sigaction(SIGALRM, &sa, NULL); alarm(1); testcase_trampoline(args); } pids[nr_pids++] = pid; } static void kill_tasks(void) { int i; for (i = 0; i < nr_pids; i++) kill(pids[i], SIGTERM); for (i = 0; i < nr_pids; i++) waitpid(pids[i], NULL, 0); } #endif int main(int argc, char *argv[]) { int opt_tasks = 1; int opt_iterations = 0; int iterations = 0; int i, n; char *m; static unsigned long long *results[MAX_TASKS]; hwloc_topology_t topology; unsigned long long prev[MAX_TASKS] = {0, }; unsigned long long total = 0; int fd[2]; bool smt_affinity = false; struct args *args; bool verbose = false; while (1) { signed char c = getopt(argc, argv, "mt:s:hvn"); if (c < 0) break; switch (c) { case 'm': smt_affinity = true; break; case 't': opt_tasks = atoi(optarg); if (opt_tasks > MAX_TASKS) { printf("tasks cannot exceed %d\n", MAX_TASKS); exit(1); } break; case 's': opt_iterations = atoi(optarg); break; case 'v': verbose = true; break; case 'n': use_affinity = false; break; default: usage(argv[0]); } } if (optind < argc) usage(argv[0]); if (smt_affinity && (use_affinity == false)) usage(argv[0]); m = initialise_shared_area(opt_tasks * MAX_CACHELINE_SIZE); for (i = 0; i < opt_tasks; i++) results[i] = (unsigned long long *)&m[i * MAX_CACHELINE_SIZE]; if (pipe(fd) == -1) { perror("pipe"); exit(1); } testcase_prepare(opt_tasks); hwloc_topology_init(&topology); hwloc_topology_load(topology); n = hwloc_get_nbobjs_by_type(topology, smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE); if (n == 0) { printf("No Cores/PUs found. Try %s -m flag\n", smt_affinity ? "removing" : "adding"); exit(1); } if (n < 1) { perror("hwloc_get_nbobjs_by_type"); exit(1); } args = malloc(opt_tasks * sizeof(struct args)); if (!args) { perror("malloc"); exit(1); } for (i = 0; i < opt_tasks; i++) { hwloc_obj_t obj; hwloc_cpuset_t old_cpuset; int flags = 0; args[i].func = testcase; args[i].arg1 = results[i]; args[i].arg2 = i; args[i].poll_fd = fd[0]; obj = hwloc_get_obj_by_type(topology, smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE, i % n); if (hwloc_topology_dup(&args[i].topology, topology)) { perror("hwloc_topology_dup"); exit(1); } if (!(args[i].cpuset = hwloc_bitmap_dup(obj->cpuset))) { perror("hwloc_bitmap_dup"); exit(1); } old_cpuset = hwloc_bitmap_alloc(); if (!old_cpuset) { perror("hwloc_bitmap_alloc"); exit(1); } #ifdef THREADS flags |= HWLOC_CPUBIND_THREAD; #endif if (hwloc_get_cpubind(topology, old_cpuset, flags) < 0) { perror("hwloc_get_cpubind"); exit(1); } if (use_affinity && hwloc_set_cpubind(topology, obj->cpuset, flags) < 0) { perror("hwloc_set_cpubind"); exit(1); } new_task_affinity(&args[i]); if (use_affinity && hwloc_set_cpubind(topology, old_cpuset, flags) < 0) { perror("hwloc_set_cpubind"); exit(1); } hwloc_bitmap_free(old_cpuset); } if (write(fd[1], &i, 1) != 1) { perror("write"); exit(1); } hwloc_topology_destroy(topology); printf("testcase:%s\n", testcase_description); printf("warmup\n"); while (1) { unsigned long long sum = 0, min = -1ULL, max = 0; sleep(1); for (i = 0; i < opt_tasks; i++) { unsigned long long val = *(results[i]); unsigned long long diff = val - prev[i]; if (verbose) printf("%4d -> %llu\n", i, diff); if (diff < min) min = diff; if (diff > max) max = diff; sum += diff; prev[i] = val; } printf("min:%llu max:%llu total:%llu\n", min, max, sum); if (iterations == WARMUP_ITERATIONS) printf("measurement\n"); if (iterations++ > WARMUP_ITERATIONS) total += sum; if (opt_iterations && (iterations > (opt_iterations + WARMUP_ITERATIONS))) { printf("average:%llu\n", total / opt_iterations); break; } } kill_tasks(); for (i = 0; i < opt_tasks; i++) { hwloc_bitmap_free(args[i].cpuset); hwloc_topology_destroy(args[i].topology); } free(args); testcase_cleanup(); exit(0); } 07070100000005000081A40000000000000000000000015FFCB2540000058B000000000000000000000000000000000000002E00000000will-it-scale-20210112T071724.a34a85c/plot.jsfunction createPlot(data, title) { var x = []; var y1 = []; var y2 = []; var y3 = []; var y4 = []; var y5 = []; for (var r = 0; r < data.length; r++) { x.push(data[r][0]); y1.push(data[r][1]); y2.push(data[r][2]); y3.push(data[r][3]); y4.push(data[r][4]); y5.push(data[r][5]); } var trace1 = { x: x, y: y1, mode: 'lines+markers', name: 'Processes', line: { dash: 'solid', width: 4 }, marker: { size: 6 }, }; var trace2 = { x: x, y: y3, mode: 'lines+markers', name: 'Threads', line: { dash: 'solid', width: 4 }, marker: { size: 6 }, }; var trace3 = { x: x, y: y5, mode: 'lines', name: 'Linear', line: { dash: 'dot', width: 4 }, }; var trace4 = { x: x, y: y2, yaxis: 'y2', mode: 'lines+markers', name: 'Process idle', line: { dash: 'solid', width: 2 }, marker: { size: 8 }, }; var trace5 = { x: x, y: y4, yaxis: 'y2', mode: 'lines+markers', name: 'Thread idle', line: { dash: 'solid', width: 2 }, marker: { size: 8 }, }; var graphs = [trace1, trace2, trace3, trace4, trace5]; var layout = { title: title, xaxis: { title: 'Number of tasks' }, yaxis: { title: 'Operations per second' }, yaxis2: { title: 'Idle', side: 'right', overlaying: 'y', showline: true }, }; Plotly.newPlot('plot', graphs, layout); } 07070100000006000081ED0000000000000000000000015FFCB2540000055B000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/postprocess.py#!/usr/bin/python3 import sys import os import csv import string template = ''' <html> <head> <title>Will it scale?</title> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script src="plot.js"></script> </head> <body> <div id="plot"></div> <script> var data = $data; createPlot(data, '$title'); </script> </body> </html> ''' def parse_data(csvfile): data = [] fp = open(csvfile) csv_reader = csv.reader(fp, dialect='excel') for row in csv_reader: data.append(row) fp.close() return data def process(base): csvfile = base + '.csv' titlefile = base + '.title' htmlfile = base + '.html' data = parse_data(csvfile) title = open(titlefile).readline().strip() t = string.Template(template) html = t.substitute(data=data, title=title) open(htmlfile, 'w').write(html) print('Created %s' % (htmlfile)) def for_each_file(dirname, subdirs, filenames): for f in filenames: if f.endswith('.csv'): process(f) if __name__ == '__main__': for root, dirs, files in os.walk('.'): if root == '.': for f in files: if f.endswith('.csv'): tmp = f.split('.', 1) try: process(tmp[0]) except: sys.exit(1) 07070100000007000081ED0000000000000000000000015FFCB2540000008D000000000000000000000000000000000000003200000000will-it-scale-20210112T071724.a34a85c/runalltests#!/bin/sh for i in *_processes do TESTCASE=`basename $i _processes` echo "Running $TESTCASE" ./runtest.py $TESTCASE > $TESTCASE.csv done 07070100000008000081ED0000000000000000000000015FFCB25400000DAD000000000000000000000000000000000000003100000000will-it-scale-20210112T071724.a34a85c/runtest.py#!/usr/bin/python3 import time import subprocess import sys import os import re class linux_stat(): def __init__(self, procstat='/proc/stat'): fd = open(procstat, 'r'); for line in fd.readlines(): arr = line.split() if arr[0] != 'cpu': continue self.user = int(arr[1]) self.nice = int(arr[2]) self.system = int(arr[3]) self.idle = int(arr[4]) self.iowait = int(arr[5]) self.irq = int(arr[6]) self.softirq = int(arr[7]) self.steal = 0 self.guest = 0 self.guest_nice = 0 if len(arr) > 8: self.steal = int(arr[8]) if len(arr) > 9: self.guest = int(arr[9]) if len(arr) > 10: self.guest_nice = int(arr[10]) break fd.close() def idle_fraction(self, prev): busy = self.user + self.nice + self.system + self.irq + self.softirq + self.steal + self.guest + self.guest_nice idle = self.idle + self.iowait if prev: busy = busy - (prev.user + prev.nice + prev.system + prev.irq + prev.softirq + prev.steal + prev.guest + prev.guest_nice) idle = idle - (prev.idle + prev.iowait) if (idle + busy) == 0: return 0 return 1.0 * idle / (idle + busy) duration=5 if len(sys.argv) != 2: print('Usage: runtest.py <testcase>', file=sys.stderr) sys.exit(1) cmd = sys.argv[1] nr_cores=0 r = re.compile('^processor') fd = open('/proc/cpuinfo', 'r') for line in fd.readlines(): if r.search(line): nr_cores = nr_cores + 1 fd.close() setarch = 'setarch linux64 -R' try: retcode = subprocess.call(setarch + " /bin/true", shell=True) except OSError as e: retcode = -1 if retcode != 0: setarch = '' print('WARNING: setarch -R failed, address space randomization may cause variability', file=sys.stderr) pipe = subprocess.Popen('uname -m', shell=True, stdout=subprocess.PIPE, text=True).stdout arch = pipe.readline().rstrip(os.linesep) pipe.close() if arch == 'ppc64': pipe = subprocess.Popen('ppc64_cpu --smt 2>&1', shell=True, stdout=subprocess.PIPE, text=True).stdout smt_status = pipe.readline() pipe.close() if 'off' not in smt_status: print('WARNING: SMT enabled, suggest disabling', file=sys.stderr) print('tasks,processes,processes_idle,threads,threads_idle,linear') print('0,0,100,0,100,0') step = 1 # if step=5, this is: [5, 10, 15, ... nr_cores] data_points = list(range(step, nr_cores+step, step)) # this makes it [ 1, 5, 10, ... ] if step > 1: data_points.insert(0, 1) for i in data_points: c = './%s_processes -t %d -s %d' % (cmd, i, duration) before = linux_stat() pipe = subprocess.Popen(setarch + ' ' + c, shell=True, stdout=subprocess.PIPE, text=True).stdout processes_avg = -1 for line in pipe.readlines(): if 'testcase:' in line: (testcase, val) = line.split(':') title = open(cmd + '.title', 'w') title.write(val) title.close() if 'average:' in line: (name, val) = line.split(':') processes_avg = int(val) pipe.close() after = linux_stat() processes_idle = after.idle_fraction(before) * 100 c = './%s_threads -t %d -s %d' % (cmd, i, duration) before = linux_stat() pipe = subprocess.Popen(setarch + ' ' + c, shell=True, stdout=subprocess.PIPE, text=True).stdout threads_avg = -1 for line in pipe.readlines(): if 'average:' in line: (name, val) = line.split(':') threads_avg = int(val) pipe.close() after = linux_stat() threads_idle = after.idle_fraction(before) * 100 if i == 1: linear = max(processes_avg, threads_avg) print('%d,%d,%0.2f,%d,%0.2f,%d' % (i, processes_avg, processes_idle, threads_avg, threads_idle, linear * i)) 07070100000009000041ED0000000000000000000000025FFCB25400000000000000000000000000000000000000000000002C00000000will-it-scale-20210112T071724.a34a85c/tests0707010000000A000081A40000000000000000000000015FFCB2540000018F000000000000000000000000000000000000003300000000will-it-scale-20210112T071724.a34a85c/tests/brk1.c#include <assert.h> #include <sys/types.h> #include <unistd.h> char *testcase_description = "brk increase/decrease of one page"; void testcase(unsigned long long *iterations, unsigned long nr) { void *addr = sbrk(0); unsigned long page_size = getpagesize(); while (1) { addr += page_size; assert(brk(addr) == 0); addr -= page_size; assert(brk(addr) == 0); (*iterations) += 2; } } 0707010000000B000081A40000000000000000000000015FFCB254000001AC000000000000000000000000000000000000003300000000will-it-scale-20210112T071724.a34a85c/tests/brk2.c#include <assert.h> #include <sys/types.h> #include <unistd.h> char *testcase_description = "brk unshared increase/decrease of one page"; void testcase(unsigned long long *iterations, unsigned long nr) { unsigned long page_size = getpagesize(); void *addr = sbrk(page_size) + page_size; while (1) { addr += page_size; assert(brk(addr) == 0); addr -= page_size; assert(brk(addr) == 0); (*iterations) += 2; } } 0707010000000C000081A40000000000000000000000015FFCB2540000042B000000000000000000000000000000000000003E00000000will-it-scale-20210112T071724.a34a85c/tests/context_switch1.c#include <unistd.h> #include <stdlib.h> #include <errno.h> #include <assert.h> #define READ 0 #define WRITE 1 char *testcase_description = "Context switch via pipes"; extern void new_task(void *(func)(void *), void *arg); struct args { int fd1[2]; int fd2[2]; }; static void *child(void *arg) { struct args *a = arg; char c; int ret; while (1) { do { ret = read(a->fd1[READ], &c, 1); } while (ret != 1 && errno == EINTR); assert(ret == 1); do { ret = write(a->fd2[WRITE], &c, 1); } while (ret != 1 && errno == EINTR); assert(ret == 1); } return NULL; } void testcase(unsigned long long *iterations, unsigned long nr) { struct args *a; char c; int ret; a = malloc(sizeof(struct args)); assert(pipe(a->fd1) == 0); assert(pipe(a->fd2) == 0); new_task(child, a); while (1) { do { ret = write(a->fd1[WRITE], &c, 1); } while (ret != 1 && errno == EINTR); assert(ret == 1); do { ret = read(a->fd2[READ], &c, 1); } while (ret != 1 && errno == EINTR); assert(ret == 1); (*iterations) += 2; } free(a); } 0707010000000D000081A40000000000000000000000015FFCB25400000192000000000000000000000000000000000000003300000000will-it-scale-20210112T071724.a34a85c/tests/dup1.c#include <stdlib.h> #include <unistd.h> #include <assert.h> char *testcase_description = "Separate file dup/close"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); assert(fd >= 0); unlink(tmpfile); while (1) { int fd2 = dup(fd); assert(fd2 >= 0); close(fd2); (*iterations)++; } close(fd); } 0707010000000E000081A40000000000000000000000015FFCB2540000032B000000000000000000000000000000000000003700000000will-it-scale-20210112T071724.a34a85c/tests/eventfd1.c#ifdef __linux__ #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/eventfd.h> #include <assert.h> char *testcase_description = "eventfd read/write of 8 bytes"; void testcase(unsigned long long *iterations, unsigned long nr) { unsigned long long rbuf; unsigned long long wbuf; int fd = eventfd(0, 0); int ret; assert(fd >= 0); wbuf = 1; while (1) { do { ret = write(fd, &wbuf, sizeof(wbuf)); } while (ret != sizeof(wbuf) && errno == EINTR); assert(ret == sizeof(wbuf)); do { ret = read(fd, &rbuf, sizeof(rbuf)); } while (ret != sizeof(rbuf) && errno == EINTR); assert(ret == sizeof(wbuf)); (*iterations)++; } } #else char *testcase_description = "eventfd read/write of 8 bytes"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 0707010000000F000081A40000000000000000000000015FFCB25400000396000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/fallocate1.c#if __linux__ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define FILESIZE (1 * 1024 * 1024) #define BUFLEN (FILESIZE / 128) char *testcase_description = "Separate file fallocate against tmpfs"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/dev/shm/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long place = 0; assert(fd >= 0); unlink(tmpfile); while (1) { int ret = fallocate(fd, 0, place, BUFLEN); if (errno != EINTR) assert(ret == 0); place += BUFLEN; if (place >= FILESIZE) { ret = ftruncate(fd, 0); assert(ret == 0); place = 0; } (*iterations)++; } } #else char *testcase_description = "Separate file fallocate "; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000010000081A40000000000000000000000015FFCB25400000383000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/fallocate2.c#if __linux__ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define FILESIZE (1 * 1024 * 1024) #define BUFLEN (FILESIZE / 128) char *testcase_description = "Separate file fallocate"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long place = 0; assert(fd >= 0); unlink(tmpfile); while (1) { int ret = fallocate(fd, 0, place, BUFLEN); if (errno != EINTR) assert(ret == 0); place += BUFLEN; if (place >= FILESIZE) { ret = ftruncate(fd, 0); assert(ret == 0); place = 0; } (*iterations)++; } } #else char *testcase_description = "Separate file fallocate"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000011000081A40000000000000000000000015FFCB2540000021A000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/futex1.c#ifdef __linux__ #define _GNU_SOURCE #include <unistd.h> #include <sys/syscall.h> #include <linux/futex.h> #define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F) char *testcase_description = "futex(FUTEX_WAKE)"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { unsigned int addr = 0; futex(&addr, FUTEX_WAKE, 1, NULL, NULL, 0); (*iterations)++; } } #else char *testcase_description = "futex(FUTEX_WAKE)"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000012000081A40000000000000000000000015FFCB2540000021A000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/futex2.c#ifdef __linux__ #define _GNU_SOURCE #include <unistd.h> #include <sys/syscall.h> #include <linux/futex.h> #define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F) char *testcase_description = "futex(FUTEX_WAIT)"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { unsigned int addr = 0; futex(&addr, FUTEX_WAIT, 1, NULL, NULL, 0); (*iterations)++; } } #else char *testcase_description = "futex(FUTEX_WAIT)"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000013000081A40000000000000000000000015FFCB25400000232000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/futex3.c#ifdef __linux__ #define _GNU_SOURCE #include <unistd.h> #include <sys/syscall.h> #include <linux/futex.h> #define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F) char *testcase_description = "futex(FUTEX_WAKE_PRIVATE)"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { unsigned int addr = 0; futex(&addr, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0); (*iterations)++; } } #else char *testcase_description = "futex(FUTEX_WAKE_PRIVATE)"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000014000081A40000000000000000000000015FFCB25400000232000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/futex4.c#ifdef __linux__ #define _GNU_SOURCE #include <unistd.h> #include <sys/syscall.h> #include <linux/futex.h> #define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F) char *testcase_description = "futex(FUTEX_WAIT_PRIVATE)"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { unsigned int addr = 0; futex(&addr, FUTEX_WAIT_PRIVATE, 1, NULL, NULL, 0); (*iterations)++; } } #else char *testcase_description = "futex(FUTEX_WAIT_PRIVATE)"; void testcase(unsigned long long *iterations, unsigned long nr) { } #endif 07070100000015000081A40000000000000000000000015FFCB254000000CA000000000000000000000000000000000000003700000000will-it-scale-20210112T071724.a34a85c/tests/getppid1.c#include <sys/types.h> #include <unistd.h> char *testcase_description = "getppid"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { getppid(); (*iterations)++; } } 07070100000016000081A40000000000000000000000015FFCB25400000297000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/lock1.c#include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <assert.h> char *testcase_description = "Separate file write lock/unlock"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); assert(fd >= 0); unlink(tmpfile); while (1) { struct flock lck; lck.l_type = F_WRLCK; lck.l_whence = SEEK_SET; lck.l_start = 0; lck.l_len = 1; assert(fcntl(fd, F_SETLKW, &lck) == 0); lck.l_type = F_UNLCK; lck.l_whence = SEEK_SET; lck.l_start = 0; lck.l_len = 1; assert(fcntl(fd, F_SETLKW, &lck) == 0); (*iterations) += 2; } } 07070100000017000081A40000000000000000000000015FFCB25400000314000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/lock2.c#include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <assert.h> static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file write lock/unlock"; void testcase_prepare(unsigned long nr_tasks) { assert(mkstemp(tmpfile) != -1); } void testcase(unsigned long long *iterations, unsigned long nr) { int fd = open(tmpfile, O_RDWR); assert(fd >= 0); while (1) { struct flock lck; lck.l_type = F_WRLCK; lck.l_whence = SEEK_SET; lck.l_start = 0; lck.l_len = 1; assert(fcntl(fd, F_SETLKW, &lck) == 0); lck.l_type = F_UNLCK; lck.l_whence = SEEK_SET; lck.l_start = 0; lck.l_len = 1; assert(fcntl(fd, F_SETLKW, &lck) == 0); (*iterations) += 2; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000018000081A40000000000000000000000015FFCB254000001D4000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/lseek1.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #define BUFLEN 4096 char *testcase_description = "Separate file lseek"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); assert(fd >= 0); unlink(tmpfile); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); while (1) { lseek(fd, 0, SEEK_SET); (*iterations)++; } } 07070100000019000081A40000000000000000000000015FFCB2540000029C000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/lseek2.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file lseek"; void testcase_prepare(unsigned long nr_tasks, unsigned long nr) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations) { int fd = open(tmpfile, O_RDWR); assert(fd >= 0); while (1) { lseek(fd, 0, SEEK_SET); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 0707010000001A000081A40000000000000000000000015FFCB25400000159000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/malloc1.c#include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <assert.h> #define SIZE (128UL * 1024 * 1024) char *testcase_description = "malloc/free of 128MB"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { void *addr = malloc(SIZE); assert(addr != NULL); free(addr); (*iterations)++; } } 0707010000001B000081A40000000000000000000000015FFCB2540000014E000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/malloc2.c#include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <assert.h> #define SIZE (1UL * 1024) char *testcase_description = "malloc/free of 1kB"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { void *addr = malloc(SIZE); assert(addr != NULL); free(addr); (*iterations)++; } } 0707010000001C000081A40000000000000000000000015FFCB254000001BB000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/mmap1.c#include <unistd.h> #include <stdlib.h> #include <sys/mman.h> #include <assert.h> #define MEMSIZE (128 * 1024 * 1024) char *testcase_description = "Anonymous memory mmap/munmap of 128MB"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); assert(c != MAP_FAILED); munmap(c, MEMSIZE); (*iterations)++; } } 0707010000001D000081A40000000000000000000000015FFCB25400000244000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/mmap2.c#include <unistd.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/types.h> #include <assert.h> #define MEMSIZE (128 * 1024 * 1024) char *testcase_description = "Separate file mmap/munmap of 128MB"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); assert(ftruncate(fd, MEMSIZE) == 0); unlink(tmpfile); while (1) { char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); assert(c != MAP_FAILED); munmap(c, MEMSIZE); (*iterations)++; } } 0707010000001E000081A40000000000000000000000015FFCB254000003E9000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/open1.c#include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> #include <string.h> char *testcase_description = "Separate file open/close"; #define template "/tmp/willitscale.XXXXXX" static char (*tmpfiles)[sizeof(template)]; static unsigned long local_nr_tasks; void testcase_prepare(unsigned long nr_tasks) { int i; tmpfiles = (char(*)[sizeof(template)])malloc(sizeof(template) * nr_tasks); assert(tmpfiles); for (i = 0; i < nr_tasks; i++) { strcpy(tmpfiles[i], template); char *tmpfile = tmpfiles[i]; int fd = mkstemp(tmpfile); assert(fd >= 0); close(fd); } local_nr_tasks = nr_tasks; } void testcase(unsigned long long *iterations, unsigned long nr) { char *tmpfile = tmpfiles[nr]; while (1) { int fd = open(tmpfile, O_RDWR); assert(fd >= 0); close(fd); (*iterations)++; } } void testcase_cleanup(void) { int i; for (i = 0; i < local_nr_tasks; i++) { unlink(tmpfiles[i]); } free(tmpfiles); } 0707010000001F000081A40000000000000000000000015FFCB25400000534000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/open2.c#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> #include <limits.h> #include <string.h> char *testcase_description = "Separate file open/close in different directories"; #define template "/tmp/willitscale.XXXXXX" static char (*tmpdirs)[sizeof(template)]; static unsigned long local_nr_tasks; void testcase_prepare(unsigned long nr_tasks) { int i; tmpdirs = (char(*)[sizeof(template)])malloc(sizeof(template) * nr_tasks); assert(tmpdirs); char tmpfile[PATH_MAX]; int fd; for (i = 0; i < nr_tasks; i++) { strcpy(tmpdirs[i], template); char *tmpdir = tmpdirs[i]; assert(mkdtemp(tmpdir) != NULL); sprintf(tmpfile, "%s/willitscale", tmpdir); fd = open(tmpfile, O_RDWR|O_CREAT, 0600); assert(fd >= 0); close(fd); } local_nr_tasks = nr_tasks; } void testcase(unsigned long long *iterations, unsigned long nr) { int fd; char tmpfile[PATH_MAX]; sprintf(tmpfile, "%s/willitscale", tmpdirs[nr]); while (1) { fd = open(tmpfile, O_RDWR); assert(fd >= 0); close(fd); (*iterations)++; } } void testcase_cleanup(void) { int i; char tmpfile[PATH_MAX]; for (i = 0; i < local_nr_tasks; i++) { sprintf(tmpfile, "%s/willitscale", tmpdirs[i]); unlink(tmpfile); rmdir(tmpdirs[i]); } free(tmpdirs); } 07070100000020000081A40000000000000000000000015FFCB25400000232000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/open3.c#include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file open/close"; void testcase_prepare(unsigned long nr_tasks) { int fd = mkstemp(tmpfile); assert(fd >= 0); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { int fd = open(tmpfile, O_RDWR); assert(fd >= 0); close(fd); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000021000081A40000000000000000000000015FFCB2540000022A000000000000000000000000000000000000003A00000000will-it-scale-20210112T071724.a34a85c/tests/page_fault1.c#include <unistd.h> #include <stdlib.h> #include <sys/mman.h> #include <assert.h> #define MEMSIZE (128 * 1024 * 1024) char *testcase_description = "Anonymous memory page fault"; void testcase(unsigned long long *iterations, unsigned long nr) { unsigned long pgsize = getpagesize(); while (1) { unsigned long i; char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); assert(c != MAP_FAILED); for (i = 0; i < MEMSIZE; i += pgsize) { c[i] = 0; (*iterations)++; } munmap(c, MEMSIZE); } } 07070100000022000081A40000000000000000000000015FFCB254000002BD000000000000000000000000000000000000003A00000000will-it-scale-20210112T071724.a34a85c/tests/page_fault2.c#include <unistd.h> #include <stdlib.h> #include <sys/mman.h> #include <assert.h> #define MEMSIZE (128 * 1024 * 1024) char *testcase_description = "Separate file private mapping page fault"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long pgsize = getpagesize(); assert(fd >= 0); assert(ftruncate(fd, MEMSIZE) == 0); unlink(tmpfile); while (1) { unsigned long i; char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); assert(c != MAP_FAILED); for (i = 0; i < MEMSIZE; i += pgsize) { c[i] = 0; (*iterations)++; } munmap(c, MEMSIZE); } } 07070100000023000081A40000000000000000000000015FFCB254000002BB000000000000000000000000000000000000003A00000000will-it-scale-20210112T071724.a34a85c/tests/page_fault3.c#include <unistd.h> #include <stdlib.h> #include <sys/mman.h> #include <assert.h> #define MEMSIZE (128 * 1024 * 1024) char *testcase_description = "Separate file shared mapping page fault"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long pgsize = getpagesize(); assert(fd >= 0); assert(ftruncate(fd, MEMSIZE) == 0); unlink(tmpfile); while (1) { unsigned long i; char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); assert(c != MAP_FAILED); for (i = 0; i < MEMSIZE; i += pgsize) { c[i] = 0; (*iterations)++; } munmap(c, MEMSIZE); } } 07070100000024000081A40000000000000000000000015FFCB254000001EA000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/pipe1.c#include <unistd.h> #include <stdlib.h> #include <errno.h> #include <assert.h> #define READ 0 #define WRITE 1 char *testcase_description = "pipe read/write"; void testcase(unsigned long long *iterations, unsigned long nr) { int fd[2]; assert(pipe(fd) == 0); while (1) { char c = 0; int ret; do { ret = write(fd[WRITE], &c, 1); } while (ret != 1 && errno == EINTR); do { ret = read(fd[READ], &c, 1); } while (ret != 1 && errno == EINTR); (*iterations)++; } } 07070100000025000081A40000000000000000000000015FFCB254000001EF000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/poll1.c#include <string.h> #include <unistd.h> #include <stdlib.h> #include <poll.h> #include <assert.h> char *testcase_description = "poll of 1 fd"; void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); assert(fd >= 0); unlink(tmpfile); while (1) { struct pollfd pfd[1]; memset(&pfd, 0, sizeof(pfd)); pfd[0].fd = fd; pfd[0].events = POLLOUT; assert(poll(pfd, 1, 0) >= 0); (*iterations)++; } } 07070100000026000081A40000000000000000000000015FFCB254000004A0000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/poll2.c#include <stdio.h> #include <limits.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <poll.h> #include <sys/time.h> #include <sys/resource.h> #include <assert.h> #define NR_FILES 128 char *testcase_description = "poll of 128 fds"; void testcase_prepare(unsigned long nr_tasks) { struct rlimit rlim; int nr_procs = sysconf(_SC_NPROCESSORS_CONF); rlim_t new_lim = (NR_FILES + 10) * nr_procs; getrlimit(RLIMIT_NOFILE, &rlim); if (rlim.rlim_max < new_lim) { rlim.rlim_cur = new_lim; rlim.rlim_max = new_lim; } if (rlim.rlim_cur < new_lim) { rlim.rlim_cur = new_lim; } assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); } void testcase(unsigned long long *iterations, unsigned long nr) { int i; char tmpfile[PATH_MAX]; int tmpfiles[NR_FILES]; for (i = 0; i < NR_FILES; i++) { sprintf(tmpfile, "/tmp/willitscale.XXXXXX"); tmpfiles[i] = mkstemp(tmpfile); assert(tmpfiles[i] >= 0); unlink(tmpfile); } while (1) { struct pollfd pfd[NR_FILES]; memset(&pfd, 0, sizeof(pfd)); for (i = 0; i < NR_FILES; i++) { pfd[i].fd = tmpfiles[i]; pfd[i].events = POLLOUT; } assert(poll(pfd, NR_FILES, 0) >= 0); (*iterations)++; } } 07070100000027000081A40000000000000000000000015FFCB254000000FA000000000000000000000000000000000000003F00000000will-it-scale-20210112T071724.a34a85c/tests/posix_semaphore1.c#include <semaphore.h> char *testcase_description = "POSIX semaphores"; void testcase(unsigned long long *iterations, unsigned long nr) { sem_t sem; sem_init(&sem, 0, 1); while (1) { sem_wait(&sem); sem_post(&sem); (*iterations)++; } } 07070100000028000081A40000000000000000000000015FFCB25400000221000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/pread1.c#define _XOPEN_SOURCE 500 #include <unistd.h> #include <stdlib.h> #include <assert.h> #include <string.h> #define BUFLEN 4096 char *testcase_description = "Separate file pread"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); unlink(tmpfile); while (1) { assert(pread(fd, buf, BUFLEN, 0) == BUFLEN); (*iterations)++; } } 07070100000029000081A40000000000000000000000015FFCB254000002EF000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/pread2.c#define _XOPEN_SOURCE 500 #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file pread to same offset"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDONLY); assert(fd >= 0); while (1) { assert(pread(fd, buf, BUFLEN, 0) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 0707010000002A000081A40000000000000000000000015FFCB2540000037E000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/pread3.c#define _XOPEN_SOURCE 500 #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file pread to different offsets"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); unsigned long left = getpagesize() * nr_tasks; memset(buf, 0, sizeof(buf)); assert(fd >= 0); while (left > 0) { int n = write(fd, buf, sizeof(buf)); assert(n > 0); left -= n; } close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDONLY); unsigned long offset = getpagesize() * nr; assert(fd >= 0); while (1) { assert(pread(fd, buf, BUFLEN, offset) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 0707010000002B000081A40000000000000000000000015FFCB2540000013D000000000000000000000000000000000000003D00000000will-it-scale-20210112T071724.a34a85c/tests/pthread_mutex1.c#define _GNU_SOURCE #include <pthread.h> char *testcase_description = "Contended pthread mutex"; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex); (*iterations)++; } } 0707010000002C000081A40000000000000000000000015FFCB25400000140000000000000000000000000000000000000003D00000000will-it-scale-20210112T071724.a34a85c/tests/pthread_mutex2.c#define _GNU_SOURCE #include <pthread.h> char *testcase_description = "Uncontended pthread mutex"; void testcase(unsigned long long *iterations, unsigned long nr) { pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; while (1) { pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex); (*iterations)++; } } 0707010000002D000081A40000000000000000000000015FFCB2540000016C000000000000000000000000000000000000003D00000000will-it-scale-20210112T071724.a34a85c/tests/pthread_mutex3.c#define _GNU_SOURCE #include <pthread.h> char *testcase_description = "Contended pthread mutex with global update"; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; unsigned long val; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { pthread_mutex_lock(&mutex); val++; pthread_mutex_unlock(&mutex); (*iterations)++; } } 0707010000002E000081A40000000000000000000000015FFCB254000001F6000000000000000000000000000000000000003D00000000will-it-scale-20210112T071724.a34a85c/tests/pthread_mutex4.c#define _GNU_SOURCE #include <pthread.h> #include <stdlib.h> char *testcase_description = "Contended pthread mutex with local update"; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void testcase(unsigned long long *iterations, unsigned long nr) { // alloca() because plain "unsigned long val" gets optimized away. unsigned long *val = alloca(sizeof(unsigned long)); *(val) = 0; while (1) { pthread_mutex_lock(&mutex); (*val)++; pthread_mutex_unlock(&mutex); (*iterations)++; } } 0707010000002F000081A40000000000000000000000015FFCB25400000172000000000000000000000000000000000000003D00000000will-it-scale-20210112T071724.a34a85c/tests/pthread_mutex5.c#define _GNU_SOURCE #include <pthread.h> char *testcase_description = "Contended pthread mutex with TLS update"; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; __thread unsigned long val; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { pthread_mutex_lock(&mutex); val++; pthread_mutex_unlock(&mutex); (*iterations)++; } } 07070100000030000081A40000000000000000000000015FFCB254000001EE000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/pwrite1.c#define _XOPEN_SOURCE 500 #include <unistd.h> #include <stdlib.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 char *testcase_description = "Separate file pwrite"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); unlink(tmpfile); while (1) { assert(pwrite(fd, buf, BUFLEN, 0) == BUFLEN); (*iterations)++; } } 07070100000031000081A40000000000000000000000015FFCB254000002EF000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/pwrite2.c#define _XOPEN_SOURCE 500 #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file pwrite to same offset"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDWR); assert(fd >= 0); while (1) { assert(pwrite(fd, buf, BUFLEN, 0) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000032000081A40000000000000000000000015FFCB2540000037E000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/pwrite3.c#define _XOPEN_SOURCE 500 #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file pwrite to different offsets"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); unsigned long left = getpagesize() * nr_tasks; memset(buf, 0, sizeof(buf)); assert(fd >= 0); while (left > 0) { int n = write(fd, buf, sizeof(buf)); assert(n > 0); left -= n; } close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDWR); unsigned long offset = getpagesize() * nr; assert(fd >= 0); while (1) { assert(pwrite(fd, buf, BUFLEN, offset) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000033000081A40000000000000000000000015FFCB25400000272000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/read1.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 #define FILESIZE (1 * 1024 * 1024) char *testcase_description = "Separate file read"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[FILESIZE]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unlink(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); while (1) { int len = read(fd, buf, BUFLEN); assert(len >= 0); if (len == 0) lseek(fd, 0, SEEK_SET); (*iterations)++; } } 07070100000034000081A40000000000000000000000015FFCB2540000031D000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/read2.c#include <string.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #define BUFLEN 4096 #define FILESIZE (1 * 1024 * 1024) static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file read"; void testcase_prepare(unsigned long nr_tasks) { char buf[FILESIZE]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDONLY); assert(fd >= 0); while (1) { int ret = read(fd, buf, BUFLEN); assert(ret >= 0); if (ret == 0) lseek(fd, 0, SEEK_SET); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000035000081A40000000000000000000000015FFCB25400000343000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/read3.c#define _GNU_SOURCE #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN getpagesize() #define FILESIZE (1 * 1024 * 1024) char *testcase_description = "Separate file O_DIRECT read"; void testcase(unsigned long long *iterations, unsigned long nr) { char *buf; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkostemp(tmpfile, O_DIRECT); char *p; buf = aligned_alloc(getpagesize(), FILESIZE); memset(buf, 0, FILESIZE); assert(fd >= 0); assert(write(fd, buf, FILESIZE) == FILESIZE); unlink(tmpfile); p = malloc(BUFLEN + getpagesize()); p = (char *)(((unsigned long)p + getpagesize()-1) & ~(getpagesize()-1)); while (1) { int ret = read(fd, p, BUFLEN); assert(ret >= 0); if (ret == 0) lseek(fd, 0, SEEK_SET); (*iterations)++; } free(buf); } 07070100000036000081A40000000000000000000000015FFCB25400000364000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/read4.c#define _GNU_SOURCE #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN getpagesize() #define FILESIZE (1 * 1024 * 1024) static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file O_DIRECT read"; void testcase_prepare(unsigned long nr_tasks) { int fd = mkstemp(tmpfile); char buf[FILESIZE]; memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { int fd = open(tmpfile, O_DIRECT|O_RDONLY); char *p; p = aligned_alloc(getpagesize(), BUFLEN); while (1) { int ret = read(fd, p, BUFLEN); assert(ret >= 0); if (ret == 0) lseek(fd, 0, SEEK_SET); (*iterations)++; } free(p); } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000037000081A40000000000000000000000015FFCB25400000234000000000000000000000000000000000000003800000000will-it-scale-20210112T071724.a34a85c/tests/readseek1.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 char *testcase_description = "Separate file seek+read"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); unlink(tmpfile); while (1) { lseek(fd, 0, SEEK_SET); assert(read(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } 07070100000038000081A40000000000000000000000015FFCB254000002ED000000000000000000000000000000000000003800000000will-it-scale-20210112T071724.a34a85c/tests/readseek2.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file seek+read to same offset"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDWR); assert(fd >= 0); while (1) { lseek(fd, 0, SEEK_SET); assert(read(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000039000081A40000000000000000000000015FFCB2540000037E000000000000000000000000000000000000003800000000will-it-scale-20210112T071724.a34a85c/tests/readseek3.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file seek+read to different offsets"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); unsigned long left = getpagesize() * nr_tasks; memset(buf, 0, sizeof(buf)); assert(fd >= 0); while (left > 0) { int n = write(fd, buf, sizeof(buf)); assert(n > 0); left -= n; } close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDONLY); unsigned long offset = getpagesize() * nr; assert(fd >= 0); while (1) { lseek(fd, offset, SEEK_SET); assert(read(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 0707010000003A000081A40000000000000000000000015FFCB254000000DB000000000000000000000000000000000000003A00000000will-it-scale-20210112T071724.a34a85c/tests/sched_yield.c#include <sched.h> #include <assert.h> char *testcase_description = "sched_yield"; void testcase(unsigned long long *iterations, unsigned long nr) { while (1) { assert(sched_yield() == 0); (*iterations)++; } } 0707010000003B000081A40000000000000000000000015FFCB254000001B5000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/signal1.c#include <stdlib.h> #include <string.h> #include <signal.h> #include <sys/types.h> #include <unistd.h> void handler(int junk) { /* Do Nothing */ } char *testcase_description = "signal delivery"; void testcase(unsigned long long *iterations, unsigned long nr) { struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = handler; sigaction(SIGUSR1, &act, NULL); while (1) { raise(SIGUSR1); (*iterations)++; } } 0707010000003C000081A40000000000000000000000015FFCB254000003B5000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/tlb_flush1.c#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/mman.h> #include <unistd.h> #include <string.h> #include <assert.h> #include <sys/types.h> #include <stdio.h> #define FILESIZE (128 * 1024 * 1024) char *testcase_description = "TLB flush of separate file private mapping"; void testcase(unsigned long *iteration, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long offset = 0; unsigned long pgsize = getpagesize(); assert(fd >= 0); assert(ftruncate(fd, FILESIZE) == 0); unlink(tmpfile); unsigned long i; while (1) { char *addr = mmap(NULL, FILESIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, offset); for (i = 0; i < FILESIZE; i += pgsize) { *(addr + i) = 1; madvise(addr + i, pgsize, MADV_DONTNEED); assert(*(addr + i) == 0); (*iteration)++; } munmap(addr, FILESIZE); } } 0707010000003D000081A40000000000000000000000015FFCB2540000031A000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/tlb_flush2.c#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/mman.h> #include <unistd.h> #include <string.h> #include <assert.h> #include <sys/types.h> #include <stdio.h> #define MEMORYSIZE (1 * 1024 * 1024) char *testcase_description = "TLB flush of anonymous memory private mapping"; void testcase(unsigned long *iteration, unsigned long nr) { unsigned long pgsize = getpagesize(); unsigned long i; while (1) { char *addr = mmap(NULL, MEMORYSIZE, PROT_READ|PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); for (i = 0; i < MEMORYSIZE; i += pgsize) { *(addr + i) = 1; madvise(addr + i, pgsize, MADV_DONTNEED); assert(*(addr + i) == 0); (*iteration)++; } munmap(addr, MEMORYSIZE); } } 0707010000003E000081A40000000000000000000000015FFCB254000003B3000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/tlb_flush3.c#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/mman.h> #include <unistd.h> #include <string.h> #include <assert.h> #include <sys/types.h> #include <stdio.h> #define FILESIZE (128 * 1024 * 1024) char *testcase_description = "TLB flush of separate file shared mapping"; void testcase(unsigned long *iteration, unsigned long nr) { char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long offset = 0; unsigned long pgsize = getpagesize(); assert(fd >= 0); assert(ftruncate(fd, FILESIZE) == 0); unlink(tmpfile); unsigned long i; while (1) { char *addr = mmap(NULL, FILESIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); for (i = 0; i < FILESIZE; i += pgsize) { *(addr + i) = 1; madvise(addr + i, pgsize, MADV_DONTNEED); assert(*(addr + i) == 1); (*iteration)++; } munmap(addr, FILESIZE); } } 0707010000003F000081A40000000000000000000000015FFCB2540000021E000000000000000000000000000000000000003400000000will-it-scale-20210112T071724.a34a85c/tests/unix1.c#include <unistd.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #define READ 0 #define WRITE 1 char *testcase_description = "unix domain socket read/write"; void testcase(unsigned long long *iterations, unsigned long nr) { int fd[2]; char c; int ret; socketpair(AF_UNIX, SOCK_STREAM, 0, fd); while (1) { do { ret = write(fd[WRITE], &c, 1); } while (ret != 1 && errno == EINTR); do { ret = read(fd[READ], &c, 1); } while (ret != 1 && errno == EINTR); (*iterations)++; } } 07070100000040000081A40000000000000000000000015FFCB2540000041D000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/unlink1.c#include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> #include <string.h> char *testcase_description = "Separate file open/close/unlink"; #define template "/tmp/willitscale.XXXXXX" static char (*tmpfiles)[sizeof(template)]; static int local_nr_tasks; void testcase_prepare(unsigned long nr_tasks) { int i; tmpfiles = (char(*)[sizeof(template)])malloc(sizeof(template) * nr_tasks); assert(tmpfiles); for (i = 0; i < nr_tasks; i++) { strcpy(tmpfiles[i], template); char *tmpfile = tmpfiles[i]; int fd = mkstemp(tmpfile); assert(fd >= 0); close(fd); unlink(tmpfile); } local_nr_tasks = nr_tasks; } void testcase(unsigned long long *iterations, unsigned long nr) { char *tmpfile = tmpfiles[nr]; while (1) { int fd = open(tmpfile, O_RDWR|O_CREAT, 0600); assert(fd >= 0); close(fd); unlink(tmpfile); (*iterations)++; } } void testcase_cleanup(void) { int i; for (i = 0; i < local_nr_tasks; i++) { unlink(tmpfiles[i]); } free(tmpfiles); } 07070100000041000081A40000000000000000000000015FFCB25400000558000000000000000000000000000000000000003600000000will-it-scale-20210112T071724.a34a85c/tests/unlink2.c#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <limits.h> #include <assert.h> #include <string.h> char *testcase_description = "Separate file open/close/unlink in different directories"; #define template "/tmp/willitscale.XXXXXX" static char (*tmpdirs)[sizeof(template)]; static unsigned long local_nr_tasks; void testcase_prepare(unsigned long nr_tasks) { int i; tmpdirs = (char(*)[sizeof(template)])malloc(sizeof(template) * nr_tasks); assert(tmpdirs); char tmpfile[PATH_MAX]; int fd; for (i = 0; i < nr_tasks; i++) { strcpy(tmpdirs[i], template); char *tmpdir = tmpdirs[i]; assert(mkdtemp(tmpdir) != NULL); sprintf(tmpfile, "%s/willitscale", tmpdir); fd = open(tmpfile, O_RDWR|O_CREAT, 0600); assert(fd >= 0); close(fd); } local_nr_tasks = nr_tasks; } void testcase(unsigned long long *iterations, unsigned long nr) { char tmpfile[PATH_MAX]; sprintf(tmpfile, "%s/willitscale", tmpdirs[nr]); while (1) { int fd = open(tmpfile, O_RDWR|O_CREAT, 0600); assert(fd >= 0); close(fd); unlink(tmpfile); (*iterations)++; } } void testcase_cleanup(void) { int i; char tmpfile[PATH_MAX]; for (i = 0; i < local_nr_tasks; i++) { sprintf(tmpfile, "%s/willitscale", tmpdirs[i]); unlink(tmpfile); rmdir(tmpdirs[i]); } free(tmpdirs); } 07070100000042000081A40000000000000000000000015FFCB2540000027F000000000000000000000000000000000000003500000000will-it-scale-20210112T071724.a34a85c/tests/write1.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 #define FILESIZE (1 * 1024 * 1024) char *testcase_description = "Separate file write"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); unsigned long size = 0; memset(buf, 0, sizeof(buf)); assert(fd >= 0); unlink(tmpfile); while (1) { int ret = write(fd, buf, BUFLEN); assert(ret >= 0); size += ret; if (size >= FILESIZE) { size = 0; lseek(fd, 0, SEEK_SET); } (*iterations)++; } } 07070100000043000081A40000000000000000000000015FFCB25400000201000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/writeseek1.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 char *testcase_description = "Separate file seek+write"; void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; char tmpfile[] = "/tmp/willitscale.XXXXXX"; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); unlink(tmpfile); while (1) { lseek(fd, 0, SEEK_SET); assert(write(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } 07070100000044000081A40000000000000000000000015FFCB254000002EE000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/writeseek2.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file seek+read to same offset"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); memset(buf, 0, sizeof(buf)); assert(fd >= 0); assert(write(fd, buf, sizeof(buf)) == sizeof(buf)); close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDWR); assert(fd >= 0); while (1) { lseek(fd, 0, SEEK_SET); assert(write(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000045000081A40000000000000000000000015FFCB2540000037E000000000000000000000000000000000000003900000000will-it-scale-20210112T071724.a34a85c/tests/writeseek3.c#include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #define BUFLEN 4096 static char tmpfile[] = "/tmp/willitscale.XXXXXX"; char *testcase_description = "Same file seek+write to different offsets"; void testcase_prepare(unsigned long nr_tasks) { char buf[BUFLEN]; int fd = mkstemp(tmpfile); unsigned long left = getpagesize() * nr_tasks; memset(buf, 0, sizeof(buf)); assert(fd >= 0); while (left > 0) { int n = write(fd, buf, sizeof(buf)); assert(n > 0); left -= n; } close(fd); } void testcase(unsigned long long *iterations, unsigned long nr) { char buf[BUFLEN]; int fd = open(tmpfile, O_RDWR); unsigned long offset = getpagesize() * nr; assert(fd >= 0); while (1) { lseek(fd, offset, SEEK_SET); assert(write(fd, buf, BUFLEN) == BUFLEN); (*iterations)++; } } void testcase_cleanup(void) { unlink(tmpfile); } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!136 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor