Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upcss background image parsing takes a very long time/hangs #13778
Comments
|
Thanks for the report! @Manishearth Do you think this is good piranha food? |
|
I don't think so ... this is pretty curious and I don't see any immediately obvious reason behind it, so it might not be best for new contributors. @wafflespeanut or @canaltinova might be interested in poking at this (otherwise I'll have a look) |
|
Looks like it uses data URIs, and perhaps we're very slow at parsing those? @SimonSapin However, those are directly on |
|
Oh, there are a bunch of CSS |
|
I doubt we're parsing image |
|
Yes, like I said. But there are other background-images in the inline CSS. |
|
And also the font-face rules. |
|
Actually I bet most of the time there is spent parsing the font-face rules. I might take a deeper look today if I find the time. |
|
This webpage is also hanging on my Firefox 51 and Chrome 53(MacOS 10.12). Are we sure it is servo related? |
|
Yeah, but those aren't in the path mentioned in the issue above. Still building, but will run with instruments to see if url parsing is the real culprit. Looks like rust-url treats data URIs as any other kind of URI? I wonder if we can optimize this case since there's no transformation (punycode or otherwise) to be done here and we just need to verify that it belongs to a set of characters. There should be some bitmask algorithms that are able to operate on chunks here. |
|
@Manishearth: Are you sure |
|
@canaltinova could be. Works fine for me on Firefox Dev. But I have a rather fast laptop so it might still be a hang-y page |
|
@Manishearth: it goes to |
|
Hm... You're right, I'm sleepy apparently :-) |
|
Heh, I was looking at how did we deal with invalid URIs (because it's a valid declared value to do something like |
|
FWIW, my profile looks way different than yours, taking ~30% of the time in |
|
Yes, mine also has that fucntion in it |
|
Fully expanded at heavy bits: It seems to be taking lots of time with tokenizing on the style side. As @emilio said On the URL side, it seems to be very worried about BurntSushi mentioned that he'd gotten some major wins from using utf8-ranges which gives you the tools necessary for matching sets of unicode ranges against a string with fast byte comparisons. ... Really, with a lazy_static precompiled regex, we might be able to steal the regex crate's speed here. Though handling percent-encoding could get tricky. (Of course, we should investigate further before jumping to a solution) |
|
Hm, the clone only happens when there's a backslash char though. These are base64 URIs, they probably won't have those. Still, that code could do with a (I suspect there are a lot of other small improvements to be made here; parsing URIs isn't something you'd overoptimize, until you realize that folks stuff entire images into URIs |
|
|
The patch over servo/rust-cssparser#110 should make a decent difference on this test case. |
|
That patch applied locally moves |
|
Oh, because we're just copying non-ascii chars anyway, and we already know that the string is valid utf8. Good catch. |
|
We might want to bypass rust-url entirely for |
|
Still need to check if its valid. Though the tokenizer does that already for unquoted uris |
|
I have local patches to fix #13779 and share the result of url resolution. That makes the tokenizer the higher in the profile again, and now servo crashes due to an assertion on IPC-channel due to a too large font loaded in memory and passed via IPC I think. I'll try to clean them up a bit and submit them today. |
…-url. Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with servo#13778
…-url. Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with servo#13778
…-url. Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with servo#13778
…-url. Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with servo#13778
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
Update rust-cssparser for speed improvements when tokenizing strings and data uris <!-- Please describe your changes on the following line: --> See #13778 r? @SimonSapin (or anyone else really). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14245) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
Update rust-cssparser for speed improvements when tokenizing strings and data uris <!-- Please describe your changes on the following line: --> See #13778 r? @SimonSapin (or anyone else really). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14245) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
WIP: Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
Urlmageddon <!-- Please describe your changes on the following line: --> Still needs a bunch of code in net to be converted in order to get more advantage of this for images and stuff, but meanwhile this should help quite a bit with #13778. Still wanted to get this in. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14246) <!-- Reviewable:end -->
|
Even after these changes we're still spending a lot of time in url::parser::Parser::parse_cannot_be_a_base_path. We're also spending a bigger chunk of time in cssparser::tokenizer::consume_ident_like now. |
|
For unquoted URIs I guess we should try and skip to the next closing brace as fast as possible? What does Firefox do? |
|
As far as I know Gecko also goes through the whole URI, but using a table to indicate which kind of byte is it instead of the whole branching we go through. See |
|
@jrmuizel are you sure we are expending more time in The first seems really unlikely to me except if you're using debug assertions (in which case it'll verify the final token is valid utf8 in https://github.com/servo/rust-cssparser/pull/110/files#diff-0bd70f3585cde6d2d2aff02435db9070R844) |
|
@emilio It could just be a higher percentage of the time. i.e. we used to be spending a much larger amount of time in parse_cannot_be_a_base_path before and so I didn't notice consume_ident_like earlier. |
…en tokenizing strings and data uris (from emilio:cssparser); r=nox <!-- Please describe your changes on the following line: --> See servo/servo#13778 r? @SimonSapin (or anyone else really). Source-Repo: https://github.com/servo/servo Source-Revision: 843a25f9f4adf354d5291cb43ccf0f6e7c866b82
|
The sample is gone and many parsing improvements were done as part of Stylo, closing this. |
…en tokenizing strings and data uris (from emilio:cssparser); r=nox <!-- Please describe your changes on the following line: --> See servo/servo#13778 r? SimonSapin (or anyone else really). Source-Repo: https://github.com/servo/servo Source-Revision: 843a25f9f4adf354d5291cb43ccf0f6e7c866b82 UltraBlame original commit: a170342a47705943efa35ebbfa4ff8f11fbe72fb
…en tokenizing strings and data uris (from emilio:cssparser); r=nox <!-- Please describe your changes on the following line: --> See servo/servo#13778 r? SimonSapin (or anyone else really). Source-Repo: https://github.com/servo/servo Source-Revision: 843a25f9f4adf354d5291cb43ccf0f6e7c866b82 UltraBlame original commit: a170342a47705943efa35ebbfa4ff8f11fbe72fb
…en tokenizing strings and data uris (from emilio:cssparser); r=nox <!-- Please describe your changes on the following line: --> See servo/servo#13778 r? SimonSapin (or anyone else really). Source-Repo: https://github.com/servo/servo Source-Revision: 843a25f9f4adf354d5291cb43ccf0f6e7c866b82 UltraBlame original commit: a170342a47705943efa35ebbfa4ff8f11fbe72fb


http://people.mozilla.org/~jmuizelaar/webrender/sites/instagram.html causes servo to spend a very long time in style::properties::longhands::background_image::parse_declared
@bholley