News for hackers. Stuff that matters.
Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Wednesday February 10, 2021 @10:35PM (#26097988)
> Threads are lighter weight than processes they're still relatively expensive to switch between and to maintain in memory ... context switching between processes is pretty expensive

This is a really common misconception. Both switching between threads and processes is _extremely_ fast compared to what web applications do.

An exceptionally fast web response is generally <1ms. Linux thread context switching takes ~2 microseconds. Forking a new processes takes ~20 microseconds.

Re:Why Wasn't Ruby 3 Faster? by strken on Wednesday February 10, 2021 @11:07PM (#26098155)
Relatively expensive was probably not phrased well, but a goroutine context switch is ~200 nanoseconds and instantiating a new one takes ~1 microsecond, from memory and a quick google.
Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Thursday February 11, 2021 @01:51AM (#26098946)
Doing nothing 10x as fast is not all that useful. In a real app it's unlikely the difference in context switching being 0.2% of your CPU time or 0.02% of your CPU time matters.

It's also not a fundamental restriction on threads vs Goroutines either. switchto is very nearly as fast a Goroutine context switching https://www.phoronix.com/scan.php?page=news_item&px=Google-U...