13 ms·
A lighter V8
- non-entity 7y agoI wonder if something like this could be used to build an electron alternative (or modify the existing electron backend to use this engine), since memory usage is a major complaint for these applications
- draw_down 7y agoAmazing, very first comment is about getting rid of Electron. I love you guys.
- non-entity 7y agoYou misread my comment. I also suggested replacing the internal engine it uses with this lighter version to make it performant. modifying to be more performant != getting rid of
- deleted 7y ago[deleted]
- liveoneggs 7y ago> However, in the process of this work, we realized that many of the memory optimizations we had made for this Lite mode could be brought over to regular V8 thereby benefiting all users of V8.
- est31 7y agoThis is mentioned in the lead paragraph: > Lite mode of V8 specifically aimed at [...] embedder use-cases that care more about reduced memory usage than throughput execution speed.
- non-entity 7y agoAh, I mistook that as embedded (i.e. usage on microcontrollers / etc.)
- leggomylibro 7y agoJerryScript and Espruino aren't that good yet, but embedded JS is an option. You'd probably just be better off with embedded Python or Lua in most cases (MicroPython / eLua). Sadly, eLua doesn't look very active since 2016-ish
- giancarlostoro 7y agoWell... Electron is powered by Chromium, but uses NodeJS which is based off of V8, V8 is also the default JS engine for Chromium. So in theory, it would benefit Electron directly, not sure why anybody would waste the engineering efforts to recreate Electron if these changes will find their way on Electron. Edit: Didn't mean to make it sound personal on my second paragraph, but the rest of what I wrote still applies with the context of the article and the comment made.
- non-entity 7y agoDear lord people are getting pointlessly defensive and aggressive. Obviously this article is not referencing the full V8 engine, but a light version that may or may not make it into Chromium You might want to re-read the HN guidelines > When disagreeing, please reply to the argument instead of calling names. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3."
- hwillis 7y agoThe article is about how many of the lite mode optimizations were added to the last 7 v8 releases, resulting in an 18% reduction vs lite mode's 22%. The people responding to you are making the case that the 18% reduction is basically as good as.
- Scarbutt 7y agoYou missed these guideline: Please don't comment on whether someone read an article. "Did you even read the article? It mentions that" can be shortened to "The article mentions that." So, the article mentions that.
- apendleton 7y ago> Obviously this article is not referencing the full V8 engine, but a light version that may or may not make it into Chromium Obviously? Right from the second sentence, the article says: > Initially this project was envisioned as a separate Lite mode of V8 specifically aimed at low-memory mobile devices or embedder use-cases that care more about reduced memory usage than throughput execution speed. However, in the process of this work, we realized that many of the memory optimizations we had made for this Lite mode could be brought over to regular V8 thereby benefiting all users of V8.
- realusername 7y agoThe memory issue with Electron is the DOM, not the Javascript. Reducing V8's memory isn't going to help much.
- derefr 7y agoWhat is it about the JS DOM that makes a DOM of N elements modelling a given app’s view, have a higher memory footprint than the “DOM” (view state) of a native graphics toolkit modelling an equivalent app’s view?
- smolder 7y agoPart of it is just how feature complete browser compositing is. The other part is bloat due to how it was all implemented. HTML and CSS were never optimal representation for complex documents, and a ton of features have been added on top.
- arc33 7y agoCan't we compile those things out of the engine when using it for the desktop?
- coldtea 7y ago>What is it about the JS DOM that makes a DOM of N elements modelling a given app’s view, have a higher memory footprint than the “DOM” (view state) of a native graphics toolkit modelling an equivalent app’s view? For starters, because the DOM is a very inefficient design of an app's view, primarily designed for text and simple forms, and with all kinds of extra crap bolted on. Until CSS Grid, there wasn't even a proper layout engine available, and people used styling primitives meant to float text for UI design... A native UI engine can implement drawing a window with a button (the raw widgets, design wise) with a few lines of code to draw, two rectangles, some edge shading, and some text. The DOM has thousands of lines for all kinds of contingencies for the same thing...
- AriaMinaei 7y ago> If you prefer watching a presentation over reading articles, then enjoy the video below! If not, skip the video and read on. This is OT, but I think we can design a format with the best of both worlds. We can have the personal and narrated quality of videos/voiceovers, along with the skimmable/scannable/interactive quality of web content.
- DonHopkins 7y agoI agree, having a transcript of a video is very useful. I've done that with some of my own and other people's videos. It takes a lot less time to skim over an illustrated transcript than to watch a video, and it lets the readers decide if they're interested enough in actually taking the time to watch the video. Plus it's search engine friendly, and lets you add more links and additional material. I loved the body language in this classic Steve Jobs video so much that I was compelled to write a transcript with screen snapshots focusing on and transcribing all of his gestures (in parens). After reading the transcript, it's still interesting to watch the video, after you know what body language to look for! “Focusing is about saying no.” -Steve Jobs, WWDC ‘97 As sad as it was, Steve Jobs was right to “put a bullet in OpenDoc’s head”. Jobs explained (and performed) his side of the story in this fascinating and classic WWDC’97 video: “Focusing is about saying no.” https://medium.com/@donhopkins/focusing-is-about-saying-no-steve-jobs-wwdc-97-ff0174c171d0 https://medium.com/@donhopkins/focusing-is-about-saying-no-s...
- dictum 7y agoIf only HTML could have hyperlinks, embedded multimedia and textual content in a single file... (In all seriousness, it's sad that YouTube has such a narrow focus — video files only — which helped it spread to many different devices, from small phones to TVs, but hinders interactivity)
- sixplusone 7y agoAlso OT, but the audio on that video is extremely quiet, is there a way to boost volume beyond 100%?
- dkarl 7y agoIf I can't watch it while I'm doing the dishes, it doesn't get the best of the video presentation world.
- truth_seeker 7y agoGreat engineering stuff. I am consistently amazed by the work of V8 team. I hope V8 v7.8 makes it to Node v12 before its LTS release in coming October.
- umvi 7y agoIs there any reason there couldn't be a python interpreter as awesome as V8 is for JavaScript?
- gsnedders 7y agoThere's a bunch of things: Python allows metaprogramming in a way that JS does, which means you end up needing more guards (or conflating more guards); the Python ecosystem fairly heavily relies on CPython extension modules, and if you wish to remain compatible with them you're constrained in some ways, especially if you care about performance of calling into/from them.
- matthewaveryusa 7y agoAnd of course money, lots of it. The amount of money invested in optimizing v8 is staggering -- Google brought Lars Bak out of retirement[1] to start v8, and that guy is no joke. [1] https://www.ft.com/content/03775904-177c-11de-8c9d-0000779fd2ac https://www.ft.com/content/03775904-177c-11de-8c9d-0000779fd...
- forgot-my-pw 7y agoPaywalled article
- derefr 7y agoWould there be a performance penalty (I’m guessing in cache coherency) in having an interpreter that’s really two interpreters in the same process, where modules that use the “strict subset” of the language (the part that doesn’t require the more advanced object-model, or any FFI preemption safety) run their code through a more minimal interpreter, and then whenever your code jumps into a module that requires those things, the interpreter itself jumps into a more-complete “fallback” interpreter? Sort of doing what profile-guided JIT optimization does, but without the need for JITing (and before JITing would even kick in), just instead using a little bit of static analysis during the interpreter’s source-parsing step. I ask because I know that this is something hardware “interpreters” (CISC CPU microcode decoders) do, by detecting whether the stream of CISC opcodes in the decode pipeline entirely consist of some particular uarch, and then shunting decode to an optimized decode circuit for that uarch that doesn’t need to consider cases the uarch can’t encode. But, of course, unlike hardware, software interpreters have to try to fit in a CPU’s cache lines and stay branch-predicted, so there might not be a similar win. (Tangent: I once considered writing a compiler that takes Ruby code, rewrites the modules using only a “strict subset” of it to another language, and then either has that language’s runtime host a Ruby interpreter for the fallback, or has the Ruby runtime call the optimized modules through its FFI. I never got far enough into this to determine the performance implications; the plan was actually to enable better concurrency by transpiling Rails web-apps into Phoenix ones, switching out the stack entirely at the framework level and keeping only the “app” code, so single-request performance wasn’t actually the top-level goal.)
- abc_lisper 7y agoThis is great, but because you have achieved memory reduction by trading off speed, it would be nice to see charts that show processing time increases too.
- truth_seeker 7y ago> Lite mode launched in V8 version 7.3 and provides a 22% reduction in typical web page heap size compared to V8 version 7.1 by disabling code optimization, not allocating feedback vectors and performed aging of seldom executed bytecode (described below). This is a nice result for those applications that explicitly want to trade off performance for better memory usage. However in the process of doing this work we realized that we could achieve most of the memory savings of Lite mode with none of the performance impact by making V8 lazier. Copied from article
- magicalist 7y agoProbably should be re-titled to match the post as people are getting confused by the reference to V8 lite, which this post isn't directly about. > However, in the process of this work, we realized that many of the memory optimizations we had made for this Lite mode could be brought over to regular V8 thereby benefiting all users of V8. > ...we could achieve most of the memory savings of Lite mode with none of the performance impact by making V8 lazier.
- dang 7y agoYes, the submitted title ("V8 lite (22% memory savings)") broke the site guideline which asks: "Please use the original title, unless it is misleading or linkbait; don't editorialize." Doing this tends to skew discussions enormously, so please follow the guidelines!
- syspec 7y agoThe most recent version of chrome has made having a breakpoint a painful affair. * The browser becomes completely unresponsive, each time you hit a breakpoint for 3-5 seconds. * It also takes chrome much longer to show you the source maps for a page * If you refresh while on a breakpoint it will remain unresponsive for nearly 10 seconds. Is this related to these new changes? Is there a way to revert the trade off?
- JMTQp8lwXL 7y ago> * If you refresh while on a breakpoint it will remain unresponsive for nearly 10 seconds. Glad to hear I'm not alone in experiencing this. For a period, I thought I had written bad code that caused Chrome to stumble. Guess it's just Chrome.
- natorion 7y agoCan you please file a bug report on crbug.com?
- mehrdadn 7y agoHow are Chrome devs themselves not experiencing this? I've experienced it too...
- JMTQp8lwXL 7y agoIt seems like such a common action, I'm surprised a non-Chromium developer would have to report it. I considered reporting it, but too much friction. I need to use a Google Account to report a bug? Why? Eh.
- djmips 7y agoIt's easy to conceptualize a configuration or use case that's common to the people reporting a bug that's not being used by the developers or in their QA process. It's not uncommon.
- lacampbell 7y ago
- pier25 7y agoSomewhat off topic but this Lite version made me think of something. Is there any engine/browser mode/something that lets go of legacy JS/CSS/HTML and increases performance/weight/memory consumption? A browser/JS engine with removed legacy support would in principle be much faster, no?
- jitl 7y agoWhat is “legacy” JS? with()/eval()? What is “legacy” CSS? Box model? What is “legacy” HTML? <br>?
- jannes 7y agoWhat do you consider legacy JS/CSS/HTML? Do you mean HTML features like contentEditable? Do you mean JS eval()?
- The_rationalist 7y agoDocument.write()
- Steltek 7y agoDon't you get the same effective perf benefit by marking your script async defer?
- pier25 7y agoFrom the top of my head: CSS floats, contentEditable, execCommand.
- angrygoat 7y agoHow are you going to define legacy? I'm not sure how you could whittle down the web platform in an agreed way.
- dictum 7y agoHTML has something of a legacy mode, https://en.m.wikipedia.org/wiki/Quirks_mode https://en.m.wikipedia.org/wiki/Quirks_mode Roughly anything before HTML5/4.01 and XHTML renders in quirks mode. AFAIK there are no legacy CSS properties. Only nonstandard (i.e. prefixed or experimental and never published in finished specs) properties have been deprecated. Browsers already have some leeway with DOM APIs. https://developers.google.com/web/updates/2017/01/scrolling-intervention https://developers.google.com/web/updates/2017/01/scrolling-...
- pizlonator 7y agoThis is some cool shit! I don’t know how V8 and JSC compare on memory but I’m happy for this to become a battleground. Nothing but goodness for users if that happens. (Worth noting that JSC has had a “mini mode” for a while, but it’s focused on API clients. And I don’t know if it’s as aggressive as what V8 did.)
- bzbarsky 7y agoI can't speak to JSC, but at least SpiderMonkey has had memory optimizations that are equivalent to the ones described here (e.g. discarding cold-function bytecode) for a while... I agree that it would be interesting to have more competition, including more measurement, in this space.
- pizlonator 7y agoI would love a memory usage benchmark battle. :-) JS is way faster than it was before the JS perf wars. Let's do it again. Then lets fight over power!
- chungus_khan 7y agoThis exact thing is why browser engine diversity is so important, and why even though I never used Edge, it's very disappointing to me that MS is killing it.
- rasz 7y agoOld Carakan (Opera Presto) would win hands down. That browser was using ~1GB with 500 heavy active tabs loaded.
- Andrzejko29 7y agoGood!
- ksec 7y agoI think Firefox went through something similar many many years ago, a Project called MemShrink started after many user were complaining how Firefox were getting slower and bloated with Firefox 3 - 4* if I remember correctly. It was Memory optimisation in every part of Firefox and mostly in SpiderMonkey.
- The_rationalist 7y agoHow does compare current spidermonkey heap usage vs V8?
- clumsysmurf 7y agoI think Firefox needs another MemShrink initiative. After Electrolysis / e10 - at least in my experience - the browser uses more memory over time than Chrome.
- aitchnyu 7y agoI tolerate (apparently) a 6G memory leak with 50+ tabs and Tree Style Tabs. It was much faster when Mozilla accidentally remotely disabled extensions for a weekend.
- iggldiggl 7y agoAnd the "Fission" project (i.e. running each browsing origin in its own process) won't help in that regard. To be fair, they are working intensively on reducing the overhead of having loads of separate content processes, but the target goal I have heard about is still "only" < 10 MB overhead per content process, which still translates into 1 GB (!) of additional RAM usage for the benchmark browsing session with 100 separate origins (which is perhaps slightly more than the average user uses, but for power users it might not be that unlikely to hit - and it's not just tabs that need to be counted, but every iframe that loads some third-party content and therefore needs to run in a separate process, too).
- nammi 7y agoSomewhat off-topic, but is there an RSS feed available for the V8 blog? Their posts are always interesting to me, but I've searched a few times with no luck.
- toupeira 7y agoHere you go: https://v8.dev/blog.atom https://v8.dev/blog.atom (found through the <link> tag on the blog)
- andrewhodel 7y agoSomeone needs to add some heavy complexity to ACID4 so there's a solid baseline for tests. They should have ACID sub-tests for images, videos, etc so these statistics would actually provide something long term and important.
- z3t4 7y agoWhy not allow the runtime to call the garbage collector (GC)? The GC is very lazy by default, it should be possible to make it collect all garbage. Currently v8 will just let the garbage grow because the GC is so lazy.
- Sawamara 7y agoIt is rather interesting to me to see that V8 has been packing so many micro-optimizations and special techniques over the years that now it has become actually feasible to just start cutting back on the optimizations to have performance gains. What all this enables is, beside having more sensible defaults, is the ability for developers who use V8 with Electron or NW.js to tweak the default behavior of the engine, catering to their application's needs. That is always good.
- cwp 7y agoThat's not what I took away from this at all. They specifically say that Lite mode started out as a way to reduce memory consumption at the cost of performance. Execution time jumped 120%! Then they figured out how to get the memory improvements without the performance hit. The only place where they actually removed optimizations was in generating stack traces, and that wasn't a gain in performance, it was just considered acceptable for that to get slower.
- deleted 7y ago[deleted]
- Nitramp 7y agoOne of the interesting aspects of benchmarks is that they are usually designed and intended to run in isolation. E.g. if you benchmark a database system, you expect that to be the sole system running on your server machine, in control of all resources. That's not true of software running on desktop systems or mobile phones - desktops usually run many concurrent tasks, so do phones to some degree, and then there's also the question of battery use. That can create skewed incentives if the benchmark isn't carefully designed. E.g. you can usually make space/time tradeoffs regarding performance, so if your benchmark is solely measuring CPU time, it pays off to gobble up all possible RAM for even minor benefits. If your benchmark is only measuring wallclock time, it pays off to gobble up all the CPUs, even if the actual speedup from that is minor. This can lead to software "winning" the benchmark with improvements that are actually detrimental to the performance on end user's systems.
- robocat 7y agoAside: Chromium includes regression tests for battery usage. I saw a fix get reverted because the code change caused a 5% step increase in battery usage. They have some very good testing infrastructure.
- crispyporkbites 7y agoHow do they test this?
- judge2020 7y agothis commit[0] might be what's referenced, and this[1] looks to be the test that Google runs (not sure if this is ran in CI, or only done anecdotally for when performance tests[2] show issues). 0: https://github.com/chromium/chromium/commit/208f274e4bcb51748bba83071aa70011ceafa385 https://github.com/chromium/chromium/commit/208f274e4bcb5174... 1: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/refs/heads/master/client/site_tests/power_LoadTest/README.md https://chromium.googlesource.com/chromiumos/third_party/aut... 2: https://chromeperf.appspot.com/ https://chromeperf.appspot.com/
- claytongulick 7y agoWhen I saw the title of this article, I got really excited because I thought they were referring to a lighter "build". IMHO, one of the biggest problems facing v8 right now is the build process. You need to download something like 30 gigs of artifacts, and building on windows is difficult - to say the least. It's bad enough that the trusted postgres extension plv8 is considering changing it's name to pljs and switching engines to something like QuickJS. [0] One of the driving factors is that building and distributing v8 as a shared lib as part of a distro is incredibly difficult, and increasing numbers of distros are dropping it. This has downstream effects for anyone (like plv8) that are linking to it.[1] Also, embedding it is super complex. Referenced in the above conversation is a discussion that NodeJS had to create their own build process for v8. At this point, it's easier to user the NodeJS build process and use the Node v8 API than it is to use v8 directly. At the beginning of the article, they are talking about building a "v8 light" for embedded application purposes, which was pretty exciting to me, then they diverged and focused on memory optimization that's useful for all v8. This is great work, no doubt, but as the most popular and well tested JavaScript engine, I'd love to see a focus on ease of building and embedding. 0: https://github.com/plv8/plv8/issues/364 https://github.com/plv8/plv8/issues/364 1: https://github.com/plv8/plv8/issues/308#issuecomment-434740000 https://github.com/plv8/plv8/issues/308#issuecomment-4347400...
- vvanders 7y agoMeanwhile integrating Lua is as simple as just dropping in a few c files...
- perl4ever 7y agoI hoped this would be about this: https://grassrootsmotorsports.com/forum/grm/lightweight-v8-engines/153797/page1/ https://grassrootsmotorsports.com/forum/grm/lightweight-v8-e...
- userbinator 7y agoThis is a little off-topic, but I find the terminology used in software these days to be a little perplexing. Is "small", a perfectly adequate word to describe less memory usage, not buzzwordy/trendy enough? "light" or "heavy" just reminds me of that classic story about the weight of software.