On Sun, Jan 26, 2003 at 12:40:19AM +0000, Nicholas Clark wrote: > On Sat, Jan 25, 2003 at 11:43:40PM +0000, Dave Mitchell wrote: > > Okay, I just ran a program on a a Solaris machines that mmaps in each > > of 571 man files 20 times (a total of 11420 mmaps). The process size > > was 181Mb, but the total system swap available only decreased by 1.2Mb > > (since files mmapped in RO effecctively don't consume swap). > > 11420 simultaneous mmaps in the same process? (just checking that I > understand you)
yep, exactly that. Src code included below. > Maybe I'm paranoid (or even plain wrong) but we (parrot) can handle it > if an mmap fails - we just automatically fall back to plain file loading. > Can dlopen() cope if an mmap fails? Or on a platform which can only > do a limited number of mmaps do we run the danger of exhausting them early > with all our bytecode segments, and then the first time someone attempts > a require POSIX; it fails because the perl6 DynaLoader can't dlopen > POSIX.so? (And by then we've done our could-have-been-plain-loaded > mmaps, so it's too late to adapt) If there's such a platform, then presumably we don't bother mmap at all for that platform. to run: cd to a man directory, then C</tmp/foo *> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> main(int argc, char *argv[]) { int i,j; int fd; off_t size; void *p; struct stat st; for (j=0; j<20; j++) { for (i=1; i<argc; i++) { fd = open(argv[i], O_RDONLY); if (fd == -1) { perror("open"); exit(1); } if (fstat(fd, &st) == -1) { perror("fstat"); exit(1); } size = st.st_size; /* printf("%d %5d %s\n", i, size, argv[i]); */ p = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0); if (p < 0) { perror("mmap"); exit(1); } close(fd); } printf("done loop %d\n",j); } sleep(1000); } -- "But Sidley Park is already a picture, and a most amiable picture too. The slopes are green and gentle. The trees are companionably grouped at intervals that show them to advantage. The rill is a serpentine ribbon unwound from the lake peaceably contained by meadows on which the right amount of sheep are tastefully arranged." Lady Croom - Arcadia