Search Issue Tracker

Won't Fix

Votes

0

Found in

2018.2.0b4

Issue ID

1041643

Regression

No

NativeArray<T> is slower than built-in C# array

Scripting

-

* NativeArray in mono in the editor is slower than builtin arrays
* We need to make sure agressive inline works properly, if not possible or doesn't get the necessary speedups add a custom intrinsic for native array

------

Steps to reproduce:
1. Open supplied project ("SlowNativeArrayAccess.zip")
2. Play the Scene ("SampleScene")
3. Inspect the Console window

Result: the computational time difference is more than 10x (see notes)

Reproduced in: 2017.1.4f1, 2017.2.3p1, 2017.3.2f1, 2017.4.5f1, 2018.1.4f1, 2018.2.0b8, 2018.3.0a1

Note:
Win 10.1 (3.3 GHz) Unity 2018.2.0b8:
C# array computation took: 0.545589
NativeArray computation took: 5.9725
Unsafe C# array computation took: 0.5315886

MacBook Pro 2016 (2.9 GHz) Unity 2018.2.0b4:
C# array computation took: 0.134985
NativeArray computation took: 2.369257

  1. Resolution Note (2018.3.X):

    We plan on doing a performance pass related to DOTS and native collections on Mono in the future (late 2020 or 2021). However, this will be a lot of work and not something we can solve via a bug. Resolving for now.

Comments (1)

  1. imaginaryhuman

    Dec 04, 2019 19:49

    This seems to still be an issue in 2019.3. Native arrays in the editor under mono are very slow. Also under mono in a windows build, they are super slow compared to IL2CPP.

    A speed test I produced just writing values into a native array.... in mono in a windows build it took 149579 ms, versus only 4134ms in IL2CPP in a windows build.

    Thing is it's fine that IL2CPP is so much faster, BUT, other normal array accesses were also way faster than the native array in mono. e.g. an Int Array doing the same thing took 16000ms, which means the native array under mono is 9.3x slower than a regular integer array in mono. Why is the native array SO much worse when under mono?

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.