Subject: mmap(2) performance netbsd-1-6 vs. -current
To: None <tech-perform@netbsd.org>
From: Bang Jun-Young <junyoung@netbsd.org>
List: tech-kern
Date: 10/20/2003 01:51:19
Hi,

After reading a Slashdotted article currently in the flame, I performed
a quick and dirty benchmark test to see mmap(2) performance difference
between netbsd-1-6 and -current. The result is interesting:  

netbsd-1-6 (latest as of this writing):
	real 25.357s user 0.150s sys 24.984s

-current (1.6ZD, updated yesterday):
	real 22.603s user 0.180s sys 22.404s

As you can see, -current mmap(2) was faster than the netbsd-1-6 one
by 11% in the test. The numbers hardly varied during multiple tests. 

The test program used is as follows (please don't blame me for its
silliness, I just wanted to see a rough difference in minutes :-):

#include <stdio.h>
#include <sys/mman.h>

main()
{
	void *ptr[15];
	int i, j;
	size_t size;

	for (j = 0; j < 40960; j++) {
		for (i = 0; i < 15; i++) {
			size = 4096 << i;
			ptr[i] = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
			if (ptr == NULL)
				err("NULL returned, i=%d\n", i);
			*((int *)ptr) = 0xdeadbeef;
		}
		for (i = 0; i < 15; i++) {
			size = 4096 << i;
			munmap(ptr[i], size);
		}
	}
}

Jun-Young

-- 
Bang Jun-Young <junyoung@NetBSD.org>