]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/map_populate'
authorAndre Noll <maan@systemlinux.org>
Mon, 24 Oct 2011 13:31:31 +0000 (15:31 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 24 Oct 2011 13:34:25 +0000 (15:34 +0200)
1  2 
NEWS
vss.c

diff --combined NEWS
index 6db7225350f014f80e3f0ad831fe60b93d2777b9,50f9b6996c878e9e7762cddf25dbf2a9666bb277..3a7027298f5a20ee00793554b2be89a997f331c3
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -2,14 -2,6 +2,16 @@@
  0.4.9 (to be announced) "hybrid causality"
  ------------------------------------------
  
 +      - Fix for an endless loop in the mp3 decoder for certain
 +        (corrupt) mp3 files.
 +      - autogen.sh now detects a distcc setup and adjusts the
 +        parameter for the -j option of make accordingly.
 +      - Shared memory areas are no longer restricted to 64K. We now
 +        detect the maximal size of a shared memory area at runtime.
 +      - cleanup of the internal uptime API.
++      - para_server prefaults the mmapped audio file to avoid
++        delays on slow media.
 +
  --------------------------------------
  0.4.8 (2011-08-19) "nested assignment"
  --------------------------------------
diff --combined vss.c
index f6da52dd6cc933f66a746095389ad1510452d0e4,e833543e785788876af91d691b73cf8876899de3..e336a9e7413d469c71a6221cab0e86b0aae24867
--- 1/vss.c
--- 2/vss.c
+++ b/vss.c
@@@ -132,7 -132,6 +132,7 @@@ struct fec_group 
        uint16_t slice_bytes;
  };
  
 +/** A FEC client is always in one of these states. */
  enum fec_client_state {
        FEC_STATE_NONE = 0,     /**< not initialized and not enabled */
        FEC_STATE_DISABLED,     /**< temporarily disabled */
@@@ -953,6 -952,10 +953,10 @@@ static int recv_afs_msg(int afs_socket
        return 1;
  }
  
+ #ifndef MAP_POPULATE
+ #define MAP_POPULATE 0
+ #endif
  static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
  {
        int ret, passed_fd, shmid;
        }
        mmd->size = statbuf.st_size;
        mmd->mtime = statbuf.st_mtime;
-       ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE, passed_fd,
-               0, &vsst->map);
+       ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
+               passed_fd, 0, &vsst->map);
        if (ret < 0)
                goto err;
        close(passed_fd);
@@@ -1077,6 -1080,23 +1081,23 @@@ static void vss_send(struct vss_task *v
                }
                mmd->chunks_sent++;
                mmd->current_chunk++;
+               /*
+                * Prefault next chunk(s)
+                *
+                * If the backing device of the memory-mapped audio file is
+                * slow and read-ahead is turned off or prevented for some
+                * reason, e.g. due to memory pressure, it may take much longer
+                * than the chunk interval to get the next chunk on the wire,
+                * causing buffer underruns on the client side. Mapping the
+                * file with MAP_POPULATE seems to help a bit, but it does not
+                * eliminate the delays completely. Moreover, it is supported
+                * only on Linux. So we do our own read-ahead here.
+                */
+               buf += len;
+               for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
+                       __a_unused volatile char x = *buf;
+                       buf += 4096;
+               }
        }
  }