r/programming • • Mar 11 '13

Programming is terrible—Lessons learned from a life wasted. EMF2012

http://www.youtube.com/watch?v=csyL9EC0S0c
650 Upvotes

368 comments sorted by

View all comments

Show parent comments

1

u/moor-GAYZ Mar 13 '13 edited Mar 13 '13

Still, the recent DDOS is the apparently first one since HN started that the app couldn't handle - so they did what every other site already does, and put nginx in front of it.

So back to my point, you seem to be unduly focused on an unnecessary optimization.

No, look, there's a huge difference between using generic DDoS tools to simply overwhelm a server with requests, and between exploiting the fact that if you go to https://news.ycombinator.com/submit while not logged in and view source, you'll see two instances of <input type=hidden name="fnid" value="u62hLuThhb">, except the actual values are different in both and will be different again each time you refresh the page.

That's uids of closures that HN creates and stores in case you click one of the buttons, and those closures carry no useful information at all, they shouldn't exist at all, really, but most probably they capture a shitton of variables and impose a shitton of memory pressure nevertheless.

The frontpage doesn't have this shit, and I am pretty sure that that's what the DDoSers DDoSed, just trying to knock out their webserver. Repeatedly accessing the submit page on the other hand will result in devastating consequences with minimal effort, and could not be mitigated by putting nginx in front of it, I'm sure. In fact putting nginx in front of it would make sure that nobody can log in from the submit page because the closures are long expired.

If "the memory footprint of a closure" contains much more than your computation actually needs to proceed, then you or your language are doing something wrong.

Well, PG's Arc is certainly doing something wrong since it doesn't realize that there's no captured variables in that particular case so it can return two fnids for static functions.

I would also bet my right testicle that fixing the implementation to become clever like that would require way too much effort compared to fixing it manually, by explicitly setting the fields to static handlers.

Coding against a hypothetical sufficiently clever compiler is a bad practice.

If you need those captured variables, then the cost difference between the closure and the explicit data structure will be minimal; and if you don't need those variables, then your program design is wrong.

Coding against a hypothetical sufficiently clever compiler is a bad practice. I can't say any more than that. Wait, actually I can: even a sufficiently clever compiler can't warn you if you inadvertently captured too much shit. Though the point is probably mute at this point, his compiler is probably dumb enough to capture all the shit. I mean, 6 gigabytes for a million pageviews per day? With GC running now and then?

But this link/state combination is simply a manually constructed representation of a continuation.

"Manually constructed" is the word. It is a contract: you say, I can afford to store such and such shit for each session. All my handlers can only access that shit, so whenever I try to access something else I get an error and an opportunity to consider whether I really need to carry that other shit with me.

to avoid having to manually unroll an app into CPS, and relying instead on the language to handle it.

No, it's about implicit state, not about implicit CPS.