[compiler-rt] 5502bd6 - [profile] Remove useless msync when dumping gcda files
    Calixte Denizet via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Oct 14 08:08:17 PDT 2020
    
    
  
Author: Calixte Denizet
Date: 2020-10-14T17:07:20+02:00
New Revision: 5502bd66bb97f7cf3888a869b73091c51fdbba4c
URL: https://github.com/llvm/llvm-project/commit/5502bd66bb97f7cf3888a869b73091c51fdbba4c
DIFF: https://github.com/llvm/llvm-project/commit/5502bd66bb97f7cf3888a869b73091c51fdbba4c.diff
LOG: [profile] Remove useless msync when dumping gcda files
Summary:
According the mmap man page (https://man7.org/linux/man-pages/man2/mmap.2.html) is only required to precisely control updates, so we can safely remove it.
Since gcda files are dumped just before to call exec** functions, dump need to be fast.
On my computer, Firefox built with --coverage needs ~1min40 to display something and in removing msync it needs ~8s.
Reviewers: void
Subscribers: #sanitizers, marco-c, sylvestre.ledru
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D81060
Added: 
    
Modified: 
    compiler-rt/lib/profile/GCDAProfiling.c
Removed: 
    
################################################################################
diff  --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
index 405568187241..4293e8f7b5bf 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -303,16 +303,11 @@ static void unmap_file() {
 
   mmap_handle = NULL;
 #else
-  if (msync(write_buffer, file_size, MS_SYNC) == -1) {
+  if (munmap(write_buffer, file_size) == -1) {
     int errnum = errno;
-    fprintf(stderr, "profiling: %s: cannot msync: %s\n", filename,
+    fprintf(stderr, "profiling: %s: cannot munmap: %s\n", filename,
             strerror(errnum));
   }
-
-  /* We explicitly ignore errors from unmapping because at this point the data
-   * is written and we don't care.
-   */
-  (void)munmap(write_buffer, file_size);
 #endif
 
   write_buffer = NULL;
        
    
    
More information about the llvm-commits
mailing list