logoalt Hacker News

econyesterday at 7:12 PM2 repliesview on HN

I can't think of a better way to make simple things billions of times slower than they should be.


Replies

Dylan16807today at 5:55 AM

> I can't think of a better way to make simple things billions of times slower than they should be.

How's it going to do that? What's so bad about it? Especially in the multi-core era which lets multiple programs run at the same time the way that multiple pages can run javascript at the same time. The lack of preemption is only within a single page/program.

During periods of time where no single chunk of code runs for more than a millisecond, cooperative multitasking should have the exact same performance as preemptive multitasking. And even when single chunks of code do run for that long, if that code wasn't properly isolated then preemption doesn't save you from lag.

So the difference only shows up when you have chunks of code that keep running way too long, that are also inside of properly isolated threads/callbacks, and on web those threads/callbacks are not inside web workers. Is that a common situation?

odo1242yesterday at 8:32 PM

I'm just going to borrow a sibling comment:

> afiori: JavaScript's execution model uses cooperative concurrency to avoid a tons of data races, preemptive non-parallel concurrency would make all web development incredibly harder