NEW206094
Add Lightweight Optimization Level (LOL) to the compilation pipeline
https://bugs.webkit.org/show_bug.cgi?id=206094
Summary Add Lightweight Optimization Level (LOL) to the compilation pipeline
Saam Barati
Reported 2020-01-10 14:37:58 PST
original plan try to do this as a replacement of the baseline.
Attachments
WIP (7.01 KB, patch)
2020-01-16 15:26 PST, Saam Barati
no flags
WIP (10.63 KB, patch)
2020-06-23 19:18 PDT, Saam Barati
no flags
WIP (11.93 KB, patch)
2020-06-24 17:53 PDT, Saam Barati
no flags
WIP (15.31 KB, patch)
2020-06-25 14:25 PDT, Saam Barati
no flags
WIP (22.88 KB, patch)
2020-06-25 17:34 PDT, Saam Barati
no flags
WIP (31.16 KB, patch)
2020-06-26 12:40 PDT, Saam Barati
no flags
WIP (39.59 KB, patch)
2020-06-26 16:39 PDT, Saam Barati
no flags
WIP (39.69 KB, patch)
2020-06-26 16:44 PDT, Saam Barati
no flags
WIP (46.72 KB, patch)
2020-06-29 19:19 PDT, Saam Barati
no flags
WIP (58.91 KB, patch)
2020-07-01 21:01 PDT, Saam Barati
no flags
WIP (68.62 KB, patch)
2020-07-08 15:35 PDT, Saam Barati
no flags
WIP (69.29 KB, patch)
2020-07-08 20:20 PDT, Saam Barati
no flags
WIP (72.31 KB, patch)
2020-07-08 20:49 PDT, Saam Barati
no flags
WIP (74.80 KB, patch)
2020-07-09 19:25 PDT, Saam Barati
no flags
WIP (80.67 KB, patch)
2020-07-10 16:23 PDT, Saam Barati
no flags
WIP (82.62 KB, patch)
2020-07-10 20:14 PDT, Saam Barati
no flags
WIP (142.03 KB, patch)
2020-07-16 19:35 PDT, Saam Barati
no flags
WIP (142.88 KB, patch)
2020-09-22 14:34 PDT, Saam Barati
no flags
WIP (144.36 KB, patch)
2020-09-22 14:50 PDT, Saam Barati
no flags
WIP (144.36 KB, patch)
2020-09-22 16:00 PDT, Saam Barati
no flags
WIP (145.64 KB, patch)
2020-09-24 15:31 PDT, Saam Barati
no flags
WIP (147.77 KB, patch)
2020-09-29 17:52 PDT, Saam Barati
no flags
WIP (149.19 KB, patch)
2020-09-30 12:36 PDT, Saam Barati
no flags
WIP (155.71 KB, patch)
2020-10-01 19:41 PDT, Saam Barati
no flags
WIP (167.37 KB, patch)
2020-10-02 19:14 PDT, Saam Barati
no flags
WIP (169.73 KB, patch)
2020-10-05 15:48 PDT, Saam Barati
no flags
WIP (177.53 KB, patch)
2020-10-05 19:30 PDT, Saam Barati
no flags
WIP (181.89 KB, patch)
2020-10-06 18:44 PDT, Saam Barati
no flags
WIP (192.90 KB, patch)
2020-10-07 13:06 PDT, Saam Barati
no flags
WIP (209.06 KB, patch)
2020-10-07 19:35 PDT, Saam Barati
no flags
WIP (212.58 KB, patch)
2020-10-19 16:46 PDT, Saam Barati
no flags
WIP (217.53 KB, patch)
2020-10-19 18:20 PDT, Saam Barati
no flags
WIP (242.07 KB, patch)
2020-10-20 18:27 PDT, Saam Barati
no flags
WIP (245.42 KB, patch)
2020-10-26 12:27 PDT, Saam Barati
no flags
WIP (260.26 KB, patch)
2020-10-26 19:29 PDT, Saam Barati
no flags
WIP (271.29 KB, patch)
2020-10-27 17:20 PDT, Saam Barati
no flags
WIP (271.29 KB, patch)
2020-10-27 17:30 PDT, Saam Barati
no flags
WIP (277.24 KB, patch)
2020-11-02 17:07 PST, Saam Barati
no flags
WIP (296.57 KB, patch)
2020-11-09 13:39 PST, Saam Barati
no flags
WIP (303.26 KB, patch)
2020-11-10 15:15 PST, Saam Barati
no flags
WIP (316.59 KB, patch)
2020-11-10 17:05 PST, Saam Barati
no flags
WIP (323.40 KB, patch)
2020-11-12 15:54 PST, Saam Barati
no flags
WIP (323.52 KB, patch)
2020-11-12 16:01 PST, Saam Barati
no flags
WIP (348.06 KB, patch)
2020-11-12 20:44 PST, Saam Barati
no flags
WIP (370.09 KB, patch)
2020-11-13 13:35 PST, Saam Barati
no flags
WIP (375.27 KB, patch)
2020-11-13 18:55 PST, Saam Barati
no flags
WIP (379.61 KB, patch)
2020-12-01 14:18 PST, Saam Barati
no flags
WIP (382.03 KB, patch)
2020-12-02 19:33 PST, Saam Barati
no flags
WIP (387.09 KB, patch)
2020-12-03 15:11 PST, Saam Barati
no flags
WIP (404.62 KB, patch)
2020-12-03 19:52 PST, Saam Barati
no flags
WIP (405.18 KB, patch)
2020-12-04 16:03 PST, Saam Barati
no flags
WIP (406.68 KB, patch)
2020-12-04 16:53 PST, Saam Barati
no flags
WIP (407.67 KB, patch)
2020-12-04 17:39 PST, Saam Barati
no flags
WIP (412.51 KB, patch)
2020-12-04 19:45 PST, Saam Barati
no flags
WIP (415.22 KB, patch)
2020-12-07 15:58 PST, Saam Barati
no flags
WIP (429.59 KB, patch)
2020-12-07 18:51 PST, Saam Barati
no flags
WIP (431.99 KB, patch)
2020-12-07 19:53 PST, Saam Barati
no flags
WIP (433.01 KB, patch)
2020-12-08 11:46 PST, Saam Barati
no flags
WIP (468.46 KB, patch)
2020-12-08 13:30 PST, Saam Barati
no flags
WIP (443.66 KB, patch)
2020-12-08 14:19 PST, Saam Barati
no flags
WIP (463.08 KB, patch)
2020-12-08 16:51 PST, Saam Barati
no flags
WIP (470.07 KB, patch)
2020-12-09 15:33 PST, Saam Barati
no flags
WIP (449.71 KB, patch)
2020-12-09 17:44 PST, Saam Barati
no flags
WIP (456.77 KB, patch)
2020-12-10 12:48 PST, Saam Barati
no flags
WIP (459.45 KB, patch)
2020-12-10 16:32 PST, Saam Barati
no flags
WIP (461.71 KB, patch)
2020-12-11 12:34 PST, Saam Barati
no flags
WIP (461.71 KB, patch)
2020-12-14 11:20 PST, Saam Barati
no flags
WIP (462.80 KB, patch)
2020-12-14 14:10 PST, Saam Barati
no flags
WIP (467.60 KB, patch)
2020-12-16 19:12 PST, Saam Barati
no flags
WIP (467.60 KB, patch)
2020-12-17 11:02 PST, Saam Barati
no flags
WIP (479.01 KB, patch)
2020-12-17 19:19 PST, Saam Barati
no flags
WIP (504.92 KB, patch)
2020-12-18 19:18 PST, Saam Barati
no flags
WIP (505.58 KB, patch)
2020-12-21 12:09 PST, Saam Barati
no flags
WIP (524.68 KB, patch)
2020-12-21 15:55 PST, Saam Barati
no flags
WIP (538.37 KB, patch)
2021-01-06 13:29 PST, Saam Barati
no flags
WIP (538.31 KB, patch)
2021-01-06 14:25 PST, Saam Barati
no flags
WIP (543.16 KB, patch)
2021-01-06 16:42 PST, Saam Barati
no flags
WIP (547.35 KB, patch)
2021-01-07 12:32 PST, Saam Barati
no flags
WIP (550.51 KB, patch)
2021-01-11 11:59 PST, Saam Barati
no flags
WIP (551.27 KB, patch)
2021-01-11 13:26 PST, Saam Barati
no flags
WIP (553.26 KB, patch)
2021-01-11 18:24 PST, Saam Barati
no flags
WIP (559.40 KB, patch)
2021-01-12 12:30 PST, Saam Barati
no flags
WIP (559.40 KB, patch)
2021-01-12 12:44 PST, Saam Barati
no flags
WIP (563.79 KB, patch)
2021-01-12 16:59 PST, Saam Barati
no flags
WIP (568.09 KB, patch)
2021-01-13 15:57 PST, Saam Barati
no flags
WIP (571.47 KB, patch)
2021-01-13 17:17 PST, Saam Barati
no flags
WIP (572.43 KB, patch)
2021-01-14 15:49 PST, Saam Barati
no flags
WIP (591.02 KB, patch)
2021-01-15 18:01 PST, Saam Barati
no flags
WIP (601.30 KB, patch)
2021-01-19 16:26 PST, Saam Barati
no flags
WIP (605.90 KB, patch)
2021-01-19 17:07 PST, Saam Barati
no flags
WIP (605.86 KB, patch)
2021-01-20 14:36 PST, Saam Barati
no flags
WIP (606.70 KB, patch)
2021-01-20 15:02 PST, Saam Barati
no flags
WIP (616.44 KB, patch)
2021-01-22 13:17 PST, Saam Barati
no flags
WIP (619.73 KB, patch)
2021-01-22 18:05 PST, Saam Barati
no flags
WIP (623.17 KB, patch)
2021-01-25 12:09 PST, Saam Barati
no flags
WIP (626.14 KB, patch)
2021-02-02 18:51 PST, Saam Barati
no flags
WIP (626.14 KB, patch)
2021-02-03 11:53 PST, Saam Barati
no flags
Saam Barati
Comment 1 2020-01-16 15:26:37 PST
Created attachment 387969 [details] WIP it begins
Saam Barati
Comment 2 2020-01-23 15:45:11 PST
We're probably going to change directions here and invent a new optimizer that works over bytecode. The main optimizations we're planning on doing are type speculation and register allocation. To get fast compile times, the goal will also be to not have to construct an entirely new IR. We'd also want to get to the point where each opcode can speculate on what its inputs are without doing some kind of prediction propagation phase. Many opcodes already have enough metadata to do this. However, not all do. We'll have to invent ways for all to do this. Our reasoning for this was based on this data. Here is the JS2 score in various configurations of JSC: [A] Baseline only: 67 [B] DFG only: 137 [C] DFG only, no inlining, no access inlining, AI says each structure set is infinite, but each variable still has a flush format: 116 [D] DFG only, no inlining, no access inlining, AI says each structure set is infinite, each variable has JSValue flush format: 109 [E] DFG only, no inlining, no access inlining, AI says each structure set is infinite, each variable has JSValue flush format, no intrinsic inlining: 106 Here are our compile time numbers on a large subset of JS2 in [E]: Baseline Compile Time: 171.968 ms DFG Compile Time: 1396.220 ms FTL (B3) Compile Time: 0.000 ms FTL (DFG) Compile Time: 0.000 ms FTL Compile Time: 0.000 ms Total Compile Time: 1568.189 ms [DFG] bytecode parser total ms: 380.117813 [DFG] live catch variable preservation phase total ms: 1.461701 [DFG] CPS rethreading total ms: 48.442496 [DFG] unification total ms: 11.940636 [DFG] prediction injection total ms: 2.781105 [DFG] static execution count estimation total ms: 43.239496 [DFG] backwards propagation total ms: 22.783780 [DFG] prediction propagation total ms: 51.928968 [DFG] fixup total ms: 55.983858 [DFG] invalidation point injection total ms: 24.982650 [DFG] control flow analysis total ms: 101.180000 [DFG] tier-up check injection total ms: 0.332139 [DFG] fast store barrier insertion total ms: 22.395290 [DFG] dead code elimination total ms: 42.648463 [DFG] phantom insertion total ms: 47.266917 [DFG] stack layout total ms: 12.130792 [DFG] virtual register allocation total ms: 10.887650 [DFG] watchpoint collection total ms: 4.037530 [DFG] machine code generation total ms: 259.451395 Just building the IR and generating machine code makes us > 2x slower than baseline compile times. As seen in [E], we get a lot of benefit just from register allocation and type speculation. Having a dedicated "IR" for making this fast could lead to really good results. The IR here could likely just be bit vectors for block boundaries representing the state of types. Or perhaps, we'd just need one bit vector we update as we parse a block. The goal would be able to do this over bytecode itself. This also had a nice OSR exit story, since if we're compiling the bytecode, OSR exit is straight forward.
Saam Barati
Comment 3 2020-06-23 12:30:01 PDT
I think we're gonna do this building off of baseline JIT. This allows us to incrementally improve the JIT without implementing all opcodes in optimized form.
Saam Barati
Comment 4 2020-06-23 19:18:46 PDT
Created attachment 402617 [details] WIP it begins round 2
Saam Barati
Comment 5 2020-06-24 17:53:16 PDT
Filip Pizlo
Comment 6 2020-06-24 19:01:21 PDT
Comment on attachment 402702 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=402702&action=review > Source/JavaScriptCore/jit/JIT.cpp:63 > +void JIT::stepOverInstruction(const Instruction* instruction, const HashMap<ValueProfile*, SpeculatedType>& profiles) Not sure you're going to want that to be a hashtable.
Saam Barati
Comment 7 2020-06-25 12:23:53 PDT
(In reply to Filip Pizlo from comment #6) > Comment on attachment 402702 [details] > WIP > > View in context: > https://bugs.webkit.org/attachment.cgi?id=402702&action=review > > > Source/JavaScriptCore/jit/JIT.cpp:63 > > +void JIT::stepOverInstruction(const Instruction* instruction, const HashMap<ValueProfile*, SpeculatedType>& profiles) > > Not sure you're going to want that to be a hashtable. Yeah I kinda doubted this too, and questioned it when I first started. The other thing I convinced myself is ok to do is to just racily read out the prediction. Since the prediction should only get wider as we read it, it shouldn't cause the algorithm to be unsound.
Saam Barati
Comment 8 2020-06-25 14:25:56 PDT
Saam Barati
Comment 9 2020-06-25 17:34:33 PDT
Saam Barati
Comment 10 2020-06-26 12:40:15 PDT
Saam Barati
Comment 11 2020-06-26 16:39:48 PDT
Created attachment 402928 [details] WIP Ok, I think the prediction propagator is good enough to start working on other parts of the system.
Saam Barati
Comment 12 2020-06-26 16:44:07 PDT
Saam Barati
Comment 13 2020-06-29 19:19:20 PDT
Saam Barati
Comment 14 2020-07-01 21:01:36 PDT
Created attachment 403342 [details] WIP It can now speculate and register allocate this program: ``` function foo(x) { x += 2; let y; if (x > 5) { y = 42; } else { y = 77; } x = x + 48; x = x + 1337; x = x + 42; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; x += y; return x + y; } ``` Unsurprisingly, runs 2x faster than old baseline code. Seems to compile in a similar amount of time.
Saam Barati
Comment 15 2020-07-08 15:35:27 PDT
Saam Barati
Comment 16 2020-07-08 20:20:05 PDT
Saam Barati
Comment 17 2020-07-08 20:49:48 PDT
Saam Barati
Comment 18 2020-07-09 19:25:03 PDT
Saam Barati
Comment 19 2020-07-10 16:23:49 PDT
Created attachment 404019 [details] WIP Starting to do some basic double math. It's ~2x faster also.
Saam Barati
Comment 20 2020-07-10 20:14:09 PDT
Saam Barati
Comment 21 2020-07-16 19:35:16 PDT
Saam Barati
Comment 22 2020-09-22 14:34:30 PDT
Created attachment 409399 [details] WIP rebased
Saam Barati
Comment 23 2020-09-22 14:50:42 PDT
Saam Barati
Comment 24 2020-09-22 16:00:33 PDT
Saam Barati
Comment 25 2020-09-24 15:31:56 PDT
Saam Barati
Comment 26 2020-09-29 17:52:29 PDT
Saam Barati
Comment 27 2020-09-30 12:36:07 PDT
Created attachment 410146 [details] WIP Getting silent refill working
Saam Barati
Comment 28 2020-10-01 19:41:07 PDT
Saam Barati
Comment 29 2020-10-02 19:14:42 PDT
Saam Barati
Comment 30 2020-10-05 15:48:09 PDT
Saam Barati
Comment 31 2020-10-05 19:30:23 PDT
Saam Barati
Comment 32 2020-10-06 18:44:37 PDT
Saam Barati
Comment 33 2020-10-07 13:06:32 PDT
Saam Barati
Comment 34 2020-10-07 19:35:03 PDT
Saam Barati
Comment 35 2020-10-19 16:46:42 PDT
Saam Barati
Comment 36 2020-10-19 18:20:43 PDT
Saam Barati
Comment 37 2020-10-20 18:27:39 PDT
Saam Barati
Comment 38 2020-10-20 18:29:23 PDT
Saam Barati
Comment 39 2020-10-26 12:27:32 PDT
Saam Barati
Comment 40 2020-10-26 19:29:27 PDT
Saam Barati
Comment 41 2020-10-27 17:20:13 PDT
Saam Barati
Comment 42 2020-10-27 17:30:02 PDT
Saam Barati
Comment 43 2020-11-02 17:07:34 PST
Saam Barati
Comment 44 2020-11-09 13:39:32 PST
Saam Barati
Comment 45 2020-11-10 15:15:15 PST
Saam Barati
Comment 46 2020-11-10 17:05:14 PST
Saam Barati
Comment 47 2020-11-12 15:54:55 PST
Saam Barati
Comment 48 2020-11-12 16:01:02 PST
Saam Barati
Comment 49 2020-11-12 20:44:57 PST
Saam Barati
Comment 50 2020-11-13 13:35:20 PST
Saam Barati
Comment 51 2020-11-13 18:55:03 PST
Saam Barati
Comment 52 2020-12-01 14:18:35 PST
Saam Barati
Comment 53 2020-12-02 19:33:33 PST
Saam Barati
Comment 54 2020-12-03 15:11:58 PST
Saam Barati
Comment 55 2020-12-03 19:52:44 PST
Saam Barati
Comment 56 2020-12-04 16:03:02 PST
Saam Barati
Comment 57 2020-12-04 16:53:46 PST
Created attachment 415476 [details] WIP Fixing a bunch of bugs in the baseline JIT when run without LOL
Saam Barati
Comment 58 2020-12-04 17:39:51 PST
Saam Barati
Comment 59 2020-12-04 19:45:31 PST
Saam Barati
Comment 60 2020-12-07 15:58:27 PST
Created attachment 415596 [details] WIP it's starting to run some of our tests
Saam Barati
Comment 61 2020-12-07 18:51:27 PST
Created attachment 415605 [details] WIP Fixing lots of bugs and implementing opcodes I forgot to rewrite.
Saam Barati
Comment 62 2020-12-07 19:53:47 PST
Saam Barati
Comment 63 2020-12-08 11:46:07 PST
Saam Barati
Comment 64 2020-12-08 13:30:47 PST
Created attachment 415670 [details] WIP When running just LOL, without any tier up past it, I'm at about a 5% failure rate of tests. Working through the failures before I start to focus more on perf.
Saam Barati
Comment 65 2020-12-08 14:19:15 PST
Saam Barati
Comment 66 2020-12-08 16:51:28 PST
Created attachment 415690 [details] WIP Turns out negative zero is a thing.
Saam Barati
Comment 67 2020-12-09 15:33:57 PST
Saam Barati
Comment 68 2020-12-09 17:44:43 PST
Saam Barati
Comment 69 2020-12-10 12:48:21 PST
Saam Barati
Comment 70 2020-12-10 16:32:17 PST
Saam Barati
Comment 71 2020-12-11 12:34:46 PST
Created attachment 416032 [details] WIP Seems to pass the tests now when running LOL instead of baseline and without tier up to DFG. Now, I need to focus on perf, there's a lot of obvious work to be done.
Saam Barati
Comment 72 2020-12-14 11:20:23 PST
Saam Barati
Comment 73 2020-12-14 14:10:12 PST
Created attachment 416193 [details] WIP rebased.
Saam Barati
Comment 74 2020-12-16 19:12:41 PST
Saam Barati
Comment 75 2020-12-17 11:02:18 PST
Saam Barati
Comment 76 2020-12-17 19:19:34 PST
Saam Barati
Comment 77 2020-12-18 19:18:29 PST
Saam Barati
Comment 78 2020-12-21 12:09:38 PST
Saam Barati
Comment 79 2020-12-21 15:55:11 PST
Saam Barati
Comment 80 2021-01-06 13:29:26 PST
Saam Barati
Comment 81 2021-01-06 14:25:41 PST
Saam Barati
Comment 82 2021-01-06 16:42:21 PST
Saam Barati
Comment 83 2021-01-07 12:32:26 PST
Saam Barati
Comment 84 2021-01-11 11:59:27 PST
Saam Barati
Comment 85 2021-01-11 13:26:17 PST
Saam Barati
Comment 86 2021-01-11 18:24:58 PST
Saam Barati
Comment 87 2021-01-12 12:30:04 PST
Saam Barati
Comment 88 2021-01-12 12:44:59 PST
Saam Barati
Comment 89 2021-01-12 16:59:01 PST
Saam Barati
Comment 90 2021-01-13 15:57:38 PST
Saam Barati
Comment 91 2021-01-13 17:17:07 PST
Saam Barati
Comment 92 2021-01-14 15:49:19 PST
Saam Barati
Comment 93 2021-01-15 18:01:32 PST
Saam Barati
Comment 94 2021-01-19 16:26:56 PST
Saam Barati
Comment 95 2021-01-19 17:07:49 PST
Saam Barati
Comment 96 2021-01-20 14:36:53 PST
Saam Barati
Comment 97 2021-01-20 15:02:14 PST
Saam Barati
Comment 98 2021-01-22 13:17:37 PST
Saam Barati
Comment 99 2021-01-22 18:05:52 PST
Saam Barati
Comment 100 2021-01-25 12:09:08 PST
Saam Barati
Comment 101 2021-02-02 18:51:30 PST
Saam Barati
Comment 102 2021-02-03 11:53:44 PST
Note You need to log in before you can comment on or make changes to this bug.