Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
GameCube
Nov 21, 2006

but mongo is web scale

Adbot
ADBOT LOVES YOU

Max Facetime
Apr 18, 2009

OOGA-BOOGA MONGO WEB SCALE

shrughes
Oct 11, 2008

(call/cc call/cc)

MononcQc posted:

Which I guess is kind of okay, but annoying. poo poo can be locked up, I need to manually split everything in callbacks that will register themselves in order to know when things are done (something like resource.ready(callback)), I need to keep track of everything manually (is this parse for request 1, 2 or 73?).

Jesus loving christ that's not hard to do at all. You don't keep some table of requests and ask which request the parse is for, this poo poo is called closures.

MononcQc posted:

blah blah blah threads

Yeah and you pay the cost for context switching and overhead of threads or processes, which is why people still do event-based code to this day.

MononcQc posted:

Then at some point, I may gain parallelism on top of it Awesome, poo poo will go great, except maybe my writes, which will need to block to be sane. What I'll be able to do with my concurrent code (not callback-based) is:

Why would your writes block to be sane? Get better at writing. Learn 2 code.

MononcQc posted:

code:
accept -> parse -> dispatch -> read -> read more -> write -> push.
accept -> parse -> dispatch -> read -> read more ->        write -> push.

More like

code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                            wriiiiiiiiiiiiiiiiiiiiiiite -> push.
Note that the single-threaded event-based version looks like this:

code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
                a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->             wriiiiiiiiiiiiiiiiiiiiiiite -> push.

MononcQc posted:

My code that was concurrent is now parallel by default, and I limit how much blocking I need to do (assuming the write is written to block correctly, either via transactions, safe queues, mutexes, locks or whatever). However, if I go back to my callback-based code and get parallel, what I get is still this:

code:
(accept 1) -> (accept 2) -> ... (write 1) -> (write 2) -> (push 1) -> (push 2)

Put event loops on multiple threads, problem solved.

MononcQc posted:


And I want to get the speedup of my friends in the parallel and concurrent worlds. So I know what I'll do! I'll add non-blocking IO and will send poo poo to concurrent drivers in charge of doing poo poo right!

code:
(accept 1) -> ... ->          ->              -> (write 1) -> (write 2) ->
                     (read 1)    (read more 1)                             (push 1)
                     (read 2)    (read more 2)                             (push 2)
See? I got the parallelism going! I only did so at the cost of a shittier way to read and write code, still as sensitive to failures or blocks from independent requests, and relying heavily on the implementation of individual drivers not to gently caress my poo poo up! It's still worse on every level, but hey, I get to keep using my callback-based code (not that it's impossible to do in concurrent/parallel systems anyway). Hooray.

What are you talking about? In all event-based code the reads are going to happen in parallel. You don't schedule a read and then block anybody else from reading while you do your thing. Non-blocking IO is the thing one does with async code, LOL if you're using callbacks with blocking I/O.

MononcQc posted:

While the modern world of programming on servers has moved to concurrent and parallel methods a long while ago (mostly because they are objectively better), Javascript users with node.js came crashing through the door and said "we have a great new model! it's callbacks with non-blocking IO! it's loving great!".

Because that's how Javascript loving works. That's how it works in the browser, that's what Javascript engines support. Have you tried to take javascript engines and run more than one inside a process? Have you tried making them run on top of green threads? Guess what: the fancypants C++ programmers didn't make them compatible with all such notions.

MononcQc posted:

Everyone who is not node.js knows what they propose is worse than what exists. It's like someone inventing PHP again, but for server-side platforms.

Blah blah blah Ryan Dahl is an idiot. We know that. We don't need you to be an idiot too.

shrughes fucked around with this message at 12:08 on Oct 13, 2012

0xB16B00B5
Aug 24, 2006

by Y Kant Ozma Post
well on one hand, i respect MononcQc's opinions, and on the other hand, youre breaking anime rules

this is a tough decision

0xB16B00B5
Aug 24, 2006

by Y Kant Ozma Post
also youre defending node unironically

