Fork me on GitHub
Ben Sless19:04:51

sigh, implemented micro kanren again

😅 1
😂 5
Cora (she/her)19:04:58

constant fatigue is so demoralizing 😭


Yes. Yes it is. I'm sorry you're struggling with it.

💜 1

Thanks for posting this — any chance you can share more specifics on what you were experimenting with, how you did it, level of effort, etc? Sounds fun!


I‘m currently compiling some blog posts about this topic (and probably a video collab) and tinkered with virtual threads in http-kit and core.async today, I hope to publish some of this stuff in the upcoming week


Before that Tweet I patched virtual threads into a Java process engine / workflow engine which spawns threads to execute tasks, and had a lot of tasks with longer, blocking I/O. The effort was rather low, changed the threadfactories from creating new Threads to “Thread.ofVirtual()…” and avoided the Threadpool.


I don't know about biggest high-impact for the JVM. With Kotlin Coroutines you can also do it, plus it's much easier to cancel them.


There are similar concepts in some languages already, but I was focussing the JVM as the platform, not JVM languages. And I am not that familiar with Kotlin, but I was under the impression that you should avoid blocking calls in coroutines?


Yes, agree that “increased throughput by x” would have been the better wording

gotta_go_fast 1

Thanks for instigating the ... thread ..., @javahippie :D Today is learning day! I've only known virtual thready things from a distance.

🧑‍🎓 1

AFAIK you should also avoid blocking calls in virtual threads.


That’s actually the main feature about them. Virtual Threads get mounted onto Platform Threads to perform work. If inside a thread a blocking syscall is made, it triggers the virtual thread to yield it’s assigned platform thread, making room for other virtual threads to mount. After the blocking call is finished, the virtual thread is assigned to a platform thread again and continues to work. One of the goals is to enable developers to use the “thread per task” programming model instead of async strategies with the same performance and less complexity.

Martynas Maciulevičius06:04:09

Does this mean that thread pools are/will be deprecated?


Threads and Threadpools will exist in the same way, as they are the underlying technology and still are useful. We will just get virtual threads on top

Martynas Maciulevičius06:04:45

This guy said that we shouldn't use threadpools and instead should resort to semaphores when using virtual threads:


I agree with Nicolai, but still the old API won’t be deprecated 😉 (This is an excellent video, btw).

Ben Sless14:04:58

Anyone remember the post which benchmarked loom?


btw if you want to try virtual threads yourself, I have created a short how-to for setting up your workspace with the JDK Preview Builds:

gratitude 2

It also works for Clojure projects, e.g. with Cursive


I tried out a deps.edn project with the latest JDK preview build 19-loom+5-429, and I did not seem to need to pass the --enable-preview JVM option to get virtual threads to work. Not sure why that’s the case.