Search Issue Tracker

Active

Under Consideration for 6000.0.X

Votes

0

Found in

6000.0.16f1

7000.0.0a1

Issue ID

UUM-77985

Regression

No

Slow synchronization primitives (lock, volatile, interlocked) on IL2CPP

--

-

*Steps to reproduce:*

Originally reported on Discussions here: [https://discussions.unity.com/t/poor-performance-of-synchronization-primitives-lock-volatile-interlocked-in-il2cpp/1489837]

 
{code:java}
int count;
public void TestNormal()
{
    [MethodImpl(MethodImplOptions.NoOptimization)]
    static void Incr(ref int v)
    {
        v++;
    }
    for (int i = 0; i < 100000000; i++)
    {
        Incr(ref count);
    }
}
public void TestVolatile()
{
    for (int i = 0; i < 100000000; i++)
    {
        Volatile.Write(ref count, Volatile.Read(ref count) + 1);
    }
}
public void TestInterlocked()
{
    for (int i = 0; i < 100000000; i++)
    {
        Interlocked.Increment(ref count);
    }
}
public void TestLock()
{
    for (int i = 0; i < 100000000; i++)
    {
        lock (this)
        {
            count++;
        }
    }
}
{code}
 

*Actual results:* 

Mono
{code:java}
normal: 142ms
volatile: 143ms
Interlocked: 347ms
lock: 1782ms{code}
IL2CPP
{code:java}
normal: 114ms
volatile: 1310ms
Interlocked: 990ms
lock: 6872ms{code}
.NET 8
{code:java}
normal: 23.43ms
volatile: 21.70ms
Interlocked: 343.34ms
lock: 1,305.52ms{code}
 

*Expected results:* 

*Reproducible with versions:* 

6.0 preview

*Tested on (OS):* 

Windows

Comments (1)

  1. evelynmartinez9911

    Aug 12, 2024 07:31

    How do I recover $222,500. BTC sent to a romance scammer?
    It's possible to get back your money little I know it was a big shock of my life because the company i sent my money to was revealed to be a total scam.
    I contacted the professional and they helped me with the recovery of all my money successfully, you can also contact them for help. They will help you retrieve back your money, I was able to retrieve all my money back through the professional, you can contact them too they are ready to help....

    Email Address: dwchzone @ gmail . com

    Whats-App: + 1 (803) 392 - 1735

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.