WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-136592-20140905165230.patch (text/plain), 7.94 KB, created by
Geoffrey Garen
on 2014-09-05 16:52:35 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Geoffrey Garen
Created:
2014-09-05 16:52:35 PDT
Size:
7.94 KB
patch
obsolete
>Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 173341) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,13 @@ >+2014-09-05 Geoffrey Garen <ggaren@apple.com> >+ >+ bmalloc should honor the FastMalloc statistics API >+ https://bugs.webkit.org/show_bug.cgi?id=136592 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/FastMalloc.cpp: >+ (WTF::fastMallocStatistics): >+ > 2014-09-05 Geoffrey Garen <ggaren@apple.com> > > bmalloc should honor the FastMalloc scavenging API >Index: Source/WTF/wtf/FastMalloc.cpp >=================================================================== >--- Source/WTF/wtf/FastMalloc.cpp (revision 173338) >+++ Source/WTF/wtf/FastMalloc.cpp (working copy) >@@ -74,6 +74,8 @@ > // * allocation of a reasonably complicated struct > // goes from about 1100 ns to about 300 ns. > >+#define USE_BMALLOC 1 >+ > #include "config.h" > #include "FastMalloc.h" > >@@ -477,7 +479,11 @@ void releaseFastMallocFreeMemory() > > FastMallocStatistics fastMallocStatistics() > { >- FastMallocStatistics statistics = { 0, 0, 0 }; >+ FastMallocStatistics statistics; >+ statistics.committedVMBytes = bmalloc::api::heapSize(); >+ statistics.reservedVMBytes = bmalloc::api::heapCapacity(); >+ statistics.freeListBytes = 0; // bmalloc doesn't really have free lists. >+ > return statistics; > } > >Index: Source/bmalloc/ChangeLog >=================================================================== >--- Source/bmalloc/ChangeLog (revision 173341) >+++ Source/bmalloc/ChangeLog (working copy) >@@ -1,3 +1,43 @@ >+2014-09-05 Geoffrey Garen <ggaren@apple.com> >+ >+ bmalloc should honor the FastMalloc statistics API >+ https://bugs.webkit.org/show_bug.cgi?id=136592 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We do this by tracking "size" and "capacity" in the VM heap. >+ >+ The VM heap's "capacity" is all the VM we ever allocated. >+ >+ The VM heap's "size" is the subset of its capacity that the regular heap >+ is not using. >+ >+ Somewhat ironically, reducing the process's memory footprint, increases >+ the size of the VM heap, since the VM heap holds the pages that are >+ purely virtual and not physical. >+ >+ * bmalloc/Heap.cpp: >+ (bmalloc::Heap::size): >+ (bmalloc::Heap::capacity): >+ * bmalloc/Heap.h: >+ * bmalloc/VMHeap.cpp: >+ (bmalloc::VMHeap::VMHeap): >+ (bmalloc::VMHeap::allocateSmallChunk): >+ (bmalloc::VMHeap::allocateMediumChunk): >+ (bmalloc::VMHeap::allocateLargeChunk): >+ * bmalloc/VMHeap.h: >+ (bmalloc::VMHeap::size): >+ (bmalloc::VMHeap::capacity): >+ (bmalloc::VMHeap::allocateSmallPage): >+ (bmalloc::VMHeap::allocateMediumPage): >+ (bmalloc::VMHeap::allocateLargeRange): >+ (bmalloc::VMHeap::deallocateSmallPage): >+ (bmalloc::VMHeap::deallocateMediumPage): >+ (bmalloc::VMHeap::deallocateLargeRange): >+ * bmalloc/bmalloc.h: >+ (bmalloc::api::heapSize): >+ (bmalloc::api::heapCapacity): >+ > 2014-09-02 Geoffrey Garen <ggaren@apple.com> > > bmalloc crashes on the EWS bots (due to bad large object allocation) >Index: Source/bmalloc/bmalloc/Heap.cpp >=================================================================== >--- Source/bmalloc/bmalloc/Heap.cpp (revision 173333) >+++ Source/bmalloc/bmalloc/Heap.cpp (working copy) >@@ -210,4 +210,14 @@ void Heap::deallocateLarge(std::lock_gua > m_scavenger.run(); > } > >+size_t Heap::size(std::lock_guard<StaticMutex>&) >+{ >+ return m_vmHeap.capacity() - m_vmHeap.size(); >+} >+ >+size_t Heap::capacity(std::lock_guard<StaticMutex>&) >+{ >+ return m_vmHeap.capacity(); >+} >+ > } // namespace bmalloc >Index: Source/bmalloc/bmalloc/Heap.h >=================================================================== >--- Source/bmalloc/bmalloc/Heap.h (revision 173333) >+++ Source/bmalloc/bmalloc/Heap.h (working copy) >@@ -62,7 +62,10 @@ public: > void deallocateXLarge(std::lock_guard<StaticMutex>&, void*); > > void scavenge(std::unique_lock<StaticMutex>&, std::chrono::milliseconds sleepDuration); >- >+ >+ size_t size(std::lock_guard<StaticMutex>&); >+ size_t capacity(std::lock_guard<StaticMutex>&); >+ > private: > ~Heap() = delete; > >Index: Source/bmalloc/bmalloc/VMHeap.cpp >=================================================================== >--- Source/bmalloc/bmalloc/VMHeap.cpp (revision 173333) >+++ Source/bmalloc/bmalloc/VMHeap.cpp (working copy) >@@ -33,6 +33,8 @@ > namespace bmalloc { > > VMHeap::VMHeap() >+ : m_size(0) >+ , m_capacity(0) > { > } > >@@ -41,6 +43,9 @@ void VMHeap::allocateSmallChunk() > SmallChunk* chunk = SmallChunk::create(); > for (auto* it = chunk->begin(); it != chunk->end(); ++it) > m_smallPages.push(it); >+ >+ m_size += smallChunkSize; >+ m_capacity += smallChunkSize; > } > > void VMHeap::allocateMediumChunk() >@@ -48,12 +53,19 @@ void VMHeap::allocateMediumChunk() > MediumChunk* chunk = MediumChunk::create(); > for (auto* it = chunk->begin(); it != chunk->end(); ++it) > m_mediumPages.push(it); >+ >+ m_size += mediumChunkSize; >+ m_capacity += mediumChunkSize; > } > > Range VMHeap::allocateLargeChunk() > { > LargeChunk* chunk = LargeChunk::create(); > Range result = BoundaryTag::init(chunk); >+ >+ m_size += largeChunkSize; >+ m_capacity += largeChunkSize; >+ > return result; > } > >Index: Source/bmalloc/bmalloc/VMHeap.h >=================================================================== >--- Source/bmalloc/bmalloc/VMHeap.h (revision 173333) >+++ Source/bmalloc/bmalloc/VMHeap.h (working copy) >@@ -45,6 +45,9 @@ class VMHeap { > public: > VMHeap(); > >+ size_t size() { return m_size; } >+ size_t capacity() { return m_capacity; } >+ > SmallPage* allocateSmallPage(); > MediumPage* allocateMediumPage(); > Range allocateLargeRange(size_t); >@@ -57,7 +60,10 @@ private: > void allocateSmallChunk(); > void allocateMediumChunk(); > Range allocateLargeChunk(); >- >+ >+ size_t m_size; >+ size_t m_capacity; >+ > Vector<SmallPage*> m_smallPages; > Vector<MediumPage*> m_mediumPages; > SegregatedFreeList m_largeRanges; >@@ -68,6 +74,7 @@ inline SmallPage* VMHeap::allocateSmallP > if (!m_smallPages.size()) > allocateSmallChunk(); > >+ m_size -= vmPageSize; > return m_smallPages.pop(); > } > >@@ -76,6 +83,7 @@ inline MediumPage* VMHeap::allocateMediu > if (!m_mediumPages.size()) > allocateMediumChunk(); > >+ m_size -= vmPageSize; > return m_mediumPages.pop(); > } > >@@ -84,6 +92,7 @@ inline Range VMHeap::allocateLargeRange( > Range range = m_largeRanges.take(size); > if (!range) > range = allocateLargeChunk(); >+ m_size -= range.size(); > return range; > } > >@@ -93,6 +102,7 @@ inline void VMHeap::deallocateSmallPage( > vmDeallocatePhysicalPages(page->begin()->begin(), vmPageSize); > lock.lock(); > >+ m_size += vmPageSize; > m_smallPages.push(page); > } > >@@ -102,6 +112,7 @@ inline void VMHeap::deallocateMediumPage > vmDeallocatePhysicalPages(page->begin()->begin(), vmPageSize); > lock.lock(); > >+ m_size += vmPageSize; > m_mediumPages.push(page); > } > >@@ -125,6 +136,7 @@ inline void VMHeap::deallocateLargeRange > beginTag->setHasPhysicalPages(false); > endTag->setHasPhysicalPages(false); > >+ m_size += range.size(); > m_largeRanges.insert(range); > } > >Index: Source/bmalloc/bmalloc/bmalloc.h >=================================================================== >--- Source/bmalloc/bmalloc/bmalloc.h (revision 173333) >+++ Source/bmalloc/bmalloc/bmalloc.h (working copy) >@@ -89,5 +89,17 @@ inline void scavenge() > PerProcess<Heap>::get()->scavenge(lock, std::chrono::milliseconds(0)); > } > >+inline size_t heapSize() >+{ >+ std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex()); >+ return PerProcess<Heap>::get()->size(lock); >+} >+ >+inline size_t heapCapacity() >+{ >+ std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex()); >+ return PerProcess<Heap>::get()->capacity(lock); >+} >+ > } // namespace api > } // namespace bmalloc
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 136592
:
237721
|
237722