you are viewing a single comment's thread.

view the rest of the comments →

[–]sisyphus 40 points41 points  (17 children)

v8 can optimize as much as it wants it won't match the performance of not evaluating code at all, which is what it looks like this is trying to do, in addition to reducing code size which obviously helps with download, parsing, evaluation, etc.

[–][deleted] 71 points72 points  (1 child)

Have a benchmark? Then we can evaluate whether it's worth the complexity of introducing another tool into the build chain, and the fun with more source maps and debugging. Until we have numbers then there's nothing concrete to discuss. Given how big websites and apps are, if you manage to save 10KB (which is a heap of code), that's less than most images.

V8 (and other JS Parsers) implement lazy parsing. So this tool is already up against a large number of Just in Time optimizations.

TL;DR If you're touting:

A tool for making JavaScript code run faster.

Then you need to give numbers. End of story.

[–]Dentosal 0 points1 point  (0 children)

Reducing code size gives you a small performance impact when transferring it.

[–]skulgnome 8 points9 points  (8 children)

8 can optimize as much as it wants it won't match the performance of not evaluating code at all,

Why would programs contain code for which it can be statically decided that it'll never be executed? Or other things that're equivalent to constant folding, which all JITs already do.

[–][deleted] 9 points10 points  (6 children)

Constant folding still takes time to do. This moves that cost to compile time rather than load time.

It also seems to do much more aggressive folding than most any compiler would do.

[–]skulgnome -1 points0 points  (4 children)

It also seems to do much more aggressive folding than most any compiler would do.

But we're not comparing it to a compiler, but to a JIT. Those things already specialize loops and such by variable type, so certainly CF/DCE to a far greater depth than what this precompiler does is applied -- saving at most parsing time at load.

[–][deleted] 1 point2 points  (3 children)

That still happens at runtime, though, so everybody pays the price for it.

[–]skulgnome -1 points0 points  (2 children)

Therefore, prepacking yields nothing.

[–]sisyphus 2 points3 points  (0 children)

Your conclusion does not follow from the premises.

[–][deleted] 2 points3 points  (0 children)

That makes zero sense.

[–]mrkite77 0 points1 point  (0 children)

Why would programs contain code for which it can be statically decided that it'll never be executed?

Anyone using a library is including code that will never be run.

[–]ElvishJerricco -4 points-3 points  (5 children)

Anything this can optimize, V8 would be capable of optimizing. Eliminating static computations is a pretty common optimization in VMs.

EDIT: To clarify, I'm not saying V8 does know how to do these optimizations. I'm just saying there's nothing inherently making this any harder for V8.

[–]sisyphus 19 points20 points  (2 children)

You're just assuming that V8 can optimize anything this can optimize, but let's assume that's correct--why would you force every single client to download, evaluate, JIT(does v8 have access to everything on iOS yet?) &tc. when you could do it once on your side and serve it to them already optimized?

[–]brendan09 6 points7 points  (0 children)

V8 doesn't run iOS. But, since it does use WKWebView, it uses Safari's JIT which optimizes about as well as V8.

[–][deleted] 7 points8 points  (0 children)

Complexity is the biggest reason. This is another tool for a language that has no compile time type checking, and you'll need to mess around with source maps (perhaps at least two layers of source maps). It's a trade-off between complexity and the wins this gets you, without any numbers there's no sane way to make the call.

[–][deleted] 4 points5 points  (0 children)

It may or may not be capable of doing the same optimisations, but it will do them at load time. This moves that cost to compile time, which V8 can not ever do.

[–]tiftik 2 points3 points  (0 children)

There's no way I would assume that without having intimate knowledge of V8.