Earlier quoted context omitted.
> Now they hopefully can work around the kernel for file descriptors (network and disk) saving 30% CPU globally on all Java servers. How does this work around the kernel? This lets you write java code that uses async IO but make it look nice, like golang code. But this isn't DPDK.
The JDK would have access to network card and SSD directly. Bypassing the kernel. Java is already sandboxed we don't need the kernel unless the net/ssd drivers crash completely. It's a huge task/risk, but 30% is alot.
Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
461–470 of 555 posts
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#462Earlier quoted context omitted.
Citation needed; first off, verbosity is not the problem, verbosity is NEVER the problem; any significant codebase will end up with millions of LOC (and tokens) regardless of language choice. Second, Java's infamous for having VeryLongClassNameFactoryBeans on the one hand, and deep class hierarchies on the other, with new classes being declared for everything. Third, it depends. You can set up a HTTP server in two or…
"Second, Java's infamous for having VeryLongClassNameFactoryBeans on the one hand, and deep class hierarchies on the other, with new classes being declared for everything." I have always wondered why Java is hammered for this while Apple is celebrated for this. CMMetadataFormatDescriptionCreateWithMetadataFormatDescriptionAndMetadataSpecifications(allocator:sourceDescription:metadataSpecifications:formatDescriptionOu…
Indeed.
And it's good to remember that there is nothing in the Java language forcing one to name things verbosely, that's on the developer's personal choice. Just like on every other language.
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#463Earlier quoted context omitted.
1. Platform threads place a heavier burden on the GC. It's true that virtual threads are allocated on the heap, but platform threads are GC roots , which is worse. The GC easily deals with a gazillion heap objects; it's rather unhappy with lots of roots. The number of heap objects that virtual threads occupy is roughly the same as the number of heap objects that async code allocates anyway. 2. The Jetty experiment me…
Regarding #1, would not the stacks of the lightweight threads have to root have to root any object on it? Otherwise the GC would free objects out from under the virtual thread, right? I could imagine that by having fewer physical threads running, the stop-the-world part of garbage collection could suspend the runtime more quickly. That could reduce the effect of GC-pauses.
> I could imagine that by having fewer physical threads running, the stop-the-world part of garbage collection could suspend the runtime more quickly. That could reduce the effect of GC-pauses.
Precisely. Although it's worth mentioning that while that's true for G1, ZGC does not stop-the-world when scanning roots, including platform thread stacks (https://openjdk.org/jeps/376).
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#464Earlier quoted context omitted.
Regarding #1, would not the stacks of the lightweight threads have to root have to root any object on it? Otherwise the GC would free objects out from under the virtual thread, right? I could imagine that by having fewer physical threads running, the stop-the-world part of garbage collection could suspend the runtime more quickly. That could reduce the effect of GC-pauses.
Virtual thread stacks reference the objects that local variables on the stack reference, but they are not themselves GC roots. GC roots are special objects that the GC starts its scan of the heap from, and they tend to be particularly costly, at least for most of OpenJDK's GCs. Virtual threads are just ordinary heap objects that can reference other objects. > I could imagine that by having fewer physical threads runn…
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#465Earlier quoted context omitted.
I wrote Java code for 20+ years and I can tell you exactly why I prefer Go: it produces native binaries. I mean, it’s also less verbose, easier to start a new project, faster to startup, has far fewer configuration knobs, has native dependency management, is far easier to build CI/CD for, compiles more quickly, has very few NPEs gotchas, has value types, and avoids idiomatic boilerplate. Go is far from perfect, but i…
> I mean, it’s also less verbose Are we talking about the same language? Or maybe you consider writing "if err != nil" every few seconds as good exercise for your fingers... I think we shouldn't point fingers at Java when it comes to Go's verbosity. I can simply do dict.contains("foo") in Java vs having to go through a verbose hoop: if val, ok := dict["foo"]; ok { //do something here } Common operations like filterin…
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#466Earlier quoted context omitted.
Virtual thread stacks reference the objects that local variables on the stack reference, but they are not themselves GC roots. GC roots are special objects that the GC starts its scan of the heap from, and they tend to be particularly costly, at least for most of OpenJDK's GCs. Virtual threads are just ordinary heap objects that can reference other objects. > I could imagine that by having fewer physical threads runn…
What is so costly about GC roots? Considering the stack is used in a LIFO manner, most stack pages never change.
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#467Earlier quoted context omitted.
Being not super familiar with Go, I think C#'s async/await is similar, isn't it? If you want more complex operations, you might want to look into System.IO.Pipelines.
Nah, totally different than channels. And Goroutines are proper managed threads with their own stacks. As an aside pipelines are terriblely unergonomic. The public APIs are not fully developed and something simple, like IDK creating an actual processing pipeline, is funky as all hell. Creating a pipe wrapper feels dirty. The buffer management is cool though and sequence seems like it should have just been made a firs…
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#468Earlier quoted context omitted.
Does Java even have a MAUI equivalent? There are other open source frameworks for GUI apps. This feels like goal post shifting.
The point is cross-platformness and windows does have MAUI, so not having it on linux means it is not a first-class target.
Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#469Re: Virtual Threads Arrive in JDK 21, Ushering a New Era of Concurrency
#470Earlier quoted context omitted.
In what way? async-std and tokio both support M:N.
But they can’t turn blocking calls to non-blocking which is the whole point, that requires runtime support.
(As a note, cooperative scheduling also requires a runtime - Rust might not "have a runtime" by default but you need to opt into one to use async.)