12 ms·
Ignition: V8 Interpreter
- hittaruki 11y agohttps://twitter.com/andywingo/status/630705153922838528 https://twitter.com/andywingo/status/630705153922838528
- pwg 11y agoSee this: http://i.stanford.edu/pub/cstr/reports/cs/tr/94/1520/CS-TR-94-1520.pdf http://i.stanford.edu/pub/cstr/reports/cs/tr/94/1520/CS-TR-9... (ADAPTIVE OPTIMIZATION FOR SELF: RECONCILING HIGH PERFORMANCE WITH EXPLORATORY PROGRAMING) Esp. section 5.3+ starting on physical pdf page 56.
- acqq 11y agoFor others who consider if it's worth clicking: the paper is by https://en.wikipedia.org/wiki/Urs_H%C3%B6lzle https://en.wikipedia.org/wiki/Urs_H%C3%B6lzle and it's written in 1994.
- gsg 11y agoInteresting decision. The architecture sounds a little unusual: "The interpreter itself consists of a set of bytecode handler code snippets, each of which handles a specific bytecode and dispatches to the handler for the next bytecode. These bytecode handlers are written in a high level, machine architecture agnostic form of assembly code, as implemented by the RawMachineAssembler class and compiled by Turbofan" It also seems as if all calls are mediated by code generated by the compiler, which has the advantage of avoiding the awkwardness of different calling conventions between native and bytecode functions (possibly at some cost to performance?). Fascinating reading. Thanks V8 people for allowing such documents to be public!
- barrkel 11y agoThe architecture is a threaded interpreter, a fairly old and not particularly unusual interpretation technique. https://en.wikipedia.org/wiki/Threaded_code https://en.wikipedia.org/wiki/Threaded_code When written in C, is typically done using GCC's computed goto and the && label address-of operator extension. Writing the handlers in machine-agnostic assembly is interesting; I'm guessing they want to tune the output more than writing the handlers in C would let them, or they can't rely on something like GCC's computed gotos.
- yoklov 11y agoThere's a post by Mike Pall, author of LuaJIT, which explains why writing C is very suboptimal for maximally performant VMs: http://article.gmane.org/gmane.comp.lang.lua.general/75426 http://article.gmane.org/gmane.comp.lang.lua.general/75426 Worth noting that IIRC, for a while LuaJIT in interpreted mode was able to beat V8 in optimized mode not all that infrequently (although it depended on the use case, they are different languages, and I do not know if this is still the case).
- mraleph 11y ago> Worth noting that IIRC, for a while LuaJIT in interpreted mode was able to beat V8 in optimized mode not all that infrequently V8 had no optimizing compiler when Mike Pall sent his (in)famous mail about "LuaJIT interpreter beating V8 compiler"[1]. Also usual disclaimers about cross-language benchmarks apply (e.g. nobody looked how those benchmarks differ between JS and Lua implementation). [1] http://lua-users.org/lists/lua-l/2010-03/msg00305.html http://lua-users.org/lists/lua-l/2010-03/msg00305.html
- barrkel 11y agoCommon register allocation across different bytecode interpretation sequences was one of the things specifically on my mind that could be tuned using a high-level assembler. Very suboptimal might be a slight overstatement. I can see a way, given known register calling conventions, that you could write an interpreter written as tail calls and post-process the machine code to effectively JMP instead of CALL. Guaranteed tail calls would save you a bunch of effort, and register calling convention would give you some guarantees about consistent allocation.
- s_kilk 11y agoCan anyone summarize what this move will mean for performance on the average web app? Will they be giving up some speed to claw back some memory?
- Klathmon 11y agoThe TL;DR: is that non-hot code will run slower (it looks like about 1.5 to 2 times slower) with the benefit of reducing the code-space to about 25% of it's current size. (saving any memory usage that would have been used by that) "Hot" or optimizable code will still be optimized and run just as fast.
- rakoo 11y agoWhat portion of a "standard" web site (say, Google search) is hot vs non-hot ?
- Klathmon 11y agoThe specifics of this are a bit outside my knowledge area, so take this with a few major grains of salt. But basically V8 has tools built in that will decide when the cost of compiling is worth the possible benefit. So the AJAX submission javascript will probably never hit the optimizing compiler, but your function inside 3 nested loops will probably be hit ASAP.
- s_kilk 11y agoThanks :)
- cbsmith 11y agoKind of hilarious that we're worried about code size in browsers these days.
- Klathmon 11y agoIt's not disk size that we care about, it's memory size. Reducing the space that the "parsed" code takes up in memory will reduce the amount of memory used by the engine.
- deleted 11y ago[deleted]
- coldtea 11y agoAside: I hate this "Oh this file is really popular BS" on docs.google.com. Doesn't inspire much confidence for their Cloud offerings...
- lucian1900 11y agoIt just means collaborative editing is turned off, as it logically can't scale to very large numbers.
- simonw 11y agoYou can still read the document, which gives me a lot more confidence than if the file just became unavailable.
- themckman 11y agoI like the way Google projects seem to use Google Docs for this sort of thing. I've noticed in the past docs come up for projects like Angular and Go. I'd like to hear more about some of these documentation policies if anyone knows anything.
- tuckerman 11y agoI no longer work at Google, things could have changed, but there was a strong culture to use Google Docs for project requirements gathering and design documents. There were some internal templates you could copy if you didn't want to think of the headers yourself. While it's great this is part of the culture, discoverability/versioning were still problems, i.e. had to be done yourself.
- munificent 11y agoThere's no official "policy" that I know of. It's just that most Googlers tend to prefer Docs. It works anywhere you have a browser, is easy to share on the web, has nice collaboration features, and built-in comments.
- felixangell 11y agoThe link to optimizing an ANSI C interpreter is broken, it's missing a colon after the protocol. I dunno if there's anyone here that can fix that, just thought I'd say it anyway. Actually it's not the colon, there are two protocols: http://http://dl.acm.org/citation.cfm?id=199526 ^^^^^^^ My bad.
- ndesaulniers 11y agoSo V8 will be moving from a two tier to a three tier architecture. Spidermonkey is three tier and JSC is four.
- yoklov 11y agoAre they adding an extra tier, or replacing the lowest? I thought they were replacing the lowest.
- ahomescu1 11y agoAFAIK, V8 already has 3 tiers: full-codegen (the basic non-optimizing JIT), crankshaft and turbofan. With ignition, they're replacing full-codegen with an interpreter. It's strange that there's only one mention of crankshaft in the entire document, but turbofan is all over the place. Are they also planning to get rid of the former?
- rancur 11y agoby my deeds I will honor him, V8
- rancur 11y agosource for the uninitiated: https://www.youtube.com/watch?v=egSwfPKOX1c https://www.youtube.com/watch?v=egSwfPKOX1c
- twotwotwo 11y agoThis might be about RAM-constrained phones; the design doc refers to '--optimize-for-size devices', suggesting it won't (initially?) be on for everyone. Android and Chrome OS already enable Linux zram to get more out of low-memory gadgets. Incidentally, Google announced a (to me very ambitious-sounding) push for $50 Android phones today (http://www.engadget.com/2015/08/10/google-revamps-android-one-india/ http://www.engadget.com/2015/08/10/google-revamps-android-on...) that better low-RAM support could mesh nicely with, though of course it's just a coincidence the dates lined up.
- pietaalpha 11y agoWould it be useful a <hot-code> tag for the purpose of indicating that optimizations are required for the code? in Lisp we have compiler options (declare (optimize ...))
- ilyaigpetrov 11y agoDoes this make implementation of other language compiled for V8 easier?