|
|
Created:
4 years, 1 month ago by Charlie Harrison Modified:
4 years ago Reviewers:
esprehn CC:
blink-reviews, chromium-reviews Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionOptimize KURL protocols
This patch optimizes KURL::protocol and KURL::protocolIs by keeping
an AtomicString m_protocol on KURL. This reduces string allocations
throughout the code using KURL::protocol().
This also fixes an inconsistency with KURL::protocolIs that will return
true for invalid URLs.
BUG=348655
Committed: https://crrev.com/775abc2d7c903f191f7b24f8b299ebabbea3f624
Cr-Commit-Position: refs/heads/master@{#438197}
Patch Set 1 #Patch Set 2 : cleanup #Patch Set 3 : more clean up #Patch Set 4 : 16 bit test #
Total comments: 3
Patch Set 5 : clean up patch #Patch Set 6 : Avoid hashing for http/https, add atoms, etc. #Patch Set 7 : sync to #430381 #Patch Set 8 : simplify #
Total comments: 7
Patch Set 9 : add dchecks #
Messages
Total messages: 58 (45 generated)
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. BUG= ========== to ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URL. With this patch, KURL::protocolIs(<protocol>) == (KURL.protocol() == <protocol>). BUG= ==========
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL)
Description was changed from ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URL. With this patch, KURL::protocolIs(<protocol>) == (KURL.protocol() == <protocol>). BUG= ========== to ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This reduces string allocations throughout the code using KURL::protocol(). This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URLs. BUG=348655 ==========
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
csharrison@chromium.org changed reviewers: + esprehn@chromium.org
esprehn, this has less win than the string hashing CL, but it's a good step for further optimizing SchemeRegistry. Wins will also compound once we remove the HashMap there and can just do a series AtomicString comparisons. There's also a reasonable reduction in KURL complexity here. WDYT?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
I think something is missing in this patch? Your string is not atomic and you're assigning the string to itself which doesn't do anything. https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (right): https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/weborigin/KURL.cpp:788: m_protocol = (m_protocol); what does this do? assigning m_protocol to itself seems like it doesn't do anything. https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/weborigin/KURL.h (right): https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/weborigin/KURL.h:218: String m_protocol; This isn't atomic
Sorry, let me re-upload the patch. https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (right): https://codereview.chromium.org/2463703002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/weborigin/KURL.cpp:788: m_protocol = (m_protocol); On 2016/11/04 23:48:32, esprehn wrote: > what does this do? assigning m_protocol to itself seems like it doesn't do > anything. Oops. That should be m_protocol = AtomicString(m_protocol). Sorry about that :/
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_clang_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_clan...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
So, here's the updated patch with a few changes. - I've added http/https atoms, and rather than hashing the protocol in initProtocolMetadata, we first try to see if the url is http/https (common case). To avoid an allocation I've added componentStringView method. - http/https atom added in SchemeRegistry
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_clang on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_clang/builds/...)
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_arm64_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_arm6...)
esprehn: would you take another look at this? Another benefit here is we avoid doing hashSlowCase for every newly allocated protocol. A common pattern is calling KURL::protocol() and looking it up in a map.
Are you sure this is right? The old code ignored case, and the new code is case-sensitive so a protocol of "HTTP" is now not in the http family and protocolIs("HTTP") will return false. Is that correct? https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (left): https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:815: return internalProtocolIs(scheme, spec, "http-so"); This was all case insensitive before. https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (right): https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:814: m_protocol == "http-so" || m_protocol == "https-so"; What strange protocols are these? https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:826: return m_protocol == protocol; internalProtocolIs was case insensitive, are you sure this is right?
I think this should be OK. In general we want protocol comparisons to be case sensitive (same with host comparison). This is how e.g. GURL::SchemeIs() is implemented. https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (left): https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:815: return internalProtocolIs(scheme, spec, "http-so"); On 2016/12/12 22:18:46, esprehn wrote: > This was all case insensitive before. We should always have a canonical, lowercase scheme here, so the case insensitivity was not necessary. We could probably DCHECK this fact though. https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (right): https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:814: m_protocol == "http-so" || m_protocol == "https-so"; On 2016/12/12 22:18:46, esprehn wrote: > What strange protocols are these? suborigin protocols: https://w3c.github.io/webappsec-suborigins/#representation I think these are rare so I didn't add them to the atomic string table. https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:826: return m_protocol == protocol; On 2016/12/12 22:18:46, esprehn wrote: > internalProtocolIs was case insensitive, are you sure this is right? assertProtocolIsGood checks that the input protocol wasn't uppercase ASCII.
lgtm
The CQ bit was checked by csharrison@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Many thanks for the review. I've just cleaned things up slightly and added a few DCHECKs. https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/weborigin/KURL.cpp (left): https://codereview.chromium.org/2463703002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/weborigin/KURL.cpp:815: return internalProtocolIs(scheme, spec, "http-so"); On 2016/12/12 22:26:06, Charlie Harrison wrote: > On 2016/12/12 22:18:46, esprehn wrote: > > This was all case insensitive before. > > We should always have a canonical, lowercase scheme here, so the case > insensitivity was not necessary. We could probably DCHECK this fact though. Actually, we have a DCHECK_EQ(protocol(), protocol().lower()) in KURL::init from a previous patch which removed a lot of random protocol.lower() in a bunch of places in the codebase. Let me move it to initProtocolMetadata which will catch more cases.
The CQ bit was unchecked by csharrison@chromium.org
The CQ bit was checked by csharrison@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from esprehn@chromium.org Link to the patchset: https://codereview.chromium.org/2463703002/#ps160001 (title: "add dchecks")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 160001, "attempt_start_ts": 1481645012011040, "parent_rev": "11fd06a29111ddc3f9c32f761dd9c813f40b5a41", "commit_rev": "334c786f4ac4fdd6df634ecc970b33dfc0702d79"}
Message was sent while issue was closed.
Description was changed from ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This reduces string allocations throughout the code using KURL::protocol(). This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URLs. BUG=348655 ========== to ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This reduces string allocations throughout the code using KURL::protocol(). This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URLs. BUG=348655 Review-Url: https://codereview.chromium.org/2463703002 ==========
Message was sent while issue was closed.
Committed patchset #9 (id:160001)
Message was sent while issue was closed.
Description was changed from ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This reduces string allocations throughout the code using KURL::protocol(). This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URLs. BUG=348655 Review-Url: https://codereview.chromium.org/2463703002 ========== to ========== Optimize KURL protocols This patch optimizes KURL::protocol and KURL::protocolIs by keeping an AtomicString m_protocol on KURL. This reduces string allocations throughout the code using KURL::protocol(). This also fixes an inconsistency with KURL::protocolIs that will return true for invalid URLs. BUG=348655 Committed: https://crrev.com/775abc2d7c903f191f7b24f8b299ebabbea3f624 Cr-Commit-Position: refs/heads/master@{#438197} ==========
Message was sent while issue was closed.
Patchset 9 (id:??) landed as https://crrev.com/775abc2d7c903f191f7b24f8b299ebabbea3f624 Cr-Commit-Position: refs/heads/master@{#438197}
Message was sent while issue was closed.
A revert of this CL (patchset #9 id:160001) has been created in https://codereview.chromium.org/2586253004/ by csharrison@chromium.org. The reason for reverting is: Causing DCHECK flakes. crbug.com/674388. |