Are Virtual Threads Going to Make Reactive Programming Irrelevant?

  Рет қаралды 21,247

Java

Java

Күн бұрын

Пікірлер: 67
@VuLinhAssassin
@VuLinhAssassin 29 күн бұрын
It is an honor to watch Jose Paumard presenting...
@panjacek6674
@panjacek6674 29 күн бұрын
Virtual threads have been a game changer for our services. Thank you, JDK engineers (and Spring engineers for adopting them in the framework).
@cesar.vasconcelos
@cesar.vasconcelos 28 күн бұрын
Mr. Paumard and Mr. Venkat are true legends. Their videos are gold and even experienced Java Developers will learn a lot from these two gurus.
@oqpo-q6c
@oqpo-q6c 16 күн бұрын
What I love about all this is that they did not follow the hype back then and did not add the async/await. Guys, you are awesome!
@soliveirajr
@soliveirajr 19 күн бұрын
Great talk, very unbiased and fair! Virtual threads are a great addition to the language, without a doubt. However it is worth mentioning that in terms of sheer performance (latency, not throughput), the 20-year old Java NIO with EPoll cannot be beat. A single thread spinning and pinned to an isolated CPU core is the king when it comes to low latency. And because we are talking about a single thread, which is handling many clients, there are no multithreading pitfalls. That means no synchronization, no deadlocks, no thread starvation, no race conditions, no locks, no nothing. Coding is very easy and joyful. That's the model the financial industry (high frequency market makers) has been very successfully using for 20 years now.
@MikeHeath
@MikeHeath 17 күн бұрын
Yes but this is such an incredibly complicated model to build on. This is why we have frameworks like Reactor and Netty to try and make this model usable. In reality, virtual threads do exactly this. When a virtual thread yields, the scheduler either resumes another virtual thread or invokes epoll to see if any IO has completed. It's essentially the same thing but with a much simpler programming model. Virtual threads gives all the same benefits of old school Java NIO but without all the headaches of trying to put all your concurrent operations in a single epoll loop.
@JosePaumard
@JosePaumard 8 сағат бұрын
> Coding is very easy Sorry, I disagree on this one.
@epsig1507
@epsig1507 27 күн бұрын
I am glad virtual threads came along before my company decided to adopt reactive programming. Now we just need to upgrade java and use virtual threads
@cpu1336
@cpu1336 23 күн бұрын
i'm struggling with reactive code left by previous team, you are lucky!
@jp263
@jp263 23 күн бұрын
I miss Rx. So much cleaner
@cod3r1337
@cod3r1337 14 күн бұрын
@@jp263 I have to use Rx (JS flavored) every day and like to think I'm reasonably competent at it by now, and I have to say I hate every second of dealing with that crap. I just wish there was something like Virtual Threads in JS ...
@Dominik-K
@Dominik-K 27 күн бұрын
Amazing presentation! Really well made and teaches the real reasons why virtual threads are an improvement very well
@codeZarathustra
@codeZarathustra 22 күн бұрын
Great conference Mr. Paumard.
@sjzara
@sjzara 28 күн бұрын
Really helpful - I understand the use of virtual threads for the first time. Thanks.
@PietervandenHombergh
@PietervandenHombergh 29 күн бұрын
typo on slide 47. blocking a virtual thread does NOT block the p.threaf.
@MuztabaHasanat-x2p
@MuztabaHasanat-x2p 25 күн бұрын
👏
@vietnha1999
@vietnha1999 24 күн бұрын
There are some exceptions. E.g synchronzied block
@srki22
@srki22 23 күн бұрын
What a great presentation. Thank you!
@quickruss05
@quickruss05 28 күн бұрын
What about reactive streams? I still think there is a place for reactive in stream processing IMO.
@capability-snob
@capability-snob 28 күн бұрын
The reactor allows us to reason locally about concurrent behaviour. If I know statically where my task may be switched out for another, then I know where I need to recheck my assumptions.
@RenannPrado
@RenannPrado 27 күн бұрын
Before I watch the video, I can only answer the title and say: I really hope so.
@中本聪-d9k
@中本聪-d9k 22 күн бұрын
The great José Paumard!!!
@Talaria.School
@Talaria.School 8 күн бұрын
Thanks champ.
@adrianomoreira
@adrianomoreira 29 күн бұрын
truth, I see fear in my coworkers about the reactive Java code I write
@GoodThoughtsWords
@GoodThoughtsWords 28 күн бұрын
Jośe is a really GOAT I mean it!
@amiyas29
@amiyas29 28 күн бұрын
Very Well explained! Thank you!
@daver94
@daver94 29 күн бұрын
Amazing! Thank u 😊
@122mlb
@122mlb 29 күн бұрын
José is the GOAT
@TrishulBudanurShivalingappa
@TrishulBudanurShivalingappa 24 күн бұрын
nice explanation
@cod3r1337
@cod3r1337 29 күн бұрын
What about Kotlin Coroutines? Until now they still give you Structured Concurrency, which is the missing part in Loom. But once Loom has that covered too, do Coroutines still buy you anything?
@equeim
@equeim 28 күн бұрын
Well they will exist forever in Android (or at least for a decade after they are implemented in ART). Also it's not clear what's the replacement for streams of values (e.g. Flow) is. I suppose with virtual threads you can use regular blocking queues for that?
@cod3r1337
@cod3r1337 17 күн бұрын
@@equeim I think instead of Flows we could just use regular Java Streams (or Kotlin Sequences) that just happen to potentially block the (virtual) thread when computing the next value. At least that seems like an equivalent abstraction to me. Producer/consumer queues can work too, but that feels like a lower abstraction level.
@DanielSimiyu-f9j
@DanielSimiyu-f9j 29 күн бұрын
The abuse of reactive programming will end with structured concurrency
@Franzstick
@Franzstick 29 күн бұрын
the talks by Jose are always crystal clear! Thanks for sharing them!
@bkoprucu
@bkoprucu 28 күн бұрын
15:33 Modern systems don't allocate 2MB continuous memory for stack per thread. Stack is allocated dynamically. 2MB is reserved from virtual memory for stack, which can be configured, but this won't actually optimize memory usage much, only mapping tables. A thread typically consumes ~64KB initially (without extra stack frames).
@prdoyle
@prdoyle 28 күн бұрын
Fun fact: OpenJ9 doesn't even allocate all that virtual memory upfront; it can grow the virtual space dynamically.
@bkoprucu
@bkoprucu 28 күн бұрын
@@prdoyleThat explains why Java 8 consumed more memory on my measurements of stack memory usage
@HarmeetSingh0013
@HarmeetSingh0013 27 күн бұрын
At 22:58 easiest way to explain reactive framework.
21 күн бұрын
29:50 I suffered this for more than a year
@Undergroundoga
@Undergroundoga 29 күн бұрын
Virtual threads solve the blocking issue, but not the underlying task parallelization & back-pressures ones. In the data world & GUI worlds, i imagine RX is here to stay.
@rms_6401
@rms_6401 20 күн бұрын
Do you mean because virtual threads put into heap and unblock app thread only if it's well known api blocking call like http call or file open for example?
@avalagum7957
@avalagum7957 17 күн бұрын
Do you really write code to utilize the back-pressure feature in a reactive library? If yes, may I see an example? I think that back pressure is a way to push the problem (which is that there's not enough memory/cpu to process data) from this application to another application. For example, application A calls application B for data. If application A uses the back pressure feature to tell app B not to send too much data, then application A doesn't need to have a lot of memory to hold data that hasn't been processed yet and application B is the place to hold the data that application A. So, instead of holding data in application A, you hold data in application B.
@rms_6401
@rms_6401 17 күн бұрын
@@avalagum7957 yes we do, Swing ui +Chromium doing few k data points per second in between and you need to keep ui in sync, where data exchange is a mix of jni, rpc and websockets
@pintzio1
@pintzio1 10 күн бұрын
​@@avalagum7957if application B is a MongoDB, you already have the data stored on it. I think the problem is if application B loads all data in memory and sens to A reactively
@Ewig_Luftenglanz
@Ewig_Luftenglanz 29 күн бұрын
I actually enjoy reactive tho. Most of my work has been creating reactive code
@MrKar18
@MrKar18 29 күн бұрын
Yes but should we be proud of it with callback based ones when java should do it simpler? And our `doOnError` or `onErrorResume` calls on call stack to safeguard I loose track when we debug. This is needed but we shouldn't be proud of workarounds.
@pothinenivenkat
@pothinenivenkat 28 күн бұрын
Not that much Sure
@laurentbuhler8483
@laurentbuhler8483 27 күн бұрын
Fruit Of Loom :D
@unimatrixz3ro226
@unimatrixz3ro226 29 күн бұрын
What a nice talk. The only question is "will the scoped values accept a Generic value"? I do think a response for this but i wish someone of the Java team could answer so i can understand the spirit behind the usage of Scope Value in an oficial way of view. Thanks
@PeterVerhas
@PeterVerhas 29 күн бұрын
14:43 I think You meant lost threads. Loose means not tight. Also at 46:00
@shannonkohl68
@shannonkohl68 29 күн бұрын
Loose can also mean "escaped" as in "my horse got loose". Which works in the context he is using it. But since I'm not familiar what the proper nomenclature is you may be right.
@PeterVerhas
@PeterVerhas 29 күн бұрын
@@shannonkohl68 You are right. For me, loose, like a horse or fugitive, also brings the connotation that it does something rogue, uncontrolled. The threads mentioned simply get lost. However, I have only spoken English as a second language for 45 years, and the difference between loose and lost does not lessen the excellent presentation.
@javierflores09
@javierflores09 29 күн бұрын
No, the term "loose" is used metaphorically, as in if a thread is not "tight" with your system, your system is going to fall apart due that "loose thread"
@quintesse
@quintesse 27 күн бұрын
You have to take into account that we're talking about "threads" which has connotations with weaving and cloth. And that context a "loose thread" makes sense, something that is not part of the whole anymore. A "lost thread" on the other hand would be strange concept, it would have to disappear without us knowing where it went.
@cptfwiffo
@cptfwiffo 29 күн бұрын
Always sad to see people confusing latency and throughput. If i dont use concurrency, my latency will go up. My throughput for that thread will suffer. However, if i have enough threads, the gains will not be immediately there: any wait time just lets the cpu do a context switch. Yes, these take time but that is not mentioned. Cpu is still completely filled. The problem occurs when we use microservices with marginal cpu use per work package. Then most time will be wait time and we will hit the max threads. But if you dont, no reason to add the complexity of manual concurrancy.
@nicholas1460
@nicholas1460 28 күн бұрын
Let's hope so. Reactive is an unusable disaster.
@PeterVerhas
@PeterVerhas 29 күн бұрын
Reactive programming is more than Java. It will remain important in micro service architecture and in Java areas where the vthread approach scheduling overhead is too much. For example, using reactive programming you do not move memory between the stack and the heap. It is a very small niche segment, and for most of the programming tasks where you needed to use reactive progrmming in Java to achive the performance vthreads will provide a simpler programming paradigm.
@bkoprucu
@bkoprucu 28 күн бұрын
Virtual thread scheduling does some smart tricks and doesn't actually copy the stack most of the time. Stack size is also usually relatively small. When other Java features related to virtual threads arrive, and when the ecosystem matures, performance difference will all but disappear. Reactive programming will be used maybe for other features of it, like back pressure, or having drivers for some data sources etc.
@AndrewShikhov
@AndrewShikhov 18 күн бұрын
How happy I am that I use kotlin at my work, coroutines there are 10 years ahead of java can be
@gugolinyo
@gugolinyo 29 күн бұрын
I don't think so.
@YouBetterBeJedi
@YouBetterBeJedi 28 күн бұрын
That makes no sense. Reactive Programming has more aspects
@adambickford8720
@adambickford8720 29 күн бұрын
This feels like infomercial levels of dishonesty. Stack traces aren't that bad if you don't use the JDK reactivity, which is pretty limited and has a terrible DX as proven by this video. This reactor code: ` var links = getLinks(); var images = getImages(); Mono.zip(images, links) .map(t2 -> page(t2.getT1(), t2.getT2())) .block();` Produces this stack trace when getImages() errors: `boom java.lang.RuntimeException: boom at org.abickford.fp4legacy.domain.Dishonest.getImages(Dishonest.java:26) at org.abickford.fp4legacy.domain.Dishonest.bs(Dishonest.java:14) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)` That hardly feels like the intractable monster that was fearmongered in this video. "Loose threads" isn't a thing here either. I counted over a dozen methods to return defaults, call another async primitive, short circuit, propagate, etc on errors (default is the error channel in the subscriber). These toy examples also feel unfair. If you need to do actual traffic shaping and routing, timeouts, recovery, switching, etc, I'd argue a bunch of imperative threading primitives aren't better at all. I'd far prefer a nice declarative functional API over managing locks and latches. In fact, this whole pitch is a false dichotomy as RX can be implemented *with VT*! DGMW, i think VT are really cool! But the real comparison should be things like c# async/await and how VT don't color methods. VT also work with legacy blocking APIs like JPA/hibernate. This is a huge win and a real differentiator in java. Rx is the wrong battle.
Java 21 new feature: Virtual Threads #RoadTo21
33:35
Java
Рет қаралды 68 М.
كم بصير عمركم عام ٢٠٢٥😍 #shorts #hasanandnour
00:27
hasan and nour shorts
Рет қаралды 10 МЛН
Thank you Santa
00:13
Nadir Show
Рет қаралды 28 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
Ask the Java Architects
54:47
Java
Рет қаралды 7 М.
Ollama on Kubernetes: ChatGPT for free!
18:29
Mathis Van Eetvelde
Рет қаралды 6 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 645 М.
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 149 М.
Java Virtual Threads - Reactive Programming Killer?
13:57
Viraj Shetty
Рет қаралды 21 М.
Java 21 API New Features #RoadTo21
16:48
Java
Рет қаралды 44 М.
كم بصير عمركم عام ٢٠٢٥😍 #shorts #hasanandnour
00:27
hasan and nour shorts
Рет қаралды 10 МЛН