shrughes
Oct 11, 2008

(call/cc call/cc)
In addition to the fact that single-threaded async callback systems can be fairly straightforwardly migrated to run on multiple threads:

Async callback based systems can be fairly straightforwardly migrated to green thread systems that sit on top. It takes about 3 manweeks to set up your own green thread library, and then code can be migrated incrementally later. So it's not some design decision you're Stuck With.

Async callback based systems never made sense for stuff doing lots of Disk I/O, except maybe for very expensive super-awesome SSD devices. For stuff doing lots of network I/O, with the state of a lot of connections to take care of, that's where they make sense. Guess what Node.JS is designed for.

Which is better: nginx or Apache?

If you want to run a Javascript webserver using v8 you simply can't have multiple threads. You can't have green threads. v8 does not work that way. Javascript code that can run both in-browser and in-process needs to be callback-based in both situations.

If they did use a JS engine that could run on multiple OS threads, that would make things a lot more error prone for the users of Node.JS if they went that path. Just imagine that scenario, what a clusterfuck that would be for retarded javascript programmers who never had to deal with the concept of multi-threading.

So Node.JS made the right choices when it comes to doing javascript on the web server.

You can complain about drivers and filesystems being broken when doing async I/O to disk, but so what? The point of async I/O is not to super-parallelly talk to disk, you can't do enough concurrent I/O requests on most disks for anybody to care if you just spawn a pool of worker threads for that purpose.

Zombywuf
Mar 29, 2008

shrughes posted:

Which is better: nginx or Apache?

Apache.

jony neuemonic
Nov 13, 2009

shrughes posted:

So Node.JS made the right choices when it comes to doing javascript on the web server.

node exists so no, they didn't.

FamDav
Mar 29, 2008

shrughes posted:

If you want to run a Javascript webserver using v8 you simply can't have multiple threads. You can't have green threads. v8 does not work that way. Javascript code that can run both in-browser and in-process needs to be callback-based in both situations.

I'm p sure v8 now supports threading. Why you'd want to build something substantial based upon that fact I do not know.

FamDav fucked around with this message at 15:14 on Oct 13, 2012

Zombywuf
Mar 29, 2008

If I had any time left over from being angry about unicode, date times and memory usage I would be angry about floating point http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf

GameCube
Nov 21, 2006

shrughes posted:

Jesus loving christ that's not hard to do at all. You don't keep some table of requests and ask which request the parse is for, this poo poo is called closures.


Yeah and you pay the cost for context switching and overhead of threads or processes, which is why people still do event-based code to this day.


Why would your writes block to be sane? Get better at writing. Learn 2 code.


More like

code:

a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                            wriiiiiiiiiiiiiiiiiiiiiiite -> push.

Note that the single-threaded event-based version looks like this:

code:

a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
                a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->             wriiiiiiiiiiiiiiiiiiiiiiite -> push.


Put event loops on multiple threads, problem solved.


What are you talking about? In all event-based code the reads are going to happen in parallel. You don't schedule a read and then block anybody else from reading while you do your thing. Non-blocking IO is the thing one does with async code, LOL if you're using callbacks with blocking I/O.


Because that's how Javascript loving works. That's how it works in the browser, that's what Javascript engines support. Have you tried to take javascript engines and run more than one inside a process? Have you tried making them run on top of green threads? Guess what: the fancypants C++ programmers didn't make them compatible with all such notions.


Blah blah blah Ryan Dahl is an idiot. We know that. We don't need you to be an idiot too.
tldr: node.js is rockstar hacker tech

tef
May 30, 2004

-> some l-system crap ->
it's nice to see threads vs events rather than tabs vs spaces

gangnam reference
Dec 26, 2010

shut up idiot shut up idiot shut up idiot shut up idiot
ban 4 anime n aspergers

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

tef posted:

it's nice to see threads vs events rather than tabs vs spaces

a mix of both

MononcQc
May 29, 2007

shrughes posted:

