Commit 9b77c40d authored by ggaren@apple.com's avatar ggaren@apple.com

REGRESSION (r143759): 40% JSBench regression, 20% Octane/closure regression,...

REGRESSION (r143759): 40% JSBench regression, 20% Octane/closure regression, 40% Octane/jquery regression, 2% Octane regression
https://bugs.webkit.org/show_bug.cgi?id=111797

Reviewed by Oliver Hunt.

The bot's testing configuration stresses the cache's starting guess
of 1MB.

This patch removes any starting guess, and just uses wall clock time
to discover the initial working set size of an app, in code size.

* runtime/CodeCache.cpp:
(JSC::CodeCacheMap::pruneSlowCase): Update our timer as we go.

Also fixed a bug where pruning from 0 to 0 would hang -- that case is
a possibility now that we start with a capacity of 0.

* runtime/CodeCache.h:
(CodeCacheMap):
(JSC::CodeCacheMap::CodeCacheMap):
(JSC::CodeCacheMap::add):
(JSC::CodeCacheMap::prune): Don't prune if we're in the middle of
discovering the working set size of an app, in code size.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 735da70b
2013-03-07 Geoffrey Garen <ggaren@apple.com>
REGRESSION (r143759): 40% JSBench regression, 20% Octane/closure regression, 40% Octane/jquery regression, 2% Octane regression
https://bugs.webkit.org/show_bug.cgi?id=111797
Reviewed by Oliver Hunt.
The bot's testing configuration stresses the cache's starting guess
of 1MB.
This patch removes any starting guess, and just uses wall clock time
to discover the initial working set size of an app, in code size.
* runtime/CodeCache.cpp:
(JSC::CodeCacheMap::pruneSlowCase): Update our timer as we go.
Also fixed a bug where pruning from 0 to 0 would hang -- that case is
a possibility now that we start with a capacity of 0.
* runtime/CodeCache.h:
(CodeCacheMap):
(JSC::CodeCacheMap::CodeCacheMap):
(JSC::CodeCacheMap::add):
(JSC::CodeCacheMap::prune): Don't prune if we're in the middle of
discovering the working set size of an app, in code size.
2013-03-07 Michael Saboff <msaboff@apple.com>
Crash when updating predictions below JSC::arrayProtoFuncForEach on tuaw.com article
......
......@@ -36,9 +36,18 @@
namespace JSC {
const double CodeCacheMap::workingSetTime = 10.0;
void CodeCacheMap::pruneSlowCase()
{
while (m_size >= m_capacity) {
m_minCapacity = m_size - m_sizeAtLastPrune;
m_sizeAtLastPrune = m_size;
m_timeAtLastPrune = monotonicallyIncreasingTime();
if (m_capacity < m_minCapacity)
m_capacity = m_minCapacity;
while (m_size > m_capacity) {
MapType::iterator it = m_map.begin();
m_size -= it->key.length();
m_map.remove(it);
......
......@@ -31,6 +31,7 @@
#include "SourceCode.h"
#include "Strong.h"
#include "WeakRandom.h"
#include <wtf/CurrentTime.h>
#include <wtf/FixedArray.h>
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
......@@ -135,16 +136,16 @@ public:
typedef MapType::iterator iterator;
typedef MapType::AddResult AddResult;
enum { MinCacheCapacity = 1000000 }; // Size in characters
CodeCacheMap()
: m_size(0)
, m_capacity(MinCacheCapacity)
, m_sizeAtLastPrune(0)
, m_timeAtLastPrune(monotonicallyIncreasingTime())
, m_minCapacity(0)
, m_capacity(0)
, m_age(0)
{
}
AddResult add(const SourceCodeKey& key, const SourceCodeValue& value)
{
prune();
......@@ -167,8 +168,8 @@ public:
// infer that requested objects are subject to low eviction probability,
// so we shrink the cache to save memory.
m_capacity -= recencyBias * key.length();
if (m_capacity < MinCacheCapacity)
m_capacity = MinCacheCapacity;
if (m_capacity < m_minCapacity)
m_capacity = m_minCapacity;
}
addResult.iterator->value.age = m_age;
......@@ -192,6 +193,11 @@ public:
int64_t age() { return m_age; }
private:
// This constant factor biases cache capacity toward allowing a minimum
// working set to enter the cache before it starts evicting.
static const double workingSetTime;
static const int64_t workingSetMax = 16000000;
// This constant factor biases cache capacity toward recent activity. We
// want to adapt to changing workloads.
static const int64_t recencyBias = 4;
......@@ -204,13 +210,21 @@ private:
void pruneSlowCase();
void prune()
{
if (m_size < m_capacity)
if (m_size <= m_capacity)
return;
if (monotonicallyIncreasingTime() - m_timeAtLastPrune < workingSetTime
&& m_size - m_sizeAtLastPrune < workingSetMax)
return;
pruneSlowCase();
}
MapType m_map;
int64_t m_size;
int64_t m_sizeAtLastPrune;
double m_timeAtLastPrune;
int64_t m_minCapacity;
int64_t m_capacity;
int64_t m_age;
};
......
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