Optimize your Node app by upgrading Node.js(blog.sqreen.io)
blog.sqreen.io
Optimize your Node app by upgrading Node.js
https://blog.sqreen.io/optimize-your-node-app-by-simply-upgrading-node-js/
47 comments
I find the (repeated) use of the word polymorphism here a bit confusing...
I'm mostly used to it an class inheritance-related contexts. Is it used differently in the Node/JS-community?
I'm mostly used to it an class inheritance-related contexts. Is it used differently in the Node/JS-community?
This is a different notion of polymorphism, yes.
Suggested reading: http://mrale.ph/blog/2015/01/11/whats-up-with-monomorphism.h...
Suggested reading: http://mrale.ph/blog/2015/01/11/whats-up-with-monomorphism.h...
[deleted]
I was at first excited, then deflated, because I initially read the headline as "Optimize your Node app by deleting Node.js" (snerk).
[deleted]
According to the table, there are an increasing number of constructs that prevent optimization. The oldest versions of node seem to have no constructs that prevent optimization. Can that be right?
> the JavaScript engine will not accept to optimize it
What does this mean? I don't understand if it's good or bad. Sounds bad but seems good according to the table?
What does this mean? I don't understand if it's good or bad. Sounds bad but seems good according to the table?
This misleading part of the article has been updated for more clarity.
The concept of non-optimization is describbed in my previous article: https://community.risingstack.com/how-to-find-node-js-perfor...
tl;dr: you want to avoid patterns that prevent optimization: the ones with a red "no" in the table.
The concept of non-optimization is describbed in my previous article: https://community.risingstack.com/how-to-find-node-js-perfor...
tl;dr: you want to avoid patterns that prevent optimization: the ones with a red "no" in the table.
FYI: Idiomatic Javascript / Builtins should be fast with the recent revamp of the V8 engine (stop writing "CrankScript").
http://benediktmeurer.de/2017/03/01/v8-behind-the-scenes-feb...
https://github.com/v8/v8/wiki/TurboFan
https://www.youtube.com/watch?v=M1FBosB5tjM
http://benediktmeurer.de/2017/03/01/v8-behind-the-scenes-feb...
https://github.com/v8/v8/wiki/TurboFan
https://www.youtube.com/watch?v=M1FBosB5tjM
You are right, some patterns (like try-catch) have been made optimizable thanks to TurboFan.
However:
* until ignition is not available by default on Node.js (now only through the --ignition flag, or using current master), a lot of these optimization tricks will stay up to date. Also, companies have a history of moving slowly to newer versions of Node.js.
* even with ignition (I just tested it), using Generators (including async functions) is an optimization killer.
However:
* until ignition is not available by default on Node.js (now only through the --ignition flag, or using current master), a lot of these optimization tricks will stay up to date. Also, companies have a history of moving slowly to newer versions of Node.js.
* even with ignition (I just tested it), using Generators (including async functions) is an optimization killer.
Chrome's generators are still quite fast compared to Firefox. I've currently got a generator stress test in using generators to implement a lua parser: https://github.com/serprex/luwa/blob/2c1ef6be42b804144340a2e...
Currently trying to rewrite the Exp rule from using combinators to using something that'll properly handle operator precedence (Not keen on having 11 levels of operator precedence encoded in the grammar)
Currently trying to rewrite the Exp rule from using combinators to using something that'll properly handle operator precedence (Not keen on having 11 levels of operator precedence encoded in the grammar)
Unrelated and I'm sorry for that, but do you know of a good way to get rid of the scroll hijacking? I didn't find a lot of extensions for Chrome and the one I tried wasn't working.
It blows my mind to encounter this bad practice on a developper related website.
It blows my mind to encounter this bad practice on a developper related website.
In this case, it can be fixed by running this in the developer tools:
getEventListeners(window).wheel[0].remove()Alas, this isn't possible on iPhone, where most of the table is offscreen and unviewable. So not annoyingly "unreadable", but literally (literally) unreadable.
Hm, this isn't working for me. I've been searching for a way to undo scrolljacking for a while, so I'm curious how to get it to work. What browser are you using?
I tried in Chrome (56.0.2924.87) and Firefox (forgot what version and now it's updating). Firefox doesn't even respond to `getEventListeners` and in Chrome I'm seeing `.scroll` instead of `.wheel`.
I tried in Chrome (56.0.2924.87) and Firefox (forgot what version and now it's updating). Firefox doesn't even respond to `getEventListeners` and in Chrome I'm seeing `.scroll` instead of `.wheel`.
It works for me in Chrome 56 and 57 on Linux. In Firefox, the scroll isn't hijacked (presumably chosen because Firefox has had smooth scrolling longer?), but in Firefox 52 (but not 54) this still improves scroll performance a whole lot:
window.addEventListener('scroll', function(evt) { evt.stopImmediatePropagation(); }, true)Wow yeah. That's noticable to the point that it's almost extension-worthy.
Any idea how much potential that snippet has for causing issues if applied generally across the board?
Any idea how much potential that snippet has for causing issues if applied generally across the board?
I've not tried this plugin, but it might do just what you want.
https://chrome.google.com/webstore/detail/disable-scroll-jac...
https://chrome.google.com/webstore/detail/disable-scroll-jac...
It disables scroll but enables GoogleAnalytics tracking: https://github.com/joshbalfour/disable-scroll-jacking/blob/m...
I loled at this one.
> Object literal containing a getter and object literal containing a setter
Isn't this something Babel does quite often?
Isn't this something Babel does quite often?
A quadratic algorithm optimized by v8 will be still quadratic.
While these optimizations can be helpful, real problem is order of growth. To optimize order of growth problems knowledge of algorithms and data structures is important.
Optimization can be assisted by instrumentation and profiling.
While these optimizations can be helpful, real problem is order of growth. To optimize order of growth problems knowledge of algorithms and data structures is important.
Optimization can be assisted by instrumentation and profiling.
> A quadratic algorithm optimized by v8 will be still quadratic.
That's pretty obvious. An engine's optimization features are there to help execute code faster, not as a substitute for knowledge about algorithms and data structures. The implication here is that being respectful of both solid CS theory and an engine's optimized patterns allows you to benefit from both, not just one or another.
That's pretty obvious. An engine's optimization features are there to help execute code faster, not as a substitute for knowledge about algorithms and data structures. The implication here is that being respectful of both solid CS theory and an engine's optimized patterns allows you to benefit from both, not just one or another.
I had an application with a performance bottleneck once, and people kept telling me that the solution was to upgrade node.
I ignored them, ran a profiler, found a bottleneck and fixed the bottleneck.
Sounds obvious but not everyone is familiar with performance optimization.
I ignored them, ran a profiler, found a bottleneck and fixed the bottleneck.
Sounds obvious but not everyone is familiar with performance optimization.
Out of curiosity did you also check to see if upgrading node would've also been to your benefit? It could just be a side-effect of working at a large company with smart people, but if "people" are telling me the solution is an upgrade I wouldn't be doing my due diligence to ignore them all.
Not trying to invalidate the fact that you found a way to enhance performance via profiling - that's great! But the way you phrased your response seemed very condescending of "people" when there may have been truth to what they said.
Not trying to invalidate the fact that you found a way to enhance performance via profiling - that's great! But the way you phrased your response seemed very condescending of "people" when there may have been truth to what they said.
I agree that this the last thing I would check. An application can work perfectly find with some functions not optimized. In fact, I have find unoptimized functions in node.js itself last week in the streams abstractions.
Regarding performance of node.js applications I often find myself looking at my cpu profiles and memory dumps in node-inspector because the most common problems are eventloop starvation, memory leaks or long GC pauses.
Regarding performance of node.js applications I often find myself looking at my cpu profiles and memory dumps in node-inspector because the most common problems are eventloop starvation, memory leaks or long GC pauses.
[deleted]
I'd really like to find a position doing more Node development. It seems like every place in my area that claims to just uses npm. I've had to learn the MEAN stack on my own, and it feels like it outperforms a lot of the apps I've built in other stacks.
The trick here is just apply for roles that are node based and you will be forced to learn it at a high level very quickly, if even just for interviews. There's nothing quite like just jumping straight into the deep end! (it's warm in here, come on in ;)
Look into remote jobs. Plenty of people that need skilled node developers.
Can you name a few? I'm looking.
Next Monday, I assume HN will post their "Who wants to be hired " thread. Perhaps search for "node" within it.
Hustle Inc: we are looking for nodejs devs, have an entirely modern stack, es6+, react, react native, etc...
If you love JavaScript we want you to work with us. Drop me a line through my profile.
If you love JavaScript we want you to work with us. Drop me a line through my profile.
The only thing I'm not as familiar with is react, I've spent most of my time learning Angular 2 lately. And as I've mentioned, I haven't ran into a lot of people looking for these more modern skills. Is there more companies looking for react than Angular?
Don't have any offhand but I'm constantly seeing friends asking for node devs.
Ok, seems like an interesting article but what the hell is up with those share icons. On your mobile if you rotate the screen to read the interesting table they cover up the first damn column. Then you rotate it back to portrait and they don't move back.
Fix your website. Remove those silly icons!
Fix your website. Remove those silly icons!
But muh growth hacking!
But irritating 90% of your audience with a distracting something that only 1% of them use is the preferred stylish design choice of the modern era.
Whether it's share buttons or an email signup...I mean heck, Europe essentially passed a mandatory website popup law for telling you about cookies.
Whether it's share buttons or an email signup...I mean heck, Europe essentially passed a mandatory website popup law for telling you about cookies.
They ended that law a while ago by the way.
https://www.theregister.co.uk/2017/01/10/brussels_announces_...
https://www.theregister.co.uk/2017/01/10/brussels_announces_...
- Node upgraded v8 to 5.7 [1] & async functions as fast as promises [2]
- Optimizations in fs[3]
[1] https://github.com/nodejs/node/pull/11752
[2] https://v8project.blogspot.ca/2017/02/v8-release-57.html
[3] https://github.com/nodejs/node/pull/12105