Search Unity

Question Barracuda calls GC

Discussion in 'Barracuda' started by XSquare2, Feb 2, 2022.

  1. XSquare2

    XSquare2

    Joined:
    May 7, 2018
    Posts:
    8
    Hello, barracuda calls GC on Execute(), is there any way to get rid of this? Worker is on the GPU, the garbage is about 4.5 kb, if you transfer it to Burst, then it is even worse there, more than 100 kb. By the way, what will be better on mobile phones, GPU or Burst?
    I'm using 2.4.0-preview version.

    Code (CSharp):
    1. private void TakeScreenShot()
    2.     {
    3.         var channelCount = 1;
    4.         inputX = new Tensor(rendTexture_forNeuro, channelCount);
    5.         var outputY = ExecuteInParts(_engine, inputX);
    6.         prediction.SetPrediction(outputY);
    7.         Receive();
    8.     }
    9.     Tensor ExecuteInParts(IWorker worker, Tensor I, int syncEveryNthLayer = 5)
    10.     {
    11.         var executor = worker.StartManualSchedule(I);
    12.         var it = 0;
    13.         bool hasMoreWork;
    14.  
    15.         do
    16.         {
    17.             hasMoreWork = executor.MoveNext();
    18.             if (++it % syncEveryNthLayer == 0)
    19.                 worker.FlushSchedule();
    20.  
    21.         } while (hasMoreWork);
    22.  
    23.         return worker.CopyOutput();
    24.     }
     
    Last edited: Feb 10, 2022
  2. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    Hello XSquare2,
    Thanks for your feedback! Indeed it seems we have GC regressions in latest release! I'm currently investigating and will post here the findings/solutions/patchs.

    Thanks again!
    Florent
     
    XSquare2 likes this.
  3. XSquare2

    XSquare2

    Joined:
    May 7, 2018
    Posts:
    8
    Thanks! let's wait for the fix
     
  4. airoll

    airoll

    Joined:
    Jan 12, 2021
    Posts:
    37
    Did this ever get fixed? I went from 40kb per step in v2.0.0 and v2.1.0 to 60kb per step using v2.2.0, v2.3.1, and v3.0.0 on an Android (Quest) device using Burst as the backend.