Tuesday, October 4, 2011

Node.js has jumped the shark

I've been trying to understand this whole Node.js thing that's been going on for the past few days. It's taught me a lot about how the Node.js community tries to reason about problems, and perhaps what's the real problem with Node.

It began with a relatively short rant by Ryan Dahl. Ryan talk's about how he's mad at complex software, which is at least an arguable position. I liked his rant, but Ted Dziuba did not.

Ted Dziuba wrote a brilliant troll post which lambasted Ryan and the concept of Node.js in general. I'm a huge fan of Ted's previous trolling, especially his parody TechCrunch site uncov, which trolled TechCrunch before TechCrunch became a parody of itself. Except in the case of uncov, it would be a few years before TechCrunch became a parody itself. With Node.js, the reaction was almost instantaneous.

Ted's argument centered around the problem of doing non-trivial computation within the event loop of a system like Node, and how that would affect the performance of the system. To illustrate this point, he gave an intentionally deoptimized Fibonacci function, along with the boldface caveat "Yes, I know there's a closed form solution. Shouldn't you be in front of a mirror somewhere, figuring out how to introduce yourself to her?"

Reading through the lines of Ted's trolling, his point is "I'm not specifically talking about Fibonacci. I'm talking about non-trivial computation as a general problem in Node." He specifically chose a slow algorithm to illustrate his point. However, what was the Node community's reaction?

One reaction was to go out and implement Ted's intentionally-retarded Fibonacci algorithm in a bunch of different languages and benchmark how fast the VM could optimize away a crappy algorithm. Based on several benchmarks, V8 actually does a comparatively good way of optimizing away the retarded algorithm compared to a lot of other languages. Cool story bro!

In the Reddit comments for this story I first truly gazed into the abyss of Node.js insanity. Node provides a way to schedule an anonymous function to run the next time it's event loop iterates using a function called nextTick. EventMachine (ugh) users may be familiar with this same pattern with EM.next_tick (which needs to die for most use cases, but that's the subject of another blog post)

Redditor "headzoo" suggests that we provide a "non-blocking solution" by unrolling the Fibonacci loop and execute one iteration of the Node.js event loop, calculating one iteration for each I/O multiplexing system call Node is making. When Ted Dziuba asked "Have you taken epoll into your heart?," I think he had no idea of the depths Node people actually have.

I don't really get what's going on in Node people's heads here. I think they seriously believe that throwing computation into the middle of an event loop is a good idea, because Node's event loop is FAST!!#$#! funroll-loops + nextTick = LUDICROUS SPEED!!

This crap is absolutely insane. For each iteration of the loop, Node is making an expensive system call. It's also defeating all of the mechanisms that V8's impressive JIT would use to optimize this problem, as substantiated by the previously mentioned Nodian's roflbenchmark. Clearly this is a very bad idea. But wait, it gets worse!

It wouldn't take long before another Node.js fan put together a Github project for this technique, which also added an "optimization": memoization! In addition to unrolling each iteration of the Fibonacci function to run within the event loop, it now caches the nth result. Now let's throw ApacheBench at it and see how fast Node can serve the precomputed result where n = 100.

Holy balls, it does 5390.22 requests per second serving a memoized value when I ask ApacheBench to request the same memoized value over and over!!#$! TAKE THAT TED DZIUBA! Is it any good? One word: yes. Did we miss the point that this isn't about Fibonacci? One word: yes. (Side note: I second raganwald in adding "Is it any good? Yes." to the top of all my READMEs)

Memoizing each member of the Fibonacci sequence makes this algorithm O(n) in memory. For shits and grins I installed Node-fib and asked it for the 1 millionth Fibonacci number. Node ground away (on a single core of my quad core i7 MacBook) for about a minute before running out of memory, crashing the entire VM.

Okay, so mistakenly implementing an algorithm this pathologically bad when you're trying to prove a point to someone who's just trolling you is pretty bad, right? But it gets worse. 