Jesus loving christ that's not hard to do at all. You don't keep some table of requests and ask which request the parse is for, this poo poo is called closures.
Forgive the hyperbole, but following the flow of code still requires to manually break your code into closures and follow that around. That's what I wanted to represent. Of course you don't number poo poo by hand, but when you have more than one event available, you need to be very careful.

Say for example, that I need to parse two files to proceed with further analysis. If I want to do the file reads in parallel, I can with both approaches. However, I'll need to be able to pass a callback to both operations, and that callback will need to have some explicit synchronization semantics to deal with the two following possibilities:

code:
file1 ----------------------> callback()
file2 -------------> callback()
code:
file1 -----------> callback()
file2 ---------------------------> callback()
the callback has to be aware of how both (or more) file parsers are going, and you end up needing to track poo poo by hand to some degree, with flag variables that tell you when stuff is done and a final callback for when all file handling is done.

Compare this, for example, with futures or promises, which will give you an implicit serialization point. Then you can just say "parse N files and when they're done do X" as a much, much cleaner sequence of code, with less room for error:

code:
x = parse1
y = parse2
fetch x, y
do_something() 
This kind of synchronization point is what is missing in lots of callback-only concurrency models, especially node.js.

shrughes posted:

Yeah and you pay the cost for context switching and overhead of threads or processes, which is why people still do event-based code to this day.

If you want to drag the argument into 'poorer semantics yield better performance, so we gotta have poorer semantics', then sure, I guess. Use the LOL SPEED argument. I can't disagree with that in this case, although this is highly implementation-dependent.

shrughes posted:

Why would your writes block to be sane? Get better at writing. Learn 2 code.
Writes may need to block / lock whatever if they write to the same resource and the result is required to proceed further after the fact.

I wasn't clear there, but what I meant is that in this imaginary case, writing to the same record/entry/whatever will force your writes to never be parallel (they'll block each other).

shrughes posted:

More like

code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                            wriiiiiiiiiiiiiiiiiiiiiiite -> push.
Note that the single-threaded event-based version looks like this:

code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
                a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->             wriiiiiiiiiiiiiiiiiiiiiiite -> push.

In that particular case, possibly so. That's assuming you get the right circumstances, i.e. the writes won't be blocked by reads... otherwise you'll still get:


code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                 wriiiiiiiiiiiiiiiiiiite -> push.
                a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                            wriiiiiiiiiiiiiiiiiiiiiiite -> push.
Depending on your read/write blocks and semantics, what data you try to touch, it may have an impact in how your callback-based code runs compared to say, something more parallel:

code:
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more -> wriiiiiiiiiiiiiiiiiiite -> push.
a -> p -> d -> reeeeeeeeeeeeeeeeead -> reeeeeeeeeeeeeead more ->                            wriiiiiiiiiiiiiiiiiiiiiiite -> push.
which would still run the same here. I guess we can strawman this poo poo forever.


shrughes posted:

Put event loops on multiple threads, problem solved.
"Fix event loops' poor concurrent and parallel semantics by nesting them in something with better semantics." I can agree with that. Here I'm arguing against event loops being the sole option.

shrughes posted:

What are you talking about? In all event-based code the reads are going to happen in parallel. You don't schedule a read and then block anybody else from reading while you do your thing. Non-blocking IO is the thing one does with async code, LOL if you're using callbacks with blocking I/O.
That depends on if you need one read to be done for the other to proceed. Say I'm fetching tef's username to find his avatar's URI, because I need to fetch his avatar's data from a different server to find whatever he's hidden in there. The nature of these calls is purely sequential and you will never make them parallel, even if they're both reads. Related to Amdahl's law, yadda yadda.

shrughes posted:

Because that's how Javascript loving works. That's how it works in the browser, that's what Javascript engines support. Have you tried to take javascript engines and run more than one inside a process? Have you tried making them run on top of green threads? Guess what: the fancypants C++ programmers didn't make them compatible with all such notions.


Blah blah blah Ryan Dahl is an idiot. We know that. We don't need you to be an idiot too.

Yeah, that would help my point that Javascript on the server is the wrong tool for the job, and that using it is a poo poo idea.

