https://bugs.webkit.org/show_bug.cgi?id=38154 FastMalloc calls madvise too often.
authorslewis@apple.com <slewis@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Apr 2010 22:55:22 +0000 (22:55 +0000)
committerslewis@apple.com <slewis@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Apr 2010 22:55:22 +0000 (22:55 +0000)
<rdar://problem/7834433> REGRESSSION: 1.5% PLT regression due to 56028 (return memory quicker).
To save on madvise calls when recommitting memory recommit the entire span and then carve it
instead of carving the span up and only committing the part that will be used immediately.

Reviewed by Geoff Garen.

* wtf/FastMalloc.cpp:
(WTF::TCMalloc_PageHeap::New):
(WTF::TCMalloc_PageHeap::AllocLarge):
(WTF::TCMalloc_PageHeap::Carve):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58346 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/wtf/FastMalloc.cpp
Makefile.shared
WebKit/WebKit.xcodeproj/project.pbxproj
WebKitLibraries/WebKitPluginAgent [new file with mode: 0755]
WebKitLibraries/WebKitPluginHost.app/Contents/Info.plist [new file with mode: 0644]
WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHost [new file with mode: 0755]
WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHostShim.dylib [new file with mode: 0755]
WebKitLibraries/WebKitPluginHost.app/Contents/PkgInfo [new file with mode: 0644]
WebKitLibraries/WebKitPluginHostShim.dylib [new file with mode: 0755]
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/Scripts/parse-malloc-history
WebKitTools/Scripts/run-javascriptcore-tests
WebKitTools/Scripts/webkitdirs.pm

index eecc2b4..b58162b 100644 (file)
@@ -1,3 +1,17 @@
+2010-04-26  Stephanie Lewis  <slewis@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        https://bugs.webkit.org/show_bug.cgi?id=38154 FastMalloc calls madvise too often.
+        <rdar://problem/7834433> REGRESSSION: 1.5% PLT regression due to 56028 (return memory quicker).  
+        To save on madvise calls when recommitting memory recommit the entire span and then carve it
+        instead of carving the span up and only committing the part that will be used immediately.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::TCMalloc_PageHeap::New):
+        (WTF::TCMalloc_PageHeap::AllocLarge):
+        (WTF::TCMalloc_PageHeap::Carve):
+
 2010-04-26  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 7824159..238df0a 100644 (file)
@@ -1583,19 +1583,13 @@ inline Span* TCMalloc_PageHeap::New(Length n) {
 
     Span* result = ll->next;
     Carve(result, n, released);
-    if (result->decommitted) {
-        TCMalloc_SystemCommit(reinterpret_cast<void*>(result->start << kPageShift), static_cast<size_t>(n << kPageShift));
-        result->decommitted = false;
-    }
 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
-    else {
-        // The newly allocated memory is from a span that's in the normal span list (already committed).  Update the
-        // free committed pages count.
-        ASSERT(free_committed_pages_ >= n);
-        free_committed_pages_ -= n;
-        if (free_committed_pages_ < min_free_committed_pages_since_last_scavenge_)
-            min_free_committed_pages_since_last_scavenge_ = free_committed_pages_;
-    }
+    // The newly allocated memory is from a span that's in the normal span list (already committed).  Update the
+    // free committed pages count.
+    ASSERT(free_committed_pages_ >= n);
+    free_committed_pages_ -= n;
+    if (free_committed_pages_ < min_free_committed_pages_since_last_scavenge_) 
+      min_free_committed_pages_since_last_scavenge_ = free_committed_pages_;
 #endif  // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
     ASSERT(Check());
     free_pages_ -= n;
@@ -1653,19 +1647,13 @@ Span* TCMalloc_PageHeap::AllocLarge(Length n) {
 
   if (best != NULL) {
     Carve(best, n, from_released);
-    if (best->decommitted) {
-        TCMalloc_SystemCommit(reinterpret_cast<void*>(best->start << kPageShift), static_cast<size_t>(n << kPageShift));
-        best->decommitted = false;
-    }
 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
-    else {
-        // The newly allocated memory is from a span that's in the normal span list (already committed).  Update the
-        // free committed pages count.
-        ASSERT(free_committed_pages_ >= n);
-        free_committed_pages_ -= n;
-        if (free_committed_pages_ < min_free_committed_pages_since_last_scavenge_)
-            min_free_committed_pages_since_last_scavenge_ = free_committed_pages_;
-    }
+    // The newly allocated memory is from a span that's in the normal span list (already committed).  Update the
+    // free committed pages count.
+    ASSERT(free_committed_pages_ >= n);
+    free_committed_pages_ -= n;
+    if (free_committed_pages_ < min_free_committed_pages_since_last_scavenge_)
+      min_free_committed_pages_since_last_scavenge_ = free_committed_pages_;
 #endif  // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
     ASSERT(Check());
     free_pages_ -= n;
@@ -1691,29 +1679,32 @@ Span* TCMalloc_PageHeap::Split(Span* span, Length n) {
   return leftover;
 }
 
-static ALWAYS_INLINE void propagateDecommittedState(Span* destination, Span* source)
-{
-    destination->decommitted = source->decommitted;
-}
-
 inline void TCMalloc_PageHeap::Carve(Span* span, Length n, bool released) {
   ASSERT(n > 0);
   DLL_Remove(span);
   span->free = 0;
   Event(span, 'A', n);
 
+  if (released) {
+    // If the span chosen to carve from is decommited, commit the entire span at once to avoid committing spans 1 page at a time.
+    ASSERT(span->decommitted);
+    TCMalloc_SystemCommit(reinterpret_cast<void*>(span->start << kPageShift), static_cast<size_t>(span->length << kPageShift));
+    span->decommitted = false;
+    free_committed_pages_ += span->length;
+  }
+  
   const int extra = static_cast<int>(span->length - n);
   ASSERT(extra >= 0);
   if (extra > 0) {
     Span* leftover = NewSpan(span->start + n, extra);
     leftover->free = 1;
-    propagateDecommittedState(leftover, span);
+    leftover->decommitted = false;
     Event(leftover, 'S', extra);
     RecordSpan(leftover);
 
     // Place leftover span on appropriate free list
     SpanList* listpair = (static_cast<size_t>(extra) < kMaxPages) ? &free_[extra] : &large_;
-    Span* dst = released ? &listpair->returned : &listpair->normal;
+    Span* dst = &listpair->normal;
     DLL_Prepend(dst, leftover);
 
     span->length = n;
index aa9fa72..9ccb089 100644 (file)
@@ -10,7 +10,7 @@ debug d development dev develop: force
 
 release r deployment dep deploy: force
        $(SCRIPTS_PATH)/set-webkit-configuration --release
-       ( xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | grep -v setenv && exit $${PIPESTATUS[0]} )
+       ( xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) &&  exit $${PIPESTATUS[0]} )
 
 clean:
        ( xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | grep -v setenv && exit $${PIPESTATUS[0]} )
index e6bbab5..5ab7c34 100644 (file)
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "if [[ \"${MACOSX_DEPLOYMENT_TARGET}\" > \"10.5\" && \"${CONFIGURATION}\" != \"Production\" && \"${ACTION}\" == \"build\" ]]; then\n    if [[ ! -e \"${CONFIGURATION_BUILD_DIR}/WebKit.framework/WebKitPluginHost.app\" ]]; then\n       ln -s /System/Library/Frameworks/WebKit.framework/WebKitPluginHost.app \"${CONFIGURATION_BUILD_DIR}/WebKit.framework/WebKitPluginHost.app\"\n    fi\nfi\n";
+                       shellScript = "if [[ \"${MACOSX_DEPLOYMENT_TARGET}\" > \"10.5\" && \"${CONFIGURATION}\" != \"Production\" && \"${ACTION}\" == \"build\" ]]; then \n   if [[ ! -e \"${CONFIGURATION_BUILD_DIR}/WebKit.framework/WebKitPluginHost.app\" ]]; then\n       if [[ -e \"${PROJECT_DIR}/../WebKitLibraries/WebKitPluginHost.app\" ]]; then\n           ln -s \"${PROJECT_DIR}/../WebKitLibraries/WebKitPluginHost.app\" \"${CONFIGURATION_BUILD_DIR}/WebKit.framework/WebKitPluginHost.app\"\n       else\n           ln -s /System/Library/Frameworks/WebKit.framework/WebKitPluginHost.app \"${CONFIGURATION_BUILD_DIR}/WebKit.framework/WebKitPluginHost.app\"\n       fi\n   fi\nfi\n";
                };
                9337D6540EBFE54D00DA3CB5 /* Check For Exit Time Destructors */ = {
                        isa = PBXShellScriptBuildPhase;
diff --git a/WebKitLibraries/WebKitPluginAgent b/WebKitLibraries/WebKitPluginAgent
new file mode 100755 (executable)
index 0000000..0c1e8a7
Binary files /dev/null and b/WebKitLibraries/WebKitPluginAgent differ
diff --git a/WebKitLibraries/WebKitPluginHost.app/Contents/Info.plist b/WebKitLibraries/WebKitPluginHost.app/Contents/Info.plist
new file mode 100644 (file)
index 0000000..0d00a3f
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleExecutable</key>
+       <string>WebKitPluginHost</string>
+       <key>CFBundleIdentifier</key>
+       <string>com.apple.WebKit.PluginHost</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>WebKitPluginHost</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>6533</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>6533.5</string>
+       <key>LSMinimumSystemVersion</key>
+       <string>10.6.0</string>
+       <key>LSUIElement</key>
+       <true/>
+</dict>
+</plist>
diff --git a/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHost b/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHost
new file mode 100755 (executable)
index 0000000..ef33d1d
Binary files /dev/null and b/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHost differ
diff --git a/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHostShim.dylib b/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHostShim.dylib
new file mode 100755 (executable)
index 0000000..2283c4d
Binary files /dev/null and b/WebKitLibraries/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHostShim.dylib differ
diff --git a/WebKitLibraries/WebKitPluginHost.app/Contents/PkgInfo b/WebKitLibraries/WebKitPluginHost.app/Contents/PkgInfo
new file mode 100644 (file)
index 0000000..bd04210
--- /dev/null
@@ -0,0 +1 @@
+APPL????
\ No newline at end of file
diff --git a/WebKitLibraries/WebKitPluginHostShim.dylib b/WebKitLibraries/WebKitPluginHostShim.dylib
new file mode 100755 (executable)
index 0000000..2283c4d
Binary files /dev/null and b/WebKitLibraries/WebKitPluginHostShim.dylib differ
index 3adfaf2..f6c30fd 100644 (file)
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = BCB281EE0CFA713D007E533E /* Base.xcconfig */;
                        buildSettings = {
-                               WEBKIT_FRAMEWORK_RESOURCES_PATH = WebKit.framework/Versions/A/Resources;
+                               WEBKIT_FRAMEWORK_RESOURCES_PATH = /AppleInternal/WebKitTools;
                        };
                        name = Production;
                };
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = BCB281F00CFA713D007E533E /* DumpRenderTree.xcconfig */;
                        buildSettings = {
-                               INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
+                               INSTALL_PATH = "$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
                                SKIP_INSTALL = NO;
                        };
                        name = Production;
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = BCB283D80CFA7AFD007E533E /* ImageDiff.xcconfig */;
                        buildSettings = {
-                               INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
+                               INSTALL_PATH = "$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
                                SKIP_INSTALL = NO;
                        };
                        name = Production;
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = BCB283DE0CFA7C20007E533E /* TestNetscapePlugIn.xcconfig */;
                        buildSettings = {
-                               INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
+                               INSTALL_PATH = "$(WEBKIT_FRAMEWORK_RESOURCES_PATH)";
                                SKIP_INSTALL = NO;
                        };
                        name = Production;
index 177de1c..d5db777 100755 (executable)
@@ -113,6 +113,8 @@ sub main()
             }
         }
         
+        $line =~ s/(\|\s*0x[0-9a-f]+\s*\|)/\|/g;
+        
         # Then give up
         next if (!$callCount || !$byteCount);
         
index fb4c388..9e0f45e 100755 (executable)
@@ -108,7 +108,6 @@ sub testapiPath($)
 {
     my ($productDir) = @_;
     my $jscName = "testapi";
-    $jscName .= "_debug"  if (isCygwin() && ($configuration eq "Debug"));
     return "$productDir/$jscName";
 }
 
index 6f3ca96..d93ee0a 100644 (file)
@@ -231,7 +231,6 @@ sub jscPath($)
 {
     my ($productDir) = @_;
     my $jscName = "jsc";
-    $jscName .= "_debug"  if (isCygwin() && ($configuration eq "Debug"));
     return "$productDir/$jscName";
 }