Bug 195595 - blocksInPreOrder and blocksInPostOrder should reserve the right capacity for their result vector
Summary: blocksInPreOrder and blocksInPostOrder should reserve the right capacity for ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Robin Morisset
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-03-11 18:39 PDT by Robin Morisset
Modified: 2019-03-12 10:43 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.04 KB, patch)
2019-03-11 18:46 PDT, Robin Morisset
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Morisset 2019-03-11 18:39:14 PDT
Since we know that the result vector will be exactly the size of m_blocks (it is just a permutation).
We should also remove the inline capacity of that vector: even most small functions will have more than 5 BB.
Comment 1 Robin Morisset 2019-03-11 18:46:06 PDT
Created attachment 364332 [details]
Patch
Comment 2 Saam Barati 2019-03-11 18:50:29 PDT
Comment on attachment 364332 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=364332&action=review

> Source/JavaScriptCore/dfg/DFGBasicBlock.h:260
> +typedef Vector<BasicBlock*> BlockList;

What’s the motivation here?
Comment 3 Saam Barati 2019-03-11 18:51:23 PDT
(In reply to Robin Morisset from comment #0)
> We should also remove the inline capacity of that vector: even most small
> functions will have more than 5 BB.

Based on what data? This is actually a bit surprising to me
Comment 4 Robin Morisset 2019-03-11 19:07:32 PDT
(In reply to Saam Barati from comment #3)
> (In reply to Robin Morisset from comment #0)
> > We should also remove the inline capacity of that vector: even most small
> > functions will have more than 5 BB.
> 
> Based on what data? This is actually a bit surprising to me

I had just observed that while debugging some small test cases.

I just tested it on JetStream2. Out of 39158 calls to blocksIn{Pre/Post}Order, only 13676 had 5 or less BasicBlocks. So the current inline capacity is only used in 1/3 of cases, and it otherwise wastes space for no reason.
Here are some more numbers in case we really want an inline capacity here for some reason:
- 1 BB: 7806
- <= 4 BB: 12129
- <= 8 BB: 17974
- <= 16 BB: 25612
- <= 32 BB: 32558
- <= 34 BB: 37144
Comment 5 Robin Morisset 2019-03-12 10:14:39 PDT
> - <= 34 BB: 37144

This one should have been <= 64 BB of course.
Comment 6 WebKit Commit Bot 2019-03-12 10:42:49 PDT
Comment on attachment 364332 [details]
Patch

Clearing flags on attachment: 364332

Committed r242802: <https://trac.webkit.org/changeset/242802>
Comment 7 WebKit Commit Bot 2019-03-12 10:42:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2019-03-12 10:43:23 PDT
<rdar://problem/48813529>