News for hackers. Stuff that matters.
Re:Java Virtual Threads: A Case Study by hitekker on Wednesday July 17, 2024 @01:48PM (#40988438)
This take sounds reasonable to me. But I'm not an expert, and I'd be curious to hear an opposing view if there's one.
Re:Java Virtual Threads: A Case Study by binary132 on Wednesday July 17, 2024 @03:04PM (#40989220)
Greenlets ultimately have to be scheduled onto system threads at the end of the day unless you have a lightweight thread model of some sort supported by the OS, so it’s a little bit misleading depending on how far down the stack you want to think about optimizing for greenlets. You could potentially have a poor implementation of task scheduling for some legacy compatibility reason, however. I guess I’d be curious about the specifics of what pron is discussing.
Re:Java Virtual Threads: A Case Study by troupo on Wednesday July 17, 2024 @04:30PM (#40990045)
Even though yes, in the end you have to map onto system threads, there are still quite a fee things you can do. But this is infeasible for Java, unfortunately.

For example, in Erlang the entire VM is built around green threads with a huge amount of guarantees and mechanisms: https://news.ycombinator.com/item?id=40989995

When your entire system is optimized for green threads, the question of "it still needs to map onto OS threads" loses its significance

Re:Java Virtual Threads: A Case Study by binary132 on Wednesday July 17, 2024 @07:22PM (#40991225)
I really don’t think it’s useful to be this nonspecific. You could give an example of what a Java greenlet cannot do or how it cannot be optimized, for example. If your whole point is actually just “I prefer the semantics of BEAM threads”, then just say that.
Re:Java Virtual Threads: A Case Study by troupo on Thursday July 18, 2024 @02:00AM (#40992875)
Those semantics are exactly what cannot be done in Java for many reasons (including legacy code etc.).

And yes, those semantics are important, but sadly most people stop at "yay we have green threads now" and then a null pointer exception kills their entire app, or the thread that handles requests, or...

Re:Java Virtual Threads: A Case Study by binary132 on Saturday July 20, 2024 @12:25PM (#41017620)
So let’s be clear, your point is that you find the API of non-BEAM greenlets less useful, not that they’re somehow necessarily less efficient. Right?
Re:Java Virtual Threads: A Case Study by MaxBarraclough on Saturday July 20, 2024 @06:07AM (#41015371)
> When your entire system is optimized for green threads, the question of "it still needs to map onto OS threads" loses its significance

How's that? What about parallelism?

Re:Java Virtual Threads: A Case Study by kaba0 on Wednesday July 17, 2024 @01:50PM (#40988463)
He is as much of an expert as it gets, as he is the leader of the Loom project.
Re:Java Virtual Threads: A Case Study by michaelt on Wednesday July 17, 2024 @06:09PM (#40990818)
Standard/OS threads in Java use about a megabyte of memory per thread, so running 256 threads uses about 256 MB of memory before you've even started allocating things on the heap.

Virtual threads are therefore useful if you're writing something like a proxy server, where you want to allow lots of concurrent connections, and you want to use the familiar thread-per-connection programming model.

Re:Java Virtual Threads: A Case Study by layer8 on Wednesday July 17, 2024 @07:46PM (#40991347)
Only address space of 1 MB is reserved (which can still be a problem), actual memory usage is limited to the memory pages that are actually accessed by the program within that address space.