REOPENED 228053
DFGByteCodeParser.cpp should avoid resizing the Operands<> of every BasicBlock on every inlining
https://bugs.webkit.org/show_bug.cgi?id=228053
Summary DFGByteCodeParser.cpp should avoid resizing the Operands<> of every BasicBloc...
Robin Morisset
Reported 2021-07-17 20:01:48 PDT
The dfg bytecode parser only makes use of block->variablesAtTail. But currently it updates the size of variablesAtHead, valuesAtHead, valuesAtTail and intersectionOfPastValuesAtHead every single time it changes the number of Tmps and/or Locals. This happens notably whenever it inlines a function. It is not nearly as cheap as it looks, as each resizing may reallocate a Vector, requires filling the new slots with zeros, and requires moving the existing values (which are all 0) to the new Vector. This was obvious when looking at profiling of JS2: bzero + memmove are the two hottest C++ functions, and the manipulation of Operands is partly responsible. It can be easily improved: only resize block->variablesAtTail on inlining, and initialize all of the other operands at the very end of the DFGByteCodeParser.
Attachments
Patch (13.79 KB, patch)
2021-07-17 20:06 PDT, Robin Morisset
no flags
Patch (13.92 KB, patch)
2021-07-17 20:09 PDT, Robin Morisset
no flags
Patch (13.91 KB, patch)
2021-07-17 20:11 PDT, Robin Morisset
saam: review+
ews-feeder: commit-queue-
Patch (13.99 KB, patch)
2021-11-17 18:20 PST, Robin Morisset
no flags
Robin Morisset
Comment 1 2021-07-17 20:06:08 PDT
Robin Morisset
Comment 2 2021-07-17 20:09:43 PDT
Created attachment 433742 [details] Patch updated Changelog with perf numbers.
Robin Morisset
Comment 3 2021-07-17 20:11:37 PDT
Created attachment 433743 [details] Patch Fix style nitpick.
Radar WebKit Bug Importer
Comment 4 2021-07-24 20:02:16 PDT
Saam Barati
Comment 5 2021-11-17 15:57:14 PST
Comment on attachment 433743 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=433743&action=review r=me > Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:8971 > + block->variablesAtHead = Operands<Node*>(m_numArguments, m_numLocals, m_numTmps); > + block->valuesAtHead = Operands<AbstractValue>(m_numArguments, m_numLocals, m_numTmps); > + block->valuesAtTail = Operands<AbstractValue>(m_numArguments, m_numLocals, m_numTmps); > + block->intersectionOfPastValuesAtHead = Operands<AbstractValue>(m_numArguments, m_numLocals, m_numTmps); nit: Use the OperandsLike constructor so these lines of code don't have to change in the future if we change the Operands constructor you're invoking?
Robin Morisset
Comment 6 2021-11-17 18:20:26 PST
Created attachment 444624 [details] Patch Applied Saam's suggestion and rebased
EWS
Comment 7 2021-11-18 14:57:05 PST
Committed r286030 (244418@main): <https://commits.webkit.org/244418@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 444624 [details].
WebKit Commit Bot
Comment 8 2021-11-19 15:17:55 PST
Re-opened since this is blocked by bug 233387
Note You need to log in before you can comment on or make changes to this bug.