MononcQc fucked around with this message at 17:09 on Oct 13, 2012

MononcQc
May 29, 2007

shrughes posted:

In addition to the fact that single-threaded async callback systems can be fairly straightforwardly migrated to run on multiple threads:

Async callback based systems can be fairly straightforwardly migrated to green thread systems that sit on top. It takes about 3 manweeks to set up your own green thread library, and then code can be migrated incrementally later. So it's not some design decision you're Stuck With.

Async callback based systems never made sense for stuff doing lots of Disk I/O, except maybe for very expensive super-awesome SSD devices. For stuff doing lots of network I/O, with the state of a lot of connections to take care of, that's where they make sense. Guess what Node.JS is designed for.
Well sure, I guess I can use a bad tool and then fix it by applying better semantics to it, or maybe just use something right from the beginning (not node.js)

shrughes posted:

Which is better: nginx or Apache?
Depends on what you serve.

shrughes posted:

If you want to run a Javascript webserver using v8 you simply can't have multiple threads. You can't have green threads. v8 does not work that way. Javascript code that can run both in-browser and in-process needs to be callback-based in both situations..

If they did use a JS engine that could run on multiple OS threads, that would make things a lot more error prone for the users of Node.JS if they went that path. Just imagine that scenario, what a clusterfuck that would be for retarded javascript programmers who never had to deal with the concept of multi-threading.

So Node.JS made the right choices when it comes to doing javascript on the web server.
My whole point is you should not use Javascript on the server because of that. No matter how hard you try to wiggle around it, you're forcing tools into a job they're inadequate for because you want to use the same code on two platforms not sharing similar concerns. Please refer to my knife-to-a-modern-war comment.

Shaggar
Apr 26, 2006
use java, problem solved.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Shaggar posted:

use java, problem solved.

https://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf

Shaggar
Apr 26, 2006
math people will always complain about a language doing correct things for users instead of dumb poo poo for autists.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Werthog posted:

but mongo is web scale

mongo is dead

http://www.nytimes.com/2012/10/11/sports/football/alex-karras-nfl-lineman-and-actor-dies-at-77.html

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Shaggar posted:

math people will always complain about a language doing correct things for users instead of dumb poo poo for autists.

ah yes, having accurate floating point is bad for users, unsigned integers are for autists

Homocow
Apr 24, 2007

Extremely bad poster!
DO NOT QUOTE!


Pillbug
a real programmer uses floating point datatypes without knowing how they work

every time I do something with floats I use floor/ceil to prevent rounding errors :unsmigghh:

Max Facetime
Apr 18, 2009

Otto Skorzeny posted:

ah yes, having accurate floating point is bad for users, unsigned integers are for autists

the autists got their strictfp keyword in December 1998, 7 months after that rant

meanwhile everyone else just uses floats for money calculations to get the highest possible performance

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Win8 Hetro Experie posted:

the autists got their strictfp keyword in December 1998, 7 months after that rant

meanwhile everyone else just uses floats for money calculations to get the highest possible performance

my favorite antipattern

shrughes
Oct 11, 2008

(call/cc call/cc)

MononcQc posted:

:words: obviosities about how event-based programming is annaying, claims that you can't have concurrency primitives in event-based programming and general ignorance in general :words:

Yeah, that would help my point that Javascript on the server is the wrong tool for the job, and that using it is a poo poo idea.

I'm still waiting for a recommendation of a better language for programming that wants to share code on the client side and server side. If you're writing a web based chess server, do you want to rewrite the rules of chess in both Scala and Javascript? You might notice the numerous efforts to solve or avoid that sort of problem. There's GWT, even NaCl is a way to solve it.

TiMBuS
Sep 25, 2007

LOL WUT?

man dunno why you are having problems with events
perl + AnyEvent + Coro is almost a joy to work with..

must just be your programming language

MononcQc
May 29, 2007

shrughes posted:

