Bug 237002 - CachedResourceLoader::allCachedSVGImages() reparses resource URLs unnecessarily
Summary: CachedResourceLoader::allCachedSVGImages() reparses resource URLs unnecessarily
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-21 15:52 PST by Chris Dumez
Modified: 2022-02-22 17:28 PST (History)
8 users (show)

See Also:


Attachments
Patch (3.72 KB, patch)
2022-02-21 15:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-02-21 15:52:13 PST
CachedResourceLoader::allCachedSVGImages() reparses resource URLs unnecessarily:

Sample Count, Samples %, Normalized CPU %, Symbol
40, 0.1%, 0.0%, WebCore::CachedResourceLoader::allCachedSVGImages() const (in WebCore)
34, 0.1%, 0.0%,     WebCore::CachedResourceLoader::cachedResource(WTF::String const&) const (in WebCore)
31, 0.1%, 0.0%,         WebCore::Document::completeURL(WTF::String const&, WebCore::ScriptExecutionContext::ForceUTF8) const (in WebCore)
31, 0.1%, 0.0%,             WebCore::Document::completeURL(WTF::String const&, WTF::URL const&, WebCore::ScriptExecutionContext::ForceUTF8) const (in WebCore)
30, 0.0%, 0.0%,                 WTF::URL::URL(WTF::URL const&, WTF::String const&, WTF::URLTextEncoding const*) (in JavaScriptCore)
30, 0.0%, 0.0%,                     WTF::URLParser::URLParser(WTF::String const&, WTF::URL const&, WTF::URLTextEncoding const*) (in JavaScriptCore)
29, 0.0%, 0.0%,                         void WTF::URLParser::parse<unsigned char>(unsigned char const*, unsigned int, WTF::URL const&, WTF::URLTextEncoding const*) (in JavaScriptCore)
Comment 1 Chris Dumez 2022-02-21 15:57:17 PST
Created attachment 452790 [details]
Patch
Comment 2 Jonathan Bedard 2022-02-22 08:22:03 PST
Stopped https://ews-build.webkit.org/#/builders/70/builds/974, the 3 failures seen are already known.
Comment 3 Chris Dumez 2022-02-22 08:28:49 PST
(In reply to Jonathan Bedard from comment #2)
> Stopped https://ews-build.webkit.org/#/builders/70/builds/974, the 3
> failures seen are already known.

Oh, thank you for letting me know! My patch touches SVG and the 3 failures were on SVG tests so I was about to investigate.
Comment 4 Darin Adler 2022-02-22 14:46:22 PST
Comment on attachment 452790 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=452790&action=review

> Source/WebCore/ChangeLog:10
> +        Store URLs in the HashMaps instead of Strings since we have URLs initially and we
> +        need URLs eventually. This avoids having to re-parse the URL unnecessarily, which
> +        is fairly expensive.

It also makes the maps bigger; URLs share the strings, but the parsed offsets are separate in each URL. Hope that extra memory use is OK.
Comment 5 EWS 2022-02-22 17:27:41 PST
Committed r290341 (247661@main): <https://commits.webkit.org/247661@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452790 [details].
Comment 6 Radar WebKit Bug Importer 2022-02-22 17:28:21 PST
<rdar://problem/89326498>