Don't overallocate in CachedMetadata |
|||||
Issue descriptionCachedMetdata has a Vector<char> member and calls append() in its constructor. The problem is that Vector::append(data, size) calls expandCapacity(size), which allocates "(size / 4) + 1" more bytes than needed. Metadata can be quite large, 288 KiB was seen in [1], but that is a total number, which decomposes into 230 KiB of actual data and 58 KiB of wasted memory. The fix is to reserve enough space, either by using Vector(size) constructor, or by explicitly calling reserveInitialCapacity(). Slightly involved fix is to add Vector(data, size) constructor, which might be useful in other places. There is at least one other place where Vector::append() is called in a constructor: PushMessageData, but I suspect there are instances of this pattern in functions, too. It might be interesting to profile Vector and find out how many instances were not modified after first append(). [1] https://docs.google.com/spreadsheets/d/13knYGLMXB5opE7vlDUsvreNcYr-FEi_mmaJ2YZVfS6M/edit#gid=159723971
,
Aug 11 2016
,
Aug 18 2016
,
Aug 18 2016
,
Aug 31 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2805c285bf5a0b681c2ad648c0d5506aa26985d1 commit 2805c285bf5a0b681c2ad648c0d5506aa26985d1 Author: yhirano <yhirano@chromium.org> Date: Wed Aug 31 02:41:24 2016 Reserve Vector's capacity manually in CachedMetadata As CachedMetaData::m_serializedData is set only at the initialization timing, we can call Vector<char>::reserveCapacity to save memory consumption without loosing performance. This CL includes other cleanups: - Renaming methods, - Replacing error handling logic with DCHECKs, - Replacing unsigned with uint32_t. BUG= 636462 Review-Url: https://codereview.chromium.org/2258743002 Cr-Commit-Position: refs/heads/master@{#415544} [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/core/core.gypi [add] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/core/fetch/CachedMetadata.cpp [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/core/fetch/CachedMetadata.h [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/core/fetch/CachedMetadataHandler.h [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/core/fetch/Resource.cpp [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.cpp [modify] https://crrev.com/2805c285bf5a0b681c2ad648c0d5506aa26985d1/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h
,
Aug 31 2016
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by esprehn@chromium.org
, Aug 10 2016Labels: -OS-Android OS-All