I'm still waiting for a recommendation of a better language for programming that wants to share code on the client side and server side. If you're writing a web based chess server, do you want to rewrite the rules of chess in both Scala and Javascript? You might notice the numerous efforts to solve or avoid that sort of problem. There's GWT, even NaCl is a way to solve it.

I'm not saying event-based code isn't concurrent, I'm saying it's a crappy type of concurrency compared to other, often more modern options. Compare it to comparing Java's type system to Haskell's or SML's if you want. Both are type systems, but one is objectively weaker than the other. Sure you can have event-based code coupled with other stuff, but it doesn't change its attributes on its own as not being a good option compared to other stuff available server-side.

Regarding sharing code between the front and back end, I can't give a good alternative across the board. First because the front-end model of JS is not the best model for the back-end, second because the question is loaded because Js is pretty much your only frontend option.

If you really want to, I guess you could look for languages that can compile to javascript, like ruby, python, java bytecode, lisps, Haskell, smalltalk, or go with Haxe or Opa. See altjs.org for different options that won't necessarily involve node.js. They may not be better, but I'm not convinced you need complete code duplication on the front-end and the back-end either.

To put it another way, I welcome the idea of JavaScript as the main server language the way I enjoy Java applets in my browser.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

shrughes posted:

I'm still waiting for a recommendation of a better language for programming that wants to share code on the client side and server side. If you're writing a web based chess server, do you want to rewrite the rules of chess in both Scala and Javascript?

Java :smugdroid:

MononcQc
May 29, 2007

Man I sure love a system where the entire server and application crashes if one of the handlers raises an uncaught exception or where the other option is to register some generic handler that will let requests time out instead and leave the whole stack in an undefined state! Let me use dat node.js!

shrughes
Oct 11, 2008

(call/cc call/cc)
What Ryan Dahl should have done is hacked v8 to run properly on green threads. As far as I'm concerned he can kiss my rear end. I made a commit to Node.JS and it get accepted (because they didn't know how to HTTP properly) and then maybe a month later they were all "lol I want you to give your copyright to me". So I do so and then they say I need to give my address. No, gently caress him.

MononCqC posted:

raises an uncaught exception

Yeah, all sorts of lols can happen if you throw exceptions in event-based code. (Or at anything made by javascript programmers in general.)

There are plenty of real problems with Node.JS, the whole thing being a pile of javascript code being one of them. Being in the space of event-based callback systems is not one of them.

MononcQc
May 29, 2007

Event-based code on its own is not terrible and there are times when it's a decent tool. A platform offering only that for concurrency is lagging behind though; most languages with an event framework or component will at least allow other concurrency primitives, which in many scenarios will be more appropriate.

Even better, these won't claim that event loops are revolutionary, and will have a saner overall architecture than node.js.

MononcQc fucked around with this message at 06:07 on Oct 14, 2012

shrughes
Oct 11, 2008

(call/cc call/cc)
It's not really a good idea to offer two ways of doing concurrency like that. Then you get libraries that want to do event-based stuff, and then you get libraries that want to do green-thread based stuff, and then you get libraries that want to do OS thread based stuff, and these don't interact well at all. (Green-thread and event-based can interact pretty well, but JS programmers aren't familiar with the issues of combining such systems.)

salted hash browns
Mar 26, 2007
ykrop
green thread green thread green thread

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
csp is the light

gangnam reference
Dec 26, 2010

shut up idiot shut up idiot shut up idiot shut up idiot

salted hash browns posted:

green thread green thread green thread

Zombywuf
Mar 29, 2008

Gazpacho posted:

csp is the light

Oh how I wish for a language that had read more than 2 chapters of CSP.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

shrughes posted:

(Green-thread and event-based can interact pretty well, but JS programmers aren't familiar with the issues of combining such systems.)
that's because js programmers are retarded if they want js on the server

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum
Lets not give the users something they don't understand, then they won't have to understand it!

X-BUM-RAIDER-X
May 7, 2008

ZYNGA STOCK CRASHER posted:

ban 4 anime n aspergers

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

Let's not give user's anything. gently caress users. If they can't write it themselves they don't deserve it.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply