Title: [135666] trunk/Source/WTF
Revision
135666
Author
[email protected]
Date
2012-11-24 23:25:16 -0800 (Sat, 24 Nov 2012)

Log Message

Chromium should use TCMalloc on Mac to go fast
https://bugs.webkit.org/show_bug.cgi?id=102866

Reviewed by Eric Seidel.

This patch enables TCMalloc for some WebKit objects. It improves
dom-modify on Mac by 5-10%.

On non-Mac platforms, Chromium already uses TCMalloc throughout the
project. Unfortunately, we haven't yet figured out how to turn TCMalloc
on globally on Mac because the approach we use for other platforms makes
some OS X APIs sad.

The next best thing would be to enable TCMalloc for WebKit by
overriding the global new and delete operator, as is done on apple-mac
and other platforms. Unfortunately, we cannot use that approach either
because the Chromium WebKit API is not memory tight.

Fortunately, WebKit has a mechanism for selectively enabling TCMalloc
for a selection of objects by overriding the new and delete operators
on those objects. This patch opts chromium-mac into that scheme by
setting the appropriate preprocessor macros.

* WTF.gyp/WTF.gyp:
* wtf/Platform.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (135665 => 135666)


--- trunk/Source/WTF/ChangeLog	2012-11-25 04:49:14 UTC (rev 135665)
+++ trunk/Source/WTF/ChangeLog	2012-11-25 07:25:16 UTC (rev 135666)
@@ -1,3 +1,31 @@
+2012-11-24  Adam Barth  <[email protected]>
+
+        Chromium should use TCMalloc on Mac to go fast
+        https://bugs.webkit.org/show_bug.cgi?id=102866
+
+        Reviewed by Eric Seidel.
+
+        This patch enables TCMalloc for some WebKit objects. It improves
+        dom-modify on Mac by 5-10%.
+
+        On non-Mac platforms, Chromium already uses TCMalloc throughout the
+        project. Unfortunately, we haven't yet figured out how to turn TCMalloc
+        on globally on Mac because the approach we use for other platforms makes
+        some OS X APIs sad.
+
+        The next best thing would be to enable TCMalloc for WebKit by
+        overriding the global new and delete operator, as is done on apple-mac
+        and other platforms. Unfortunately, we cannot use that approach either
+        because the Chromium WebKit API is not memory tight.
+
+        Fortunately, WebKit has a mechanism for selectively enabling TCMalloc
+        for a selection of objects by overriding the new and delete operators
+        on those objects. This patch opts chromium-mac into that scheme by
+        setting the appropriate preprocessor macros.
+
+        * WTF.gyp/WTF.gyp:
+        * wtf/Platform.h:
+
 2012-11-21  Filip Pizlo  <[email protected]>
 
         Any function that can log things should be able to easily log them to a memory buffer as well

Modified: trunk/Source/WTF/WTF.gyp/WTF.gyp (135665 => 135666)


--- trunk/Source/WTF/WTF.gyp/WTF.gyp	2012-11-25 04:49:14 UTC (rev 135665)
+++ trunk/Source/WTF/WTF.gyp/WTF.gyp	2012-11-25 07:25:16 UTC (rev 135666)
@@ -65,9 +65,6 @@
 
           # Turns on #if PLATFORM(CHROMIUM)
           'BUILDING_CHROMIUM__=1',
-          # Controls wtf/FastMalloc
-          # FIXME: consider moving into config.h
-          'USE_SYSTEM_MALLOC=1',
         ],
         'conditions': [
           ['OS=="win"', {
@@ -83,7 +80,6 @@
           }],
           ['OS=="mac"', {
             'defines': [
-              # Use USE_NEW_THEME on Mac.
               'WTF_USE_NEW_THEME=1',
             ],
           }],
@@ -130,7 +126,6 @@
         ['exclude', '(Default|Gtk|Mac|None|Qt|Win|Wx|Efl)\\.(cpp|mm)$'],
         ['exclude', 'wtf/OSRandomSource\\.cpp$'],
         ['exclude', 'wtf/MainThread.cpp$'],
-        ['exclude', 'wtf/TC.*\\.(cpp|h)$'],
       ],
       'direct_dependent_settings': {
         'include_dirs': [
@@ -181,6 +176,12 @@
             }],
           ],
         }],
+        ['OS!="mac"', {
+          'sources/': [
+            # mac is the only OS that uses WebKit's copy of TCMalloc.
+            ['exclude', 'wtf/TC.*\\.(cpp|h)$'],
+          ],
+        }],
       ],
     },
   ]

Modified: trunk/Source/WTF/wtf/Platform.h (135665 => 135666)


--- trunk/Source/WTF/wtf/Platform.h	2012-11-25 04:49:14 UTC (rev 135665)
+++ trunk/Source/WTF/wtf/Platform.h	2012-11-25 07:25:16 UTC (rev 135666)
@@ -575,10 +575,21 @@
 #if PLATFORM(CHROMIUM) && OS(DARWIN)
 #define WTF_USE_CF 1
 #define WTF_USE_PTHREADS 1
-
 #define WTF_USE_WK_SCROLLBAR_PAINTER 1
 #endif
 
+#if PLATFORM(CHROMIUM)
+#if OS(DARWIN)
+/* We can't override the global operator new and delete on OS(DARWIN) because
+ * some object are allocated by WebKit and deallocated by the embedder. */
+#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
+#else /* !OS(DARWIN) */
+/* On non-OS(DARWIN), the "system malloc" is actually TCMalloc anyway, so there's
+ * no need to use WebKit's copy of TCMalloc. */
+#define USE_SYSTEM_MALLOC 1
+#endif /* OS(DARWIN) */
+#endif /* PLATFORM(CHROMIUM) */
+
 #if PLATFORM(IOS)
 #define DONT_FINALIZE_ON_MAIN_THREAD 1
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to