Can't yield from within an instance created by reflection

David Holmes david.holmes at oracle.com
Wed Apr 7 02:18:01 UTC 2021


On 7/04/2021 4:09 am, Øystein Myhre Andersen wrote:
> As I told Alan - I have also written an implementation that uses
> oversynchronized threads. Platform threads works well but virtual threads
> do not. There is something wrong there. I will return when it has been
> analyzed more thoroughly. I will be back when I know more.

It isn't clear exactly what you mean by the above. But if it means you 
have code that uses synchronized blocks/methods, and there is 
contention, then virtual threads will get pinned because monitors are 
implemented in the VM with native code.

David

>    - Øystein
> 
> On Tue, Apr 6, 2021 at 7:50 PM Ron Pressler <ron.pressler at oracle.com> wrote:
> 
>> I’d be interested to see how well this works with virtual threads, perhaps
>> with a custom scheduler.
>> Should be very similar to using continuations directly.
>>
>> As to continuations, the fact that they *can* work *some* of the time
>> doesn’t mean we can expose them. Other
>> times, they can break compiler assumptions and result in undefined
>> behaviour.
>>
>> — Ron
>>
>>> On 6 Apr 2021, at 16:42, Øystein Myhre Andersen <o.myhre at gmail.com>
>> wrote:
>>>
>>> As mentioned, I have implemented Simula's class Simulation. I have run
>>> simulations with up to a million processes. I have done this both with
>>> platform threads and with Continuations.
>>>
>>> The time consumption with platform threads increased exponentially
>>> while Continuations only increased linearly.
>>> Just so you know.
>>>
>>>
>>> On Tue, Apr 6, 2021 at 5:10 PM Alan Bateman <Alan.Bateman at oracle.com>
>> wrote:
>>>
>>>> On 06/04/2021 15:29, Øystein Myhre Andersen wrote:
>>>>
>>>> That's a pity to remove such a basic feature. I am working on an open
>>>> source project to implement Simula using Java. As you probably know,
>> Simula
>>>> was a great inspiration to James Gosling when he defined Java. Kristen
>>>> Nygaard and Ole-Johan Dahl strongly believed that basic concepts were
>> the
>>>> thing. And I see Delimited Continuations as an important basic concept.
>>>> Simula introduced Quasi-parallel systems to define discrete event
>>>> simulation. You want to use it for virtual threads but it is possible
>> that
>>>> there are somebody out there who will use it for eg artificial
>>>> intelligence. Why stop that opportunity - I will use it to implement
>> Simula
>>>> coroutines ( QPS Sequencing).
>>>>
>>>>
>>>> By the way, I have also written an implementation that uses
>>>> oversynchronized threads. Platform threads works well but virtual
>> threads
>>>> do not. There is something wrong there. I will return when it has been
>>>> analyzed more thoroughly.
>>>>
>>>>
>>>> If you are interested, the Simula project can be found here:
>>>>    https://portablesimula.github.io/github.io/ <
>> https://urldefense.com/v3/__https://portablesimula.github.io/github.io/__;!!GqivPVa7Brio!JNUrhq9WTpQQqmLyjbcrT062Xy0A2NUQvg5fZuffY9p7H9dOD130REg_AxisbmwmpA$
>>>
>>>>
>>>> Thanks for the link to the project implements Simula coroutines.
>>>>
>>>> Delimited continuations is a powerful primitive but not one that this
>>>> project plans to expose at this time. One significant issue is that
>>>> yielding on one thread and continuing on another would break the
>> invariant
>>>> that Thread.currentThread() doesn't change in a thread of execution.
>> Thread
>>>> locals, lock ownership and several other features would break. There is
>>>> also the issue as to whether the control flow would be just too advanced
>>>> for many developers. It might be that generators or some other feature
>> that
>>>> will use thread-confined coroutines but for now, our focus is on virtual
>>>> threads.
>>>>
>>>> -Alan.
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>


More information about the loom-dev mailing list