Search Unity

[Job System] What is CheckElementReadAccess()?

Discussion in 'C# Job System' started by Desoxi, Mar 29, 2018.

  1. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    Hey there,

    i was profiling my C# job system implementation of a custom spring physics simulation and the most expensive operation seems to be "NativeArray'1.CheckElementReadAccess()".
    Im curious what that might be (besides the obvious fact that it checks if it has read access ofc. :D )? All NativeArrays im using are [ReadOnly], why does it have to check them each time then? Is there something i can do to minimize this?

    Greetings,
    Desoxi
     
    Last edited: Mar 29, 2018
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    that is an editor/debug check that prevents race conditions etc. @Joachim_Ante has many posts in this forum about that.

    if you make a release build (always profile in a release build) it should disappear.

    you can also disable them in the editor (Jobs menu if I remember right) but if you make a mistake you could crash the editor (and it will stop detecting race conditions)
     
  3. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    Ohh i see, didnt find it through the search, maybe i used the wrong keywords. Thanks for the answer!