Closed Bug 1404385 Opened 7 years ago Closed 7 years ago

atob() whitespace processing is slow even when not needed

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: agashlin, Assigned: agashlin)

Details

Attachments

(2 files, 1 obsolete file)

Attached file atob() microbenchmark
The whitespace removal code from bug 711180 always copies the input to a new string, even if there is no whitespace to remove. The attached microbenchmark shows converting 100MB takes over 2 seconds in current Nightly (58.0a1 (2017-09-29)) but around 700ms in current Chrome Canary (63.0.3225.0). This shows up in profiles of screenshots, for instance https://perfht.ml/2fDVOId .

I have a patch for this which simply doesn't make the copy unless needed.
Assignee: nobody → agashlin
Status: NEW → ASSIGNED
Priority: -- → P2
Comment on attachment 8913803 [details] [diff] [review]
Don't copy if not needed for whitespace removal

>+    trimmedString.Append(aAsciiBase64String.BeginReading(), cur - start);
Why not pass start as the first param? It is after all const char16_t* start = aAsciiBase64String.BeginReading();


Please ensure there are testcases for this: whitespace at the beginning, somewhere in the middle and at the end.
And also a case when there is only whitespace and no whitespace at all.
Attachment #8913803 - Flags: review?(bugs) → review+
New patch with the change recommended in comment 3 and a new test, carrying forward r+ as the code didn't change meaningfully. Some of these test cases were already covered by testing/web-platform/tests/html/webappapis/atob/base64.html but I wanted to be sure I covered all reasonable cases.
Attachment #8913803 - Attachment is obsolete: true
Attachment #8918481 - Flags: review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0efa71a9a60a
Don't copy if not needed for whitespace removal. r=smaug
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/0efa71a9a60a
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
No longer depends on: 1409411
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: