trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject [trafficserver] branch master updated: TS-5085 `posix_fadvise` is incorrectly used in traffic_logcat
Date Wed, 04 Jan 2017 16:36:18 GMT
This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  be24334   TS-5085 `posix_fadvise` is incorrectly used in traffic_logcat
be24334 is described below

commit be2433438974f4e6cbdec7bc4330ed83aa09235a
Author: Daniel Xu <dlxu2@yahoo.com>
AuthorDate: Wed Dec 7 15:20:05 2016 -0600

    TS-5085 `posix_fadvise` is incorrectly used in traffic_logcat
    
    `traffic_logcat` was not using `posix_fadvise` correctly. This
    patch corrects the original poor usage as well as adds some more
    `posix_fadvise` calls that should help with performance.
---
 proxy/logcat.cc | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/proxy/logcat.cc b/proxy/logcat.cc
index f6fcab4..836ca82 100644
--- a/proxy/logcat.cc
+++ b/proxy/logcat.cc
@@ -259,7 +259,14 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
         error = DATA_PROCESSING_ERROR;
       } else {
 #if HAVE_POSIX_FADVISE
-        posix_fadvise(in_fd, 0, 0, POSIX_FADV_DONTNEED);
+        // If we don't plan on following the log file, we should let the kernel know
+        // that we plan on reading the entire file so the kernel can do
+        // some fancy optimizations.
+        if (!follow_flag)
+          posix_fadvise(in_fd, 0, 0, POSIX_FADV_WILLNEED);
+
+        // We're always reading the file sequentially so this will always help
+        posix_fadvise(in_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
 #endif
         if (auto_filenames) {
           // change .blog to .log
@@ -300,6 +307,11 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
           }
         }
       }
+#if HAVE_POSIX_FADVISE
+      // Now that we're done reading a potentially large log file, we can tell the kernel
that it's OK to evict
+      // the associated log file pages from cache
+      posix_fadvise(in_fd, 0, 0, POSIX_FADV_DONTNEED);
+#endif
     }
   } else {
     // read from stdin, allow STDIN to go EOF a few times until we get synced

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message