Changeset 286045 in webkit
- Timestamp:
- Nov 18, 2021, 10:06:32 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
b3/air/AirAllocateRegistersByGraphColoring.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r286042 r286045 1 2021-11-18 Robin Morisset <rmorisset@apple.com> 2 3 [JSC/Air] Optimize enableMovesOnValueAndAdjacents in IRC 4 https://bugs.webkit.org/show_bug.cgi?id=228615 5 6 Reviewed by Saam Barati. 7 8 The Iterated Register Coalescing (IRC) register allocator spends a very significant fraction of its time in JS2 in enableMovesOnValueAndAdjacents (816ms out of 2.07s spent in register allocation for Wasm code in one run I looked at with Instruments). 9 The reason is that if this function is called on N nodes that are neighbors of each other, then enableMovesOnValue (which is kinda expensive as it iterates a SmallSet which is not always small) will be called N times on each of the N nodes. This can trivially be fixed by keeping track of which nodes need enableMovesOnValue called on them and only calling it on them once. 10 11 It is a bit tricky to measure the performance impact of this, as it heavily depends on whether some very large functions reach Air or not, so there is a lot of noise. 12 Here are the numbers out of 4 runs of JS2 (cli version) on an M1 MBP with --airForceIRCAllocator=1: 13 Baseline : total time in allocateRegistersByGraphColoring ranges from 2090ms to 3018ms, most time for a single function ranges from 631ms to 849ms 14 With this patch: total time in allocateRegistersByGraphColoring ranges from 1580ms to 2333ms, most time for a single function ranges from 337ms to 560ms 15 So despite the noise it seems quite clearly a win. 16 17 * b3/air/AirAllocateRegistersByGraphColoring.cpp: 18 1 19 2021-11-18 Mark Lam <mark.lam@apple.com> 2 20 -
trunk/Source/JavaScriptCore/b3/air/AirAllocateRegistersByGraphColoring.cpp
r280689 r286045 913 913 IRC(Code& code, const Vector<Reg>& regsInPriorityOrder, IndexType lastPrecoloredRegisterIndex, unsigned tmpArraySize, const BitVector& unspillableTmps, const UseCounts& useCounts) 914 914 : Base(code, regsInPriorityOrder, lastPrecoloredRegisterIndex, tmpArraySize, unspillableTmps, useCounts) 915 , m_movesToEnable(tmpArraySize) 915 916 { 916 917 } … … 942 943 if (!m_simplifyWorklist.isEmpty()) 943 944 simplify(); 945 else if (!m_movesToEnable.isEmpty()) 946 enableMoves(); 944 947 else if (!m_worklistMoves.isEmpty()) 945 948 coalesce(); … … 1104 1107 unsigned oldDegree = m_degrees[tmpIndex]--; 1105 1108 if (oldDegree == registerCount()) { 1106 enableMovesOnValueAndAdjacents(tmpIndex);1109 lazyEnableMovesOnValueAndAdjacents(tmpIndex); 1107 1110 m_spillWorklist.quickClear(tmpIndex); 1108 1111 if (isMoveRelated(tmpIndex)) … … 1147 1150 } 1148 1151 1152 void lazyEnableMovesOnValueAndAdjacents(IndexType tmpIndex) 1153 { 1154 m_movesToEnable.quickSet(tmpIndex); 1155 forEachAdjacent(tmpIndex, [this] (IndexType adjacentTmpIndex) { 1156 m_movesToEnable.quickSet(adjacentTmpIndex); 1157 }); 1158 } 1159 1149 1160 void enableMovesOnValue(IndexType tmpIndex) 1150 1161 { … … 1155 1166 } 1156 1167 1157 void enableMovesOnValueAndAdjacents(IndexType tmpIndex) 1158 { 1159 enableMovesOnValue(tmpIndex); 1160 1161 forEachAdjacent(tmpIndex, [this] (IndexType adjacentTmpIndex) { 1162 enableMovesOnValue(adjacentTmpIndex); 1163 }); 1168 void enableMoves() 1169 { 1170 for (IndexType tmpIndex : m_movesToEnable) 1171 enableMovesOnValue(tmpIndex); 1172 m_movesToEnable.clearAll(); 1164 1173 } 1165 1174 … … 1310 1319 // Set of "move" not yet ready for coalescing. 1311 1320 BitVector m_activeMoves; 1321 // Set of Tmps whose moves are now ready for possible coalescing. 1322 BitVector m_movesToEnable; 1312 1323 }; 1313 1324
Note:
See TracChangeset
for help on using the changeset viewer.