Bug 197015 - [JSC] Optimize cases of Array.prototype.join/toString on huge empty arrays which result into one-character repeats
Summary: [JSC] Optimize cases of Array.prototype.join/toString on huge empty arrays wh...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-17 09:30 PDT by Yacine Bandou
Modified: 2022-07-01 15:39 PDT (History)
14 users (show)

See Also:


Attachments
Patch (4.73 KB, patch)
2019-04-17 10:00 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (4.75 KB, patch)
2019-04-17 10:23 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (6.65 KB, patch)
2019-05-10 09:33 PDT, Yacine Bandou
bandou.yacine: review?
bandou.yacine: commit-queue?
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yacine Bandou 2019-04-17 09:30:22 PDT
Add a fast case in Array.prototype.join when the array is empty and it uses array_storage indexingType and the separator length is less than 2.
    
Use the same optimisation that is used in the case of UNDECIDED indexingType, in order allocate the final string in one step, instead of
appending in a loop which consumes additional temporary memory.
Comment 1 Yacine Bandou 2019-04-17 10:00:23 PDT
Created attachment 367638 [details]
Patch
Comment 2 Yacine Bandou 2019-04-17 10:23:02 PDT
Created attachment 367645 [details]
Patch
Comment 3 Olivier Blin 2019-04-18 00:20:26 PDT
For reference, this has been done to optimize the memory consumption of the "CPU Memory Allocation" YouTube test here:
https://ytlr-cert.appspot.com/2019/main.html?test_type=functional-test
Comment 4 Yusuke Suzuki 2019-04-18 00:49:58 PDT
Comment on attachment 367645 [details]
Patch

Can you add tests?, like

1. simple test
2. array storage with some element
3. array storage + accessors
4. and so on
Comment 5 Yacine Bandou 2019-05-10 09:33:43 PDT
Created attachment 369554 [details]
Patch
Comment 6 Radar WebKit Bug Importer 2022-07-01 15:39:09 PDT
<rdar://problem/96318246>