git/list[1] front-page[2] threads[3] people[4] search[5] about
 

would madvise be a win or a lose on memory pressure?

From
MTMike Taht <mike.taht@timesys.com>
Date
Apr 16, 2005, 05:05 UTC
Message-ID
<42609D37.3030809@timesys.com>

Doesn't seem to make sense to use MADV_RANDOM on the cache file, but maybe MADV_SEQUENTIAL on the rest...

--- /home/m/src/git-pasky-0.4/update-cache.c 2005-04-15 12:24:26.000000000 -0700 +++ update-cache.c 2005-04-15 21:53:34.000000000 -0700

@@ -30,7 +30,7 @@
         close(fd);
         if (!out || (int)(long)in == -1)
                 return -1;
-
+       madvise(in,size,MADV_SEQUENTIAL);
         memset(&stream, 0, sizeof(stream));
         deflateInit(&stream, Z_BEST_COMPRESSION);

--- /home/m/src/git-pasky-0.4/read-cache.c      2005-04-15 
12:24:26.000000000 -0700
+++ read-cache.c        2005-04-15 22:01:12.000000000 -0700
@@ -143,6 +143,7 @@
         close(fd);
         if (-1 == (int)(long)map)
                 return NULL;
+       madvise(map,st.st_size,MADV_SEQUENTIAL);
         *size = st.st_size;
         return map;
  }
@@ -254,6 +255,7 @@
         close(fd);
         if (map == MAP_FAILED)
                 return -1;
+       madvise(map,size,MADV_SEQUENTIAL);
         cmp = memcmp(buf, map, size);
         munmap(map, size);
         if (cmp)
-- 
Mike Taht
Message 1 of 1 in “would madvise be a win or a lose on memory pressure?”
  1. Mike TahtApr 16, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.