Search Unity

Match 3 Agent GC bug

Discussion in 'ML-Agents' started by STKMAN, Apr 6, 2021.

  1. STKMAN

    STKMAN

    Joined:
    Mar 10, 2016
    Posts:
    11


    My project is Match3 , if I don't use ML, my CPU main is 10ms, but if the ML start working it's going to 1600ms.

    And I found the more cell types the more GC, code like this
    upload_2021-4-6_17-43-48.png
     
  2. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    Hi,
    The observation size for the Match3 sensors is roughly (Rows * Columns * (NumCellTypes + NumSpecialTypes)), so it's not too surprising that increasing those will increase the memory usage.

    Some of the GC churn during training is hard to avoid because we have to use protobuf objects to pass information to the trainer. But there's definitely some allocations that we can reuse in training, especially here (which only happens if you're using visual observations with compression). I'll do a pass on this today and try to clean up any allocations that I can.
     
  3. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
  4. STKMAN

    STKMAN

    Joined:
    Mar 10, 2016
    Posts:
    11
    Thank you, I will try it
     
  5. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    Great, the new version came out on Tuesday. Note that the Match3 code is now part of com.unity.ml-agents (not the extensions package), and also the AbstractBoard class changed a bit.