Re: [HACKERS] mmap vs read/write
От | ocie@paracel.com |
---|---|
Тема | Re: [HACKERS] mmap vs read/write |
Дата | |
Msg-id | 9805152250.AA06566@dolomite.paracel.com обсуждение исходный текст |
Ответ на | mmap vs read/write (Huw Rogers <count0@fsj.co.jp>) |
Список | pgsql-hackers |
Huw Rogers wrote: > > Someone posted a (readonly) benchtest of mmap vs > read/write I/O using the following code: > > for (off = 0; 1; off += MMAP_SIZE) > { > addr = mmap(0, MMAP_SIZE, PROT_READ, 0, fd, off); > assert(addr != NULL); > > for (j = 0; j < MMAP_SIZE; j++) > if (*(addr + j) != ' ') > spaces++; > munmap(addr,MMAP_SIZE); > } > > This is unfair to mmap since mmap is called once > per page. Better to mmap large regions (many > pages at once), then use msync() to force > write any modified pages. Access purely in Better yet, request the pages ahead of time and have another process map them in "asynchronously". By the time the process is ready to map the page in for itself, the page will have already been read in from the disk, and a memory buffer will be allocated for it. I want to try and implement this in a simple demo program when I get a chance. Ocie
В списке pgsql-hackers по дате отправления: