Bug 186703

Summary: CachedRawResource wastes 57K of Vector capacity
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: Page LoadingAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, cdumez, commit-queue, dbates, ews-watchlist, japhet, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Simon Fraser (smfr) 2018-06-15 15:04:07 PDT
On theverge.com, tooling from bug 186698:
Wasted capacity: 57584 bytes (used 4880 of 62464 bytes, utilization: 7.81%) - 13 allocations
1   0x107ee28b5 WTF::VectorBuffer<WebCore::CachedRawResource::RedirectPair, 0ul>::VectorBuffer()
2   0x107ee2895 WTF::Vector<WebCore::CachedRawResource::RedirectPair, 0ul, WTF::CrashOnOverflow, 16ul>::Vector()
3   0x107ec4b75 WTF::Vector<WebCore::CachedRawResource::RedirectPair, 0ul, WTF::CrashOnOverflow, 16ul>::Vector()
4   0x107ec4b04 WebCore::CachedRawResource::CachedRawResource(WebCore::CachedResourceRequest&&, WebCore::CachedResource::Type, PAL::SessionID)
5   0x107ec4bcb WebCore::CachedRawResource::CachedRawResource(WebCore::CachedResourceRequest&&, WebCore::CachedResource::Type, PAL::SessionID)
6   0x107ed1700 WebCore::createResource(WebCore::CachedResource::Type, WebCore::CachedResourceRequest&&, PAL::SessionID)
7   0x107ed13ca WebCore::CachedResourceLoader::loadResource(WebCore::CachedResource::Type, WebCore::CachedResourceRequest&&)
8   0x107ece32d WebCore::CachedResourceLoader::requestResource(WebCore::CachedResource::Type, WebCore::CachedResourceRequest&&, WebCore::CachedResourceLoader::ForPreload, WebCore::CachedResourceLoader::DeferOption)
Comment 1 Radar WebKit Bug Importer 2018-06-15 15:04:24 PDT
<rdar://problem/41173515>
Comment 2 Chris Dumez 2018-06-15 15:27:59 PDT
Vector<RedirectPair> m_redirectChain; in CachedRawResource.
We never reserve capacity explicitly and only call append() on it.
Comment 3 Chris Dumez 2018-06-15 15:42:59 PDT
Looks like Vector has a default inlineCapacity of 0 but a minCapacity of 16.
Note that the Vector contains ResourceResponse & ResponseRequest objects, which are large.
Comment 4 Chris Dumez 2018-06-15 16:03:22 PDT
Note that as long as the vector is empty, its capacity is 0, even though the default minCapacity is 16. However, as soon as you append one element to the Vector, capacity jumps from 0 to 16.
Comment 5 Chris Dumez 2018-06-15 16:10:26 PDT
Created attachment 342855 [details]
Patch
Comment 6 WebKit Commit Bot 2018-06-15 16:54:19 PDT
Comment on attachment 342855 [details]
Patch

Clearing flags on attachment: 342855

Committed r232897: <https://trac.webkit.org/changeset/232897>
Comment 7 WebKit Commit Bot 2018-06-15 16:54:20 PDT
All reviewed patches have been landed.  Closing bug.