Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] mmap vs read/write

From: ocie(at)paracel(dot)com
To: count0(at)fsj(dot)co(dot)jp
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] mmap vs read/write
Date: 1998-05-15 22:50:45
Message-ID: 9805152250.AA06566@dolomite.paracel.com (view raw or flat)
Thread:
Lists: 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

In response to

pgsql-hackers by date

Next:From: Michael RichardsDate: 1998-05-15 23:09:31
Subject: sorting big tables :(
Previous:From: Bruce MomjianDate: 1998-05-15 22:16:58
Subject: Re: [HACKERS] mmap vs read/write

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group