After pointing this out, a member of the Node.js community (post now deleted) suggested I might have an obsolete version of Node with a 1GB heap limit (because Node uses a VM targeted at client-side JavaScript where 1GB heaps are an uncommon use case, but hey, let's throw it on the server!) and that I recompile without the 1GB restriction so that this retarded algorithm can continue eating up all my system RAM. He says this as if this is a good idea instead of, I dunno, using a better algorithm.

Clearly the next logical steps are to store previously computed Fibonacci numbers in MongoDB. Or you could build a system with Socket.IO which caches previously computed Fibonacci numbers client-side using a distributed hash table. Then you'd be well on your way to a multimillion dollar cloud-based Fibonacci number service. Eventually you'll probably want to build in an OpenMP C++ native extension to calculate Fibonacci numbers across multiple CPU cores. That way you'll have a truly roflscale Fibonacci web service.

476 comments:

«Oldest   ‹Older   401 – 476 of 476
Neeraj Kumar said...

There is obviously a lot to know about this. I think you made some good points in Features also. Great job!
Data Science Course in Jalandhar

Training said...

I like viewing this web page which comprehend the price of delivering the excellent useful resource free of charge and truly adored reading your posting. Thank you!
Data Science Certification Course

Courses said...

I like to view your web site which is very useful and excellent resource and truly adored reading your posting. Thank you!
Data Science Course in Gurgaon

Unknown said...

menjadi yang terbaik pasti 200m

Anonymous said...

Hi, Thanks for sharing nice articles...

SEO Services

Training said...

Nice post. This is a great article and am pretty much pleased with your good work. Very helpful information. Thank you.
Best Data Science Courses

Training said...

I am hoping the same best effort from you in the future as well and in fact your creative writing skills has inspired me.
Data Science Course near me

kumal kumar said...


I read your excellent blog post. It's a great job. I enjoyed reading your post for the first time, thank you.
Data Science Institutes in Bangalore

Sunil said...

There is obviously a lot to know about this. I think you made some good points in Features also. Great job!
Mlops Course

Technical Knowledge said...

I really enjoyed reading this post and keep up the good work and let me know when you can post more articles or where I can find out more on the topic.
Data Science Online Course

Anand said...

Great post, Thanks for sharing a this post filled with a lot of information. keep up the good work
Business Analytics Course in Ahmedabad

Bhuvankumar said...

Really impressed! Information shared was very helpful Your website is very valuable. Thanks for sharing.
Business Analytics Course in Bangalore

Ganesh said...

Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Thanks for sharing
Data Science Training in Indore

Professional Course said...

Really impressed! Everything is a very open and very clear clarification of the issues. It contains true facts. Your website is very valuable. Thanks for sharing.

Best Data Analytics Courses in Bangalore

kumal kumar said...

Wonderful blog post. It's absolute magic on your part! Hope you continue like this!
Data Analytics Training in Bangalore

Gurudev said...

So luck to come across your excellent blog, glad i found it. Keep posting new articles. Good luck.
Data Science Course Details

data science bangalore said...

Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one. Keep posting. An obligation of appreciation is all together for sharing.data analytics course in rohtak

Anand said...

Very interesting to read the article. I would like to thank you for sharing this awesome article.
Data Analytics Course in Indore

Unknown said...

I was just examining through the web looking for certain information and ran over your blog.It shows how well you understand this subject. Bookmarked this page, will return for extra. data science training in kanpur

Sunil said...

Nice post, you give readers a lot to think about and I appreciate that kind of writing.
Mlops Course

Gurudev said...

I think this is a really good article. You make this information interesting and engaging. Thanks for sharing.
Data Science Course in India

data science said...

Great to become visiting your weblog once more, it has been a very long time for me. Pleasantly this article i've been sat tight for such a long time. I will require this post to add up to my task in the school, and it has identical subject along with your review. Much appreciated, great offer.

Anand said...

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. Keep up the good work. Waiting for your next article
Business Analytics Course in Jabalpur

sateesh said...

nice article seo services hyderabad

jane smith said...

McAfee programming gives the digital security services to ensure your hardware information.Install mcafee from mcafee.com/activate |
Keep yourself secure with McAfee security .
McAfee activate on your computer.
How to Uninstall or disable McAfee WebAdvisor ?
What is McAfee Safe Connect VPN ?
How to login to McAfee account ?
How to know when does my McAfee Subscription Expire ?

jane smith said...

Hiya very cool web site!! Man ...Superb .. I’ll bookmark your site and take the feeds additionally?
McAfee is quick and easy to install.
www.mcafee.com/activate
McAfee cloud security
disable McAfee notification

jane smith said...

Million Global Leads Pvt. Ltd. matches clients looking for immediately accelerated traffic
MGLS

PMP Training in Malaysia said...

360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

Ganesh said...

Hi, This article is probably where I got the most useful information for my research. Do you know of any other websites on this topic?
Data Analytics Course in Jalandhar

Nathan said...

Thank you for sharing this wonderful blog, I read that Post and got it fine and informative. Please share more like that...
Business Analytics Course in Amritsar

Data Science said...

Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
Continue posting. A debt of gratitude is in order for sharing.
data science course in kolhapur

Deekshitha said...

Informative blog
business analytics course in ludhiana

Nathan said...

Very educating blog, got lot of information thank you.
Data Scientist Course in Amritsar

Ganesh said...

Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Thanks for sharing.
Data Science Training in Indore

ANAK DEWA said...

Slot Online
Judi Slot
Bartenderslot
Judi Pulsa
Slot Online Terpercaya
Puja88

Anisha said...

bollywood news a Great article.Well said, your every point is true. Thanks for sharing its an informative post

Anisha said...

food chemical suppliers a Great article.Well said, your every point is true. Thanks for sharing its an informative post

kumar said...

Through this post, I realize that your great information in playing with all the pieces was exceptionally useful. I advise this is the primary spot where I discover issues I've been scanning for. You have a smart yet alluring method of composing.https://360digitmg.com/course/certification-program-on-digital-marketing

Ganesh said...

I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it, Keep posting new articles.
Data Analytics Course in Ahmedabad

Professional Course said...

Good blog and absolutely exceptional. You can do a lot better, but I still say it's perfect. Keep doing your best.

Data Analytics Course in Nagpur

Gurudev said...

Very good message. I stumbled across your blog and wanted to say that I really enjoyed reading your articles. Anyway, I will subscribe to your feed and hope you post again soon.
Data Scientist Course in India

Professional Course said...

I read your excellent post. It's a great job. I enjoyed reading your post for the first time. I want to thank you for this publication. Thank you...

Data Science Course in Patna

data science bangalore said...

I visited various websites but the audio feature for audio songs current at this site is really wonderful.|business analytics course in jodhpur

Anisha said...

cruise packages from india to maldives a Great article.Well said, your every point is true. Thanks for sharing its an informative post

Unknown said...

I am truly getting a charge out of perusing your elegantly composed articles. It would seem that you burn through a ton of energy and time on your blog. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome.data science course in ghaziabad

marc monserrat said...

Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such info a lot. I was seeking this particular information for a very long time. Thank you and good luck. My web vinilos decorativos

Unknown said...

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck data science course in surat

Unknown said...

This post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things. data science training in mysore

Professional Course said...

Great advice and very easy to understand. It will definitely come in handy when I get the chance to start my blog.

Data Scientist Course in Durgapur

Unknown said...

I can set up my new idea from this post. It gives in depth information. Thanks for this valuable information for all,.. data science training in kanpur

oncasinosite said...

Looking forward to reading more. Great article post. Fantastic. Thanks so much for the blog. Much obliged. Feel free to visit my website; 바카라사이트

bacarasite said...

You’ve written nice post, I am gonna bookmark this page, thanks for info. I actually appreciate your own position and I will be sure to come back here. Feel free to visit my website; 바카라사이트닷컴

Professional Course said...

Really, this article is truly one of the best in article history. I am a collector of old "items" and sometimes read new items if I find them interesting. And this one that I found quite fascinating and should be part of my collection. Very good work!

Data Scientist Training in Bangalore

Rahul said...

I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it, Keep posting new articles.
Data Scientist Course in Jalandhar

Buy Instagram Followers India said...

Thank you so much for giving such good information. Earlier I did not know about these things, through you I got a chance to know this.
Buy Instagram Followers India

Data Science said...

Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
Continue posting. A debt of gratitude is in order for sharing.
data analytics course in warangal

Unknown said...

I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
data science course in london

PMP Training in Malaysia said...

This post is very simple to read and appreciate without leaving any details out. Great work! PMP Training in Malaysia

Gurudev said...

Nice post, you give readers a lot to think about and I appreciate that kind of writing.
Data Science Course in India

360digiTMG.com said...

wow... what a great blog, this writter who wrote this article it's realy a great blogger, this article so inspiring me to be a better person data science course in mysore

SAFETOTOSITEPRO18 said...

This post is absolutely brilliant! Thank you so much for sharing. 온라인카지노

SAFETOTOSITEPRO18 said...

Great article. Couldn’t be write much better! Keep it up! 바카라사이트

SAFETOTOSITEPRO18 said...

Thanks for the great article that provided this useful information. 바둑이게임

SAFETOTOSITEPRO18 said...

Either way keep up the excellent quality writing. 카지노사이트

Anjali geetha said...

Over the years, career opportunities in the field of Data Science have surfaced as one of the most dynamic and lucrative options in technology. To pursue a career in the most in-demand field that involves analyzing data with the help of various techniques like data mining and data modeling. Join the Data Science course in Bangalore and enjoy the best facilities and premier quality curriculum that will make you an expert in deriving meaningful insights that help in value-oriented decision-making for businesses across various domains.Data Analytics Course in Trichy

Digital Signage said...

Industrial IOT Solution | Industry 4.0 in Manufacturing | OEM | Renata Pollution Monitoring - Air Quality Monitoring - Air Pollution Monitor - Renata

Jiya Khan said...

If You Want Friendship and Dating Click Here Udaipur Girlfriend Meeting Udaipur Blog Udaipur Girls

Anjali geetha said...

It has been used in detecting diseases, and in this way, physicians can make crucial decisions about it.data science course in chandigarh

Graphic Design said...

it's really help for me. Thank you
Kalender Konten

khelopcgames.com said...



boson x free download
nancy drew secret of shadow ranch pc game
knights of the chalice free download
runaway a road adventure pc game
no one lives forever 1 2 free download
teleglitch die more edition pc game
teleglitch die more edition free download
american mcgees alice pc game
snowball free download

Top 5 web series you can watch with your family said...

Great article and fortunate to read and really like it lot.

MP Yatra!

Digital Signage said...

Best digital signage company More often than not, working environment correspondence is a blend of a few methodologies; it can go from composing guidelines to eye-to-eye associations to looking over your work area to speak with colleagues. Be that as it may, contact with colleagues is not generally restricted to your office spaces and is currently led internationally.

BORIVALI said...

Unleash your potential and expand your capabilities with the Data Science Certification Course.
data analytics course in borivali

Horizon Academy said...
This comment has been removed by the author.
Horizon Academy said...

Hi,


Thanks for posting this post and sharing your knowledge through blog. This blog is very helpful or informative.

Udaipur Girl said...

Meet Indian top quality high profile house wife in udaipur best model available in our we gave high-class girls trust me and book your choice.
Goa Girls Mobile Number
Agra Girls Mobile Number
Lucknow girls mobile number
high profile girls

«Oldest ‹Older   401 – 476 of 476   Newer› Newest»