Jump to content

Talk:Virtual thread

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Talk:Virtual threads)

Virtual Threads are Different

[edit]

Virtual Threads are required to increase parallelism. OS threads have too large stacks to do that

That other article is about an obsolete technology discarded in 2000

Haraldrudell (talk) 18:42, 5 April 2022 (UTC)[reply]

Initial Comment

[edit]

Virtual threads was commercialized by the Chrome browser in 2008

Green threads was discarded 22 years ago Green threads are co-operative and only allows for sharing a single thread, ie. 10% of today’s hardware

Virtual threads are — preemptive requiring runtime support — non-blocking to the fewer OS threads implementing them requiring the runtime to allocate additional threads hiding blocking calls from the programmer — managed in that the runtime dynamically resizes their stack during execution — Can be instantiated at a rate of 600,000 per second, a rate at which real OS threads would not support and crash — There is a traditional C10k problem in computing from 1999 which became C10M in 2010. With virtual threads, the preemptive part of that is readily supported on launch without having to reconfigure the host computer though I imagine sufficient file handles is required


Here’s from the green thread page: “When a green thread executes a blocking system call, not only is that thread blocked…” This is not how virtual threads work. The runtime manages the mapping of OS threads to virtual threads so that OS threads do not block. The programmer is not involved

Java Loom is not a Green Thread revival, it is virtual threads implemented like it is in Go. It is prompted by the realizations after Go1.14 on 2/25/2020 making goroutines preemptive instead of being coroutines, thgey suddenly became threads, in particular virtual threads because they are not OS threads. The Go garbage collector was frequently talked of as it would never work until it did. Similarly, the benefits of virtual threads was not obvious or significantly considered prior to Go1.14. Coroutines are everywhere because it is easy to implement. Virtual threads are not, they require extensive runtime support. Virtual threads brings massive preemptive response capabilities available in the runtime which was previously requiring extensive frameworks in order to make multi-threading work while being performant and easy to use. Many Java programmers do not program multi-threaded, they use a framework encapsulating those difficult issues

You can see in Green Threads they list 25 languages supporting it. Those languages support all sort of things but most of it is not virtual threads

I don’t understand why the talk page was deleted. It was created to make people understand that virtual threads are not green threads I have been a multi-threaded programmer for about 20 years, that is why I am writing this. The Go people made unspecific statements that “you can have millions,” so I set off on determining exactly how many millions and why not more than that many millions I do not work for anyone involved or stand to make some financial gain from this. I am a software Engineer that presently uses Go 5 years is a generation in computing and Green threads was discarded 22 years ago The only reason to keep that page is to tell how great things were back with Sun Microsystems, like we rarely have processors of their caliber today Today’s Green Threads is coroutines and async/await. Easy to implement but not performant Virtual Threads are different from green threads, coroutines and everything else that is not preemptive. Neither do they make sense if you have a global interpreter lock Virtual Threads in practice began in 2020 as far as I know. Before this, I know of no implementation widely used. I am certain some scientist produced it earlier, but I do not know of it being used commercially Virtual threads are

   • preemptive requiring runtime support
   • non-blocking to the fewer OS threads implementing them requiring the runtime to allocate additional threads hiding blocking calls from the programmer
   • managed in that the runtime dynamically resizes their stack during execution
   • Can be instantiated at a rate of 600,000 per second, a rate at which real OS threads would not support and crash
   • There is a traditional C10k problem in computing from 1999 which became C10M in 2010. With virtual threads, the preemptive part of that is readily supported on launch without having to reconfigure the host computer though I imagine sufficient file handles is required
   • Virtual threads is also part of solving a problem discovered in 2013, which is memory-write visibility with caching for multiple execution units. All Java code prior to 1.5 is inadequate, because this issue did not widely exist prior to that. What virtual threads do is allowing high processor load, ie. efficient processor use, without having to customize for the particular hardware, customization that are unique and must be ported to other hosts and adapted for other models. With virtual threads that just works

Here’s from the green thread page: “When a green thread executes a blocking system call, not only is that thread blocked…” This is not how virtual threads work. The runtime manages the mapping of OS threads to virtual threads so that OS threads do not block. The programmer is not involved Haraldrudell (talk) 01:21, 5 April 2022 (UTC)[reply]

Next Step

[edit]

I think that what you should do at this point is to nominate the redirect from Virtual threads to Green threads for deletion as being an obsolete equivalence. The article on green threads should not be deleted, because it is needed for history. Please tag the redirect for a redirect deletion discussion, and you or I can post a notice to WikiProject Computing. If you would prefer that I tag the redirect for deletion, please ask me. Robert McClenon (talk) 04:41, 6 April 2022 (UTC)[reply]

I have no expertise in the topic of this article or the field to which it belongs, but to me it seems that, per the main/parent article Thread (computing) and WP:NCPLURAL: The article titles should be green thread and/or virtual thread. Vycl1994 (talk) 23:10, 6 May 2022 (UTC)[reply]

Question

[edit]

User:Haraldrudell - Are you saying, or is it correct, that green threads are simply one historical implementation of virtual threads? Robert McClenon (talk) 02:57, 7 April 2022 (UTC)[reply]

Green Thread is one, since 20 years obsolete, implementation of coroutines.
The difference between coroutines and virtual threads is that coroutines are single-threaded, ie. do not benefit from multi-core or multi-processors. This thread sharing is easy to program
Virtual Threads is what can use all available hardware, but at the price of requiring multi-threaded synchronization. Multiple instructions are executed in parallel, truly at the same time. Issues includes two threads writing to the same memory address, or one thread having no or partial visibility into the writes of another thread depending on hardware caching and design
Virtual Threads use all available hardware therefore typically providing a magnitude of gain in performance on 2021 consumer hardware
In data centers, multi-core was common from 2000. In consumer hardware, since 2006. Since 2020, a dozen execution units is not uncommon
As far as I know, only Google and Oracle has Virtual Threads usable to programmers, and both those world top software corporations spent around five years getting there. This is a revolution because once it works, the programmers has a thousand times more threads available without the many sources of crashes that come with real operating system threads Haraldrudell (talk) 01:00, 17 April 2022 (UTC)[reply]