[rrd-developers] rrd_open.c: mremap not portable, /trunk build broken

kevin brintnall kbrint at rufus.net
Wed Oct 15 18:13:15 CEST 2008

On Wed, Oct 15, 2008 at 11:55:26AM +0100, Daniel.Pocock at barclayscapital.com wrote:
> Now using munmap followed by a new call to mmap
> This has a few consequences:
> - The effects of any previous madvise calls will be lost, it should only
> be an issue for rrd_create though as nothing else should append the rrd
> file.


#ifdef MMAP, it looks like the code in r1601 would end up calling mremap
(now munmap/mmap) for every piece of the header?  It looks like it would
be called every time the file is extended.  I count (4+DS*2+RRA) extensions.

I think a better approach would be to determine the length of the file in
advance and just create/mmap it once.  I already wrote the code that
determines the size of the data portion (it's in rrd_open):

      off_t correct_len = rrd_file->header_len +
        sizeof(rrd_value_t) * row_cnt * rrd->stat_head->ds_cnt;

It should be a trivial matter to pre-determine the rrd_file->header_len.
Then you can create the entire file once and mmap it.  There will be no
need to munmap/mmap repeatedly.

 kevin brintnall =~ /kbrint at rufus.net/

More information about the rrd-developers mailing list