Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GCActivityCallback timer should vary with the length of the previous GC
https://bugs.webkit.org/show_bug.cgi?id=80344

Reviewed by Geoffrey Garen.

* heap/Heap.cpp: Gave Heap the ability to keep track of the length of its last
GC length so that the GC Activity Callback can use it.
(JSC::Heap::Heap):
(JSC::Heap::collect):
* heap/Heap.h:
(JSC::Heap::lastGCLength):
(Heap):
* runtime/GCActivityCallbackCF.cpp:
(JSC):
(JSC::DefaultGCActivityCallback::operator()): Use the length of the Heap's last
GC to determine the length of our timer trigger (currently set at 100x the duration
of the last GC).


Canonical link: https://commits.webkit.org/97588@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Hahnenberg committed Mar 6, 2012
1 parent 368bdac commit 3312def
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,23 @@
2012-03-06 Mark Hahnenberg <mhahnenberg@apple.com>

GCActivityCallback timer should vary with the length of the previous GC
https://bugs.webkit.org/show_bug.cgi?id=80344

Reviewed by Geoffrey Garen.

* heap/Heap.cpp: Gave Heap the ability to keep track of the length of its last
GC length so that the GC Activity Callback can use it.
(JSC::Heap::Heap):
(JSC::Heap::collect):
* heap/Heap.h:
(JSC::Heap::lastGCLength):
(Heap):
* runtime/GCActivityCallbackCF.cpp:
(JSC):
(JSC::DefaultGCActivityCallback::operator()): Use the length of the Heap's last
GC to determine the length of our timer trigger (currently set at 100x the duration
of the last GC).

2012-03-06 Rob Buis <rbuis@rim.com>

BlackBerry] Fix cast-align gcc warnings when compiling JSC
Expand Down
4 changes: 4 additions & 0 deletions Source/JavaScriptCore/heap/Heap.cpp
Expand Up @@ -328,6 +328,7 @@ Heap::Heap(JSGlobalData* globalData, HeapSize heapSize)
, m_handleHeap(globalData)
, m_isSafeToCollect(false)
, m_globalData(globalData)
, m_lastGCLength(0)
{
(*m_activityCallback)();
m_numberOfFreeBlocks = 0;
Expand Down Expand Up @@ -781,6 +782,7 @@ void Heap::collect(SweepToggle sweepToggle)
ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
ASSERT(m_isSafeToCollect);
JAVASCRIPTCORE_GC_BEGIN();
double lastGCStartTime = WTF::currentTime();
#if ENABLE(GGC)
bool fullGC = sweepToggle == DoSweep;
if (!fullGC)
Expand Down Expand Up @@ -835,6 +837,8 @@ void Heap::collect(SweepToggle sweepToggle)
m_lastFullGCSize = newSize;
setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));
}
double lastGCEndTime = WTF::currentTime();
m_lastGCLength = lastGCEndTime - lastGCStartTime;
JAVASCRIPTCORE_GC_END();

(*m_activityCallback)();
Expand Down
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/heap/Heap.h
Expand Up @@ -138,6 +138,8 @@ namespace JSC {

void getConservativeRegisterRoots(HashSet<JSCell*>& roots);

double lastGCLength() { return m_lastGCLength; }

private:
friend class CodeBlock;
friend class LLIntOffsetsExtractor;
Expand Down Expand Up @@ -236,6 +238,7 @@ namespace JSC {
bool m_isSafeToCollect;

JSGlobalData* m_globalData;
double m_lastGCLength;
};

bool Heap::isBusy()
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/GCActivityCallbackCF.cpp
Expand Up @@ -53,7 +53,6 @@ struct DefaultGCActivityCallbackPlatformData {
};

const CFTimeInterval decade = 60 * 60 * 24 * 365 * 10;
const CFTimeInterval triggerInterval = 2; // seconds

void DefaultGCActivityCallbackPlatformData::trigger(CFRunLoopTimerRef timer, void *info)
{
Expand Down Expand Up @@ -95,6 +94,7 @@ void DefaultGCActivityCallback::commonConstructor(Heap* heap, CFRunLoopRef runLo

void DefaultGCActivityCallback::operator()()
{
CFTimeInterval triggerInterval = static_cast<Heap*>(d->context.info)->lastGCLength() * 100.0;
CFRunLoopTimerSetNextFireDate(d->timer.get(), CFAbsoluteTimeGetCurrent() + triggerInterval);
}

Expand Down

0 comments on commit 3312def

Please sign in to comment.