Commit b905986f authored by slewis@apple.com's avatar slewis@apple.com
Browse files

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.

Reviewed by Geoff Garen.

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



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7cd53ed1
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.
......
......@@ -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;
......
......@@ -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]} )
......
......@@ -1712,7 +1712,7 @@
);
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;
......
<?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>
......@@ -817,7 +817,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BCB281EE0CFA713D007E533E /* Base.xcconfig */;
buildSettings = {
WEBKIT_FRAMEWORK_RESOURCES_PATH = WebKit.framework/Versions/A/Resources;
WEBKIT_FRAMEWORK_RESOURCES_PATH = /AppleInternal/WebKitTools;
};
name = Production;
};
......@@ -833,7 +833,7 @@
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;
......@@ -842,7 +842,7 @@
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;
......@@ -851,7 +851,7 @@
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;
......
......@@ -113,6 +113,8 @@ sub main()
}
}
$line =~ s/(\|\s*0x[0-9a-f]+\s*\|)/\|/g;
# Then give up
next if (!$callCount || !$byteCount);
......
......@@ -108,7 +108,6 @@ sub testapiPath($)
{
my ($productDir) = @_;
my $jscName = "testapi";
$jscName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
return "$productDir/$jscName";
}
......
......@@ -231,7 +231,6 @@ sub jscPath($)
{
my ($productDir) = @_;
my $jscName = "jsc";
$jscName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
return "$productDir/$jscName";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment