]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
* msync is NOT necessary before munmap, the data gets synced automatically 511/head
authorTobias Oetiker <tobi@oetiker.ch>
Mon, 30 Jun 2014 09:16:40 +0000 (11:16 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Mon, 30 Jun 2014 11:51:08 +0000 (13:51 +0200)
* remove WILLNEED madvise, this only slows the code down while the os des not seem todo anything sensible with the info

configure.ac
src/rrd_open.c

index 121ffa9e3a6973fbd2fb390838e94147285d6129..ed5cda4492b81dbd908d24d1fa9edb55d86adac4 100644 (file)
@@ -263,7 +263,7 @@ if test "x$enable_mmap" = "xyes"; then
   *)
     AC_CHECK_HEADERS(sys/mman.h)
     AC_FUNC_MMAP
-    AC_CHECK_FUNCS(mmap munmap msync)
+    AC_CHECK_FUNCS(mmap munmap)
     AC_CHECK_DECLS(madvise, [], [], [#ifdef HAVE_SYS_MMAN_H
                                     # include <sys/mman.h>
                                     #endif])
index 5ba35fb0fc99f87ce6bcacbe653008d3753cf37f..63e562244fb98435f0700d3251277eee8605ec8b 100644 (file)
@@ -102,7 +102,6 @@ rrd_file_t *rrd_open(
     int       version;
 
 #ifdef HAVE_MMAP
-    ssize_t   _page_size = sysconf(_SC_PAGESIZE);
     char     *data = MAP_FAILED;
 #endif
     off_t     offset = 0;
@@ -200,8 +199,8 @@ rrd_file_t *rrd_open(
 #ifdef HAVE_MMAP
 #ifdef HAVE_BROKEN_MS_ASYNC
     if (rdwr & RRD_READWRITE) {    
-        /* some unices, the files mtime does not get update    
-           on msync MS_ASYNC, in order to help them,     
+        /* some unices, the files mtime does not get updated
+           on memory mapped files, in order to help them,     
            we update the the timestamp at this point.      
            The thing happens pretty 'close' to the open    
            call so the chances of a race should be minimal.    
@@ -309,14 +308,10 @@ rrd_file_t *rrd_open(
 #ifdef USE_MADVISE
     if (rdwr & RRD_COPY) {
         /* We will read everything in a moment (copying) */
-        madvise(data, rrd_file->file_len, MADV_WILLNEED );
         madvise(data, rrd_file->file_len, MADV_SEQUENTIAL );
     } else {
         /* We do not need to read anything in for the moment */
         madvise(data, rrd_file->file_len, MADV_RANDOM);
-        /* the stat_head will be needed soonish, so hint accordingly */
-        madvise(data, sizeof(stat_head_t), MADV_WILLNEED);
-        madvise(data, sizeof(stat_head_t), MADV_RANDOM);
     }
 #endif
 
@@ -341,19 +336,9 @@ rrd_file_t *rrd_open(
                       rrd->stat_head->version);
         goto out_nullify_head;
     }
-#if defined USE_MADVISE
-    /* the ds_def will be needed soonish, so hint accordingly */
-    madvise(data + PAGE_START(offset),
-            sizeof(ds_def_t) * rrd->stat_head->ds_cnt, MADV_WILLNEED);
-#endif
     __rrd_read(rrd->ds_def, ds_def_t,
                rrd->stat_head->ds_cnt);
 
-#if defined USE_MADVISE
-    /* the rra_def will be needed soonish, so hint accordingly */
-    madvise(data + PAGE_START(offset),
-            sizeof(rra_def_t) * rrd->stat_head->rra_cnt, MADV_WILLNEED);
-#endif
     __rrd_read(rrd->rra_def, rra_def_t,
                rrd->stat_head->rra_cnt);
 
@@ -364,21 +349,12 @@ rrd_file_t *rrd_open(
             rrd_set_error("live_head_t malloc");
             goto out_close;
         }
-#if defined USE_MADVISE
-        /* the live_head will be needed soonish, so hint accordingly */
-        madvise(data + PAGE_START(offset), sizeof(time_t), MADV_WILLNEED);
-#endif
         __rrd_read(rrd->legacy_last_up, time_t,
                    1);
 
         rrd->live_head->last_up = *rrd->legacy_last_up;
         rrd->live_head->last_up_usec = 0;
     } else {
-#if defined USE_MADVISE
-        /* the live_head will be needed soonish, so hint accordingly */
-        madvise(data + PAGE_START(offset),
-                sizeof(live_head_t), MADV_WILLNEED);
-#endif
         __rrd_read(rrd->live_head, live_head_t,
                    1);
     }
@@ -617,9 +593,6 @@ int rrd_close(
     int       ret;
 
 #ifdef HAVE_MMAP
-    ret = msync(rrd_simple_file->file_start, rrd_file->file_len, MS_ASYNC);
-    if (ret != 0)
-        rrd_set_error("msync rrd_file: %s", rrd_strerror(errno));
     ret = munmap(rrd_simple_file->file_start, rrd_file->file_len);
     if (ret != 0)
         rrd_set_error("munmap rrd_file: %s", rrd_strerror(errno));