Open Bug 1341900 Opened 7 years ago Updated 2 years ago

WriteStructuredClone can be slow on Google Drive

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

REOPENED
Performance Impact low

People

(Reporter: ehsan.akhgari, Unassigned)

References

Details

(Keywords: perf)

I noticed this with <https://drive.google.com/drive/u/1/folders/0BzDhuKIxRtxdY2NucFRIQWZkZlU> open (requires LDAP access.)  See the profile: https://perfht.ml/2kNMh2B  This is on the 2-17 nightly.
Sounds like bug 1339481.
Yes it is: bool js::SCOutput::writeArray<unsigned short>(unsigned short const*, unsigned long)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
(In reply to Andrea Marchesini [:baku] from comment #2)
> Yes it is: bool js::SCOutput::writeArray<unsigned short>(unsigned short
> const*, unsigned long)
> 
> *** This bug has been marked as a duplicate of bug 1339481 ***

That bug really only handled the uint8_t case, not this. (And I don't even know if it'll make much of a difference; it depends on whether the optimizer was doing the same thing already.)

It looks like this case is pretty similar, though; AFAICT writeArray<unsigned short> will only be called for writeChars(const char16_t* p, size_t nchars). So it's possible that a similar specialization would help, though we'd need to decide whether to specialize on endianness as well.

But both cases may end up requiring sharing the data or using external strings or something.

Though if you invert the call stack, you'll see that this bug's profile has 36ms for cloning uint8_t and 22ms for unsigned short. I guess this bug is for the 16-bit string portion.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Whiteboard: [qf:p1]
Whiteboard: [qf:p1] → [qf:p3]
Some sessionstore code seems to hit the 16-bot version of this function in the parent process: https://perfht.ml/2nzDBOp

Doesn't take a huge amount of time each time, but this sessionstore stuff is unfortunately super inefficient, so anything we could do to cut it down would be nice.
Keywords: perf
Priority: -- → P3
Depends on: 1483998
I can't see the testcase, but it would be good to know if the changes under bug 1483998 helped. I haven't looked into optimizing the 16-bit writeArray, but in my profiles it looked like all time under those was just a memcpy.
Here is a new profile based on what I remember I did at the time (open the spreadsheet in comment 0, hold the arrow key to scroll all the way to the end really quickly): https://perfht.ml/2pzQebe
Performance Impact: --- → P3
Whiteboard: [qf:p3]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.