Replies: 15 comments 1 reply
-
|
This paper proposes a JIT strategy that records hot loop paths at runtime and compiles them into native code with type specialization. In traditional tracing-JITs, nested loops are complex to optimize because a naive implementation may very easily turn into tail-duplication, which can easily overflow the code cache. The innovation in this paper is to use a tracing tree, which keeps the structure relatively flat. A tracing-JIT approach also provides relatively cheap inter-procedural optimization because the traces naturally cross function boundaries. Because trace monkey is "loop-optimized" and type-specialized, it works well in code that is type-stable and has predictable loops. I'm particularly worried about how Trace Monkey would perform in code that depends on many types that make heavy use of dynamic dispatch. I'm worried that the cost of guards and compiling individual type-specialized traces would be detrimental to the program's performance. In modern tiered JIT systems, how can we strike the right division of labor between a tracing JIT and a method JIT? Can the optimization of one JIT type be used as additional information for the other? |
Beta Was this translation helpful? Give feedback.
-
|
critique It seems like this paper is a natural follow-on from the SELF paper, presenting a much more sophisticated version of the JIT features discussed in the SELF paper, while keeping stuff like the "property maps" used to obtain class information. It's also very definitely an engineering-oriented paper (unsurprising considering it came out of Mozilla) --- the researchers are very interested in providing an implementation more than theory. Historically, I'm curious whether anybody had tried to JIT JS before, and whether V8 /JSCore lifted ideas from this paper. There's also something of a comparch-esque concept in here of speculation and rollback --- they're essentially doing branch prediction for types (and also making use of it to accelerate loop code). I'm a little sceptical of their evaluation --- small programs is fine, but I wonder if they're measuring results on programs that look like what real JS is used for. I suppose that will vary, but if (for example) extensive DOM manipulation is taking place in the JS, does the code performance improvement look as good? questions One of the benchmarks is 25x faster than comparative implementations --- why? How could the startup time / overhead of tracing be improved? |
Beta Was this translation helpful? Give feedback.
-
CritiqueThis paper introduces TraceMonkey, the first trace-based JIT compiler for JavaScript. TraceMonkey identifies hot paths through loops and compiles them into fast type-specialized machine code. I found this paper pretty interesting to read. Particularly, I found solving the problem of nested loops with independent tree traces with inner loop calls and type map matching was especially clever. I do appreciate that this paper isn’t pure theory, and they actually implemented TraceMonkey to test the practicality of their theory. However, I felt that TraceMonkey is quite limited in handling JS language features. Notably, it doesn’t support recursion, which I feel like is very widely used across most languages. Questions
|
Beta Was this translation helpful? Give feedback.
-
|
Critique Question |
Beta Was this translation helpful? Give feedback.
-
|
Critique I also agree with the other comment regarding how the number 2 was chosen as the hotness threshold. Also, I wonder how valid the assumption is that most loops are type-invariant in real programs. Lastly, I do feel that the performance and implementation cost imposed by dynamic languages like JavaScript may not be worth the supposed ease of programming. In fact, many of the issues discussed in the paper could have been avoided just by having proper static typing. Discussion Questions
|
Beta Was this translation helpful? Give feedback.
-
|
CRITIQUE QUESTION |
Beta Was this translation helpful? Give feedback.
-
|
Critique Questions
|
Beta Was this translation helpful? Give feedback.
-
CritiqueThis paper demonstrates the implementation of TraceMonkey. The paper is seemingly straightforward and easy to folow. Something I'm very interested in are the failure cases and blacklisting. If a trace repeatedly cannot be recorded, it will blacklist it and replace the loop header to avoid monitoring it again. Overall, I believe this is a ingenious paper that has had a lasting impact on the computer science world. On researching its impact, I found that it has directly influenced V8, SpiderMonkey, PyPy, and LuaJit. QuestionsWhy is it that in modern day, that some engines(like SpiderMonkey for instance) have seemed to move away from pure tracing JITs? |
Beta Was this translation helpful? Give feedback.
-
|
Critique: One assumption this paper makes is that it expects hot loops to be mostly type-stable. In my opinion, this seems like quite a bit of an assumption to make. It also brings up the question of how impactful these optimizations are to modern workloads. The paper brings up JavaScript as a dynamic language that is used frequently for the highly interactive web browser environment. I am curious whether this approach adapts well to modern JavaScript workloads where loops are likely less explicit and type stability is harder to take advantage of. It would be cool to see if such a tracing system could adapt to a kind of event-driven hot path that is not statically a loop structured component. Question: |
Beta Was this translation helpful? Give feedback.
-
|
Critique |
Beta Was this translation helpful? Give feedback.
-
CritiqueDynamic languages are hard to be optimized at compile time because the type information is unknown. This paper presents a technique, that starts with fast-starting interpreter, then identifies hot executed loop traces at runtime and generates specialized machine code for these traces. QuestionThe paper optimizes individual loops based on two expectations: programs spend most of time in hot loops, and hot loops are always type-stable. Are these two expectations always the case in practice? Is there any scenario where the two expectations fail? |
Beta Was this translation helpful? Give feedback.
-
CritiqueThis paper presents TraceMonkey, which is a trace-based JIT compiler designed to accelerate dynamic languages like JavaScript. However, despite its many optimizations, it seems that Mozilla eventually replaced TraceMonkey with JägerMonkey. Since TraceMonkey is a trace-based JIT, it struggles with programs with many branches and complex control flow, so JägerMonkey, a method-based JIT, became more favorable. QuestionsThe paper explicitly notes recursion as a limitation and marks it as future work. What are the fundamental architectural challenges in making a trace-based system efficiently handle deep recursion? Would it require a completely different approach, like also incorporating a method-based JIT? |
Beta Was this translation helpful? Give feedback.
-
|
Critique Questions |
Beta Was this translation helpful? Give feedback.
-
|
Figured I'd leave a comment here given the schedule switch up this week. I have touched very little JavaScript in my life and intend to keep it that way. That said, I appreciate that this paper was super concrete and super detailed, and I found the nested trace tree formation particularly cool. My main critique here is that, as others have pointed out, the effectiveness of trace-based JIT is heavily dependent on whether programs adhere to assumptions. I suppose the effectiveness of any strategy is program-dependent, but it seems like there are a lot of cases where trace-based JIT doesn't work well, and this is somewhat unsatisfactorily addressed. They do give some reasons in the evaluation section on why speedups are smaller on some benchmarks, e.g. recursion; however, they say very little on whether it is feasible/what would have to be done to address these (pretend I phrased this as a question). The paper also employs a "blacklisting" strategy for programs that do not trace well; it would have been nice to see some more context on the characteristics of those programs. Do a lot of modern programs not trace well? What does that suggest about whether and where tracing JITs are relevant today? |
Beta Was this translation helpful? Give feedback.
-
|
I was pretty delayed on this because I fell badly under the weather Monday and got busy with other work after then, so my apologies on the delay. Critique: I thought the paper was interesting if limited. The authors specifically focused on how to efficiently trace loops, and importantly loops that may be nested (which may avoid issues of outer loops failing to be traced because they are less "hot"). They did this by "separating" the CFG and detecting nested loops, letting outer loops "call" inner loops. The insight seems fairly simple, but I'm very impressed by the results. My only critique is it seems that the initial results may be a fraction of possible speedups due to the various limitations on what could be traced, but certainly this is a compliment to the paper and shows its potential. Discussion Questions: One of the limitations mentioned was that TraceMonkey does not compile paths with exceptions, under the assumption that exceptions are rare in JavaScript. Would there be any way to fix this and other limitations? For example, if an exception is always caught, could the try catch block be traced a whole, thus refactoring to avoid the issue? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Reading: Trace Based Just-in-Time Specialization for Dynamic Languages
Discussion Leads: Ann Zhang (@az275), Jeremy Ku-Benjet (@jku20), Sunwoo Kim (@sunwookim028)
Beta Was this translation helpful? Give feedback.
All reactions