[Dovecot] test program #2: mmaping
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
Mac OS X for Intel 10.4.9: SMP (Core Duo)
$ ./concurrency writing, page size = 4096 0: reading, page size = 4096 open(): No such file or directory 4: reading, page size = 4096 3: reading, page size = 4096 1: reading, page size = 4096 $ 2: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory
With all of the reader processes dying almost immediately.
Mac OS X for PowerPC 10.4.9: non-SMP (G4)
$ ./concurrency writing, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 0: reading, page size = 4096 open(): No such file or directory
With one reader process dying after about two minutes. Nothing else
after another 20 minutes.
-jim
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
Mac OS X for Intel 10.4.9: SMP (Core Duo)
$ ./concurrency writing, page size = 4096 0: reading, page size = 4096 open(): No such file or directory 4: reading, page size = 4096 3: reading, page size = 4096 1: reading, page size = 4096 $ 2: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory
With all of the reader processes dying almost immediately.
Mac OS X for PowerPC 10.4.9: non-SMP (G4)
$ ./concurrency writing, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 0: reading, page size = 4096 open(): No such file or directory
With one reader process dying after about two minutes. Nothing else
after another 20 minutes.
-jim
On Thu, Jun 21, 2007 at 04:28:17AM +0300, Timo Sirainen wrote:
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
On one computer I faltered on the first two tries because both my home directory and /tmp contained a file or directory named foo :) Perhaps the script should check for existing file entries and abort to avoid unexpected results? Applies to multiple runs too.
FreeBSD 7.0 amd64 SMP (on core 2 duo), local UFS:
% gcc concurrency.c -o concurrency -Wall % gcc -v Using built-in specs. Target: amd64-undermydesk-freebsd Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 4.2.0 20070514 [FreeBSD] % ./concurrency writing, page size = 4096 0: reading, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096
(been waiting for 22 min, prompt does not return)
FreeBSD 7.0 i386 UP (pentium 4), local UFS:
gcc concurrency.c -o concurrency -Wall concurrency.c: In function 'main': concurrency.c:92: warning: format '%ld' expects type 'long int', but argument 2 has type 'size_t' gcc -v Using built-in specs. Target: i386-undermydesk-freebsd Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 4.2.0 20070514 [FreeBSD] ./concurrency 0: reading, page size = 4096 open(): No such file or directory writing, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 ps -xauww | grep concurr mcdouga9 2262 0.0 0.1 3104 652 p0 R 10:57PM 0:00.23 ./concurrency mcdouga9 2263 0.0 0.1 3112 648 p0 S 10:57PM 0:00.11 ./concurrency mcdouga9 2264 0.0 0.1 3112 648 p0 S 10:57PM 0:00.08 ./concurrency mcdouga9 2265 0.0 0.1 3112 648 p0 S 10:57PM 0:00.08 ./concurrency mcdouga9 2266 0.0 0.1 3112 648 p0 S 10:57PM 0:00.09 ./concurrency
(been waiting for 22 min, prompt returns right away with backgrounded processes)
Solaris 9 sparc:
gcc concurrency.c -o concurrency -Wall concurrency.c: In function
main': concurrency.c:40: warning: implicit declaration of function
flock' concurrency.c:40: error:LOCK_EX' undeclared (first use in this function) concurrency.c:40: error: (Each undeclared identifier is reported only once concurrency.c:40: error: for each function it appears in.) concurrency.c:50: error:
LOCK_UN' undeclared (first use in this function) concurrency.c:92: warning: long int format, size_t arg (arg 2) gcc -v Reading specs from /opt/lib/gcc-lib/sparc-sun-solaris2.8/3.3.1/specs Configured with: /usr/local/src/gcc-3.3.1/configure --prefix=/opt --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --with-system-zlib Thread model: posix gcc version 3.3.1 ls -l concurrency ls: concurrency: No such file or directory
FreeBSD 6.2 amd64 SMP on opteron
gcc concurrency.c -o concurrency -Wall gcc -v Using built-in specs. Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 3.4.6 [FreeBSD] 20060305 ./concurrency (has inconsistent behaviors, sometimes looks fine, sometimes has some open() failures and backgrounded process(es?), may or may not vary if stored on NFS).
Not sure if the behavior here is expected or the test needs work, I didn't want to test exhaustively if the results would be inconclusive anyway
FreeBSD 6.2 i386 SMP on opteron, local UFS
% gcc concurrency.c -o concurrency -Wall concurrency.c: In function `main': concurrency.c:92: warning: long int format, size_t arg (arg 2) % gcc -v Using built-in specs. Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 3.4.6 [FreeBSD] 20060305 % ~/concurrency writing, page size = 4096 0: reading, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096
(seems consistent and fine)
Hi Timo,
It doesn't compile for Solaris 10:
gcc concurrency.c -o concurrency -Wall concurrency.c: In function
main': concurrency.c:40: warning: implicit declaration of function
flock' concurrency.c:40: error:LOCK_EX' undeclared (first use in this function) concurrency.c:40: error: (Each undeclared identifier is reported only once concurrency.c:40: error: for each function it appears in.) concurrency.c:50: error:
LOCK_UN' undeclared (first use in this function) concurrency.c:92: warning: long int format, size_t arg (arg 2)
Cheers.
On Thu, 21 Jun 2007, Timo Sirainen wrote:
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
Hi,
It doesn't compile for Solaris 10:
You can compile it with : gcc -o concurency -I/usr/ucbinclude -L/usr/ucblib -lucb concurency.c (on a default Solaris 10 install). Then, you must add /usr/ucblib to your library search path using crle.
On a dual UltraSparc IIIi running Solaris 10, here is what is printed after 30 minutes :
$ ./concurency writing, page size = 8192 4: reading, page size = 8192 3: reading, page size = 8192 2: reading, page size = 8192 0: reading, page size = 8192 1: reading, page size = 8192
Cheers, Greg
Attached another test program. I don't expect it to print any errors with any OS, but I'd like to confirm it for non-Linux SMP kernels.
(Except for OpenBSD, it doesn't work correctly in it anyway because it doesn't support mixing write()s and mmap())
6.2-RELEASE FreeBSD 2 x Intel(R) Xeon(R) CPU 5130 @ 2.00GHz (2000.08-MHz 686-class CPU)
af>./concurrency 4: reading, page size = 4096 open(): No such file or directory 0: reading, page size = 4096 open(): No such file or directory af> writing, page size = 4096 3: reading, page size = 4096 1: reading, page size = 4096 2: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory
6.2-RELEASE-p2 FreeBSD CPU: Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz (1864.81-MHz 686-class CPU)
j170> ./concurrency 4: reading, page size = 4096 open(): No such file or directory 0: reading, page size = 4096 open(): No such file or directory j170> writing, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory
6.1-RELEASE FreeBSD 2 x CPU: Intel(R) Pentium(TM)3 900 MHz
uos> ./concurrency 4: reading, page size = 4096 open(): No such file or directory writing, page size = 4096 3: reading, page size = 4096 0: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096
been waiting for 2h, prompt does not return
-- PJ
Masz fajnie urzadzone mieszkanie? Pokaz je innym >>> http://link.interia.pl/f1abf
I'm not sure what you expect to happen, but: fnord gdt 18 ~ > ./concurrency 0: reading, page size = 4096 writing, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory fnord gdt 19 ~ > ps uaxw|egrep con gdt 19239 0.0 0.1 104 548 ttyp1 S 7:55AM 0:00.00 ./concurrency [other false hits redacted] fnord gdt 20 ~ > uname -a NetBSD fnord.ir.bbn.com 4.0_BETA2 NetBSD 4.0_BETA2 (GENERIC) #11: Mon Apr 30 10:46:41 EDT 2007 gdt@fnord.ir.bbn.com:/n0/obj/gdt-4/i386/sys/arch/i386/compile/GENERIC i386 My system has 2 cpus. Reading the code, I don't understand why this shouldn't happen - the bottom branch in the children gets to the open before the top has done rename, and there's no synchronization to prevent this. With the following, it prints the 'reading' lines and then sits running: fnord gdt 68 ~ > ./concurrency writing, page size = 4096 0: reading, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 ...........................................................................................................................................................................................................................................^C --- concurrency.c.~1~ 2007-06-21 07:54:51.000000000 -0400 +++ concurrency.c 2007-06-21 08:05:33.000000000 -0400 @@ -43,16 +43,19 @@ perror("rename()"); usleep(rand() % 1000); - pwrite(fd, buf, pagesize + 16, 0); + if (pwrite(fd, buf, pagesize + 16, 0) < 0) + perror("pwrite1()"); //usleep(rand() % 1000); //fdatasync(fd); - pwrite(fd, ones, 4, pagesize-4); + if (pwrite(fd, ones, 4, pagesize-4) < 0) + perror("pwrite1()"); if (flock(fd, LOCK_UN) < 0) perror("flock()"); close(fd); usleep(rand() % 1000); } } else { + sleep(1); while (process_count-- > 1) { if (fork() == 0) break; @@ -61,7 +64,7 @@ for (;; close(fd), usleep(rand() % 1000)) { fd = open("foo", O_RDWR, 0600); if (fd == -1) { - perror("open()"); + perror("open_lower()"); return 1; } @@ -93,6 +96,7 @@ } else if (((char *)mmap_base)[pagesize] != 'h') printf("broken data\n"); } + putchar('.'); fflush(stdout); } } return 0;
On Thu, 2007-06-21 at 08:06 -0400, Greg Troxel wrote:
I'm not sure what you expect to happen, but:
fnord gdt 18 ~ > ./concurrency 0: reading, page size = 4096 writing, page size = 4096 4: reading, page size = 4096 3: reading, page size = 4096 2: reading, page size = 4096 1: reading, page size = 4096 open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory open(): No such file or directory
touch foo ./concurrency
fixes this. :)
participants (8)
-
Adam McDougall
-
Greg Troxel
-
greg@kamago.net
-
Jim Maenpaa
-
Jim Maenpaa
-
pitun
-
Tan Shao Yi
-
Timo Sirainen