Search Unity

Using [BurstCompile] On Methods

Discussion in 'Burst' started by tarahugger, Jun 20, 2019.

  1. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    Adding the attribute to a static method makes it show up in the Burst Inspector. Do these compiled methods actually get called from managed nonjob code? e.g. calling SomeClass.Method() from a Monobehavior.Update().

    Code (CSharp):
    1. [BurstCompile]
    2. public unsafe class SomeClass
    3. {
    4.     [BurstCompile]
    5.     public static void Method()
    6.     {
    7.         // do stuff
    8.     }
    9. }
     
    JesOb likes this.
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
  3. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    Thanks, point taken; next time ill bump the most relevant thread i can find. What i found however doesn't answer my question.

    They've said they plan to support pre-compiled methods in the future: https://forum.unity.com/threads/bur...atic-functions-in-builds.683797/#post-4595557

    The methods are compiled and show up in the inspector, but my question is specifically if they're being executed. Are the methods being patched on build/play in the editor to point to the compiled method?

    Im asking because from my tests the performance appears to be the same speed regardless of what kind of work is being done; which would seem to indicate that although they appear to be working, the burst compiled version is being completely ignored during build and play.
     
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Pretty sure they are not being executed. Lots of people are waiting for burst support on non-job code.
     
    tarahugger likes this.
  5. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Best solution so far is to put in ijob and .run - I think this was mentioned somewhere before