A Thorough Study
of Blink’s Memory
in Real-world Websites
*
*
*
*
{haraken, bashi, hajimehoshi, tasak}@chromium.org
2015 Oct
Memory team projects
*
*
Memory reduction
*
*
Goals of this talk
*
*
Understand real-world memory usage
What we have done
*
*
Improve tooling
*
*
Improve tooling
*
*
Improve tooling
*
*
Improve tooling
*
*
Object type | Size | Count |
Vector<RuleData> | 12256 byte | 3 |
Vector<RuleFeature> | 800 byte | 6 |
ImmutableStylePropertySet | 26 byte | 2112 |
... | ... | ... |
Improve tooling
StringImpl 536 KB
<--- AtomicString::AtomicString()
<--- ScriptResource::script()
*
*
Improve tooling
*
*
Understand real worlds
*
*
Understand real worlds
*
*
Break down of renderer’s memory
*
*
Page | Total (*1) | PartitionAlloc | Oilpan | V8 | Skia | Discardable | cc |
pinterest.com | 160.2 MB | 9.7% | 1.1% | 15.7% | 15.0% | 48.3% | 10.1% |
facebook.com | 47.2 MB | 18.0% | 1.9% | 50.6% | 6.1% | 8.5% | 15.0% |
theverge.com | 115.9 MB | 16.7% | 1.2% | 45.1% | 11.4% | 17.3% | 8.3% |
worldjournal.com | 261.5 MB | 9.9% | 0.6% | 77.1% | 4.3% | 4.6% | 3.5% |
wikipedia.org | 44.8 MB | 9.6% | 2.2% | 44.7% | 4.0% | 8.9% | 30.4% |
reddit.com | 45.9 MB | 13.7% | 2.2% | 43.6% | 5.7% | 8.7% | 25.6% |
wordpress.com | 111.4 MB | 2.5% | 0.9% | 9.1% | 19.7% | 55.7% | 12.2% |
plus.google.com | 156.9 MB | 17.8% | 0.8% | 60.3% | 2.7% | 7.7% | 9.4% |
blogspot.com | 47.3 MB | 11.8% | 2.1% | 44.2% | 4.9% | 8.5% | 28.5% |
mail.google.com | 114.7 MB | 14.7% | 0.9% | 66.2% | 1.2% | 3.5% | 11.8% |
Break down of renderer’s memory
*
*
Break down of PartitionAlloc’s memory
*
*
Break down of PartitionAlloc’s memory
*
*
Page | Total of PartitionAlloc | Buffer | FastMalloc | Node | Layout |
pinterest.com | 15.6 MB | 70.5% | 26.9% | 1.4% | 1.3% |
facebook.com | 8.5 MB | 72.9% | 21.2% | 2.9% | 2.2% |
theverge.com | 19.3 MB | 56.0% | 33.2% | 4.9% | 6.2% |
worldjournal.com | 25.9 MB | 49.8% | 41.3% | 4.6% | 4.3% |
wikipedia.org | 4.3 MB | 37.2% | 44.2% | 8.4% | 10.1% |
reddit.com | 6.3 MB | 52.4% | 33.3% | 6.0% | 8.3% |
wordpress.com | 2.8 MB | 42.9% | 46.4% | 5.7% | 6.1% |
plus.google.com | 27.9 MB | 64.5% | 32.6% | 1.2% | 1.5% |
blogspot.com | 5.6 MB | 62.5% | 30.4% | 5.0% | 2.9% |
mail.google.com | 16.9 MB | 68.1% | 28.4% | 1.9% | 1.6% |
Break down of PartitionAlloc’s memory
*
*
Break down of the Buffer partition
*
*
Page | Total of the Buffer partition | >50 KB StringImpls | <50 KB StringImpls | Vectors | HashTables | Others |
pinterest.com | 11 MB | 76.4% | 2.7% | 3.0% | 11.8% | 6.0% |
facebook.com | 6.2 MB | 71.0% | 4.8% | 1.7% | 13.0% | 9.5% |
theverge.com | 10.8 MB | 29.6% | 11.1% | 25.0% | 15.7% | 18.6% |
worldjournal.com | 12.9 MB | 14.0% | 32.6% | 23.3% | 20.2% | 20.9% |
wikipedia.org | 1.6 MB | 14.7% | 9.2% | 10.8% | 35.8% | 29.5% |
reddit.com | 3.3 MB | 22.0% | 8.3% | 20.0% | 27.0% | 22.7% |
wordpress.com | 1.2 MB | 0% | 12.7% | 10.6% | 30.4% | 46.3% |
plus.google.com | 18.0 MB | 39.4% | 3.3% | 28.3% | 20.0% | 9.0% |
blogspot.com | 3.5 MB | 51.4% | 5.7% | 13.7% | 14.6% | 14.6% |
mail.google.com | 11.5 MB | 40.9% | 16.5% | 14.8% | 15.7% | 12.1% |
Break down of the Buffer partition
*
*
Break down of the FastMalloc partition
*
*
Page | Total of the FastMalloc partition | SharedBuffers | Other objects |
pinterest.com | 4.2 MB | 35.7% | 64.3% |
facebook.com | 1.8 MB | 24.0% | 76.0% |
theverge.com | 6.4 MB | 25.0% | 75.0% |
worldjournal.com | 10.7 MB | 46.7% | 53.3% |
wikipedia.org | 1.9 MB | 17.1% | 72.9% |
reddit.com | 2.1 MB | 29.5% | 70.5% |
wordpress.com | 1.3 MB | 29.3% | 70.7% |
plus.google.com | 9.1 MB | 12.1% | 87.9% |
blogspot.com | 1.7 MB | 22.1% | 77.9% |
mail.google.com | 4.8 MB | 5.6 % | 94.4% |
Break down of the FastMalloc partition
*
*
Summary
*
*
Goal & Approach
Goal
*
*
Page | Total | PartitionAlloc’s rate |
pinterest.com | 160.2 MB | 9.7% |
facebook.com | 47.2 MB | 18.0% |
theverge.com | 115.9 MB | 16.7% |
worldjournal.com | 261.5 MB | 9.9% |
wikipedia.org | 44.8 MB | 9.6% |
reddit.com | 45.9 MB | 13.7% |
wordpress.com | 111.4 MB | 2.5% |
plus.google.com | 156.9 MB | 17.8% |
blogspot.com | 47.3 MB | 11.8% |
mail.google.com | 114.7 MB | 14.7% |
Goal
*
*
Goal
*
*
Goal
*
*
Approach
*
*
Approach
class MemoryPurgeController {
void dispatchPurgeMemory(...) { // Dispatched when Blink should save memory
for (auto& client : m_clients) // Our goal is to purge Blink’s memory by 30%
client->purgeMemory(...);
}
HashSet<MemoryPurgeClient*> m_clients;
};
class MemoryCache : public MemoryPurgeClient {
void purgeMemory(...) override { pruneAll(); } // Example
};
*
*
Approach
*
*
Approach
*
*
What we’ve learned so far
*
*
What we’ve learned so far
*
*
4 key projects
4 key projects
*
*
Compression of large StringImpls
*
*
Compression of large StringImpls
*
*
Page | Reduction rate |
pinterest.com | 63% |
facebook.com | 15% |
theverge.com | 11% |
worldjournal.com | 3% |
wikipedia.org | 19% |
reddit.com | 10% |
wordpress.com | 14% |
plus.google.com | 5% |
blogspot.com | 9% |
mail.google.com | 21% |
More aggressive Resource pruning
*
*
More aggressive Resource pruning
*
*
More aggressive Resource pruning
*
*
More aggressive Resource pruning
*
*
Discarding layout trees
*
*
Making V8 ⇔ Blink cycles collectable
*
*
Making V8 ⇔ Blink cycles collectable
*
*
Making V8 ⇔ Blink cycles collectable
*
*
Making V8 ⇔ Blink cycles collectable
*
*
Summary
*
*
Getting more teams involved
Getting more teams involved
*
*
Getting more teams involved
*
*
Getting more teams involved
*
*