playMaker

Author Topic: Huge performance hit spike every few seconds.  (Read 5286 times)

Spunkyinteractive

  • Playmaker Newbie
  • *
  • Posts: 22
Huge performance hit spike every few seconds.
« on: November 22, 2016, 04:21:16 AM »
Hi there,
Playmaker or one of the FSM's i've created within it seems to be causing a huge spike against CPU Perf every few seconds. Is there someway i can drill in to see exactly which one is causing this? I've attached a screenshot from doing a deep profile recording. Also I have turned off playmaker debug logging, so that shouldn't be related.

thanks for any and all hints on how i should go about finding the culprit.

-Stephen

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Re: Huge performance hit spike every few seconds.
« Reply #1 on: November 22, 2016, 04:38:43 AM »
Looks like it may be a spike caused by the garbage collector

If you select the behavior in the list far down enough, it should show you which objects are triggering the CPU/GC usage, instead of "N/A", I highlighted 2 of them where I saw a significant increase in GC and CPU


Spunkyinteractive

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Huge performance hit spike every few seconds.
« Reply #2 on: November 22, 2016, 10:03:14 AM »
Thanks for the reply. I actually tried clicking on every item down to the lowest level and all of them display N/A for all objects..

Do you know if all garbage collection is done by Unity? Or is some of it being done by playmaker? Sorry if this is a noob question, i'm still in the process of learning how to use the profiler. as well as how to understand performance within unity/playmaker.

-Stephen

Spunkyinteractive

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Huge performance hit spike every few seconds.
« Reply #3 on: November 23, 2016, 05:15:20 AM »
I just wanted to post a quick update on this.

When i turned off 'deep profile' in the profiler, it now shows what specific objects are causing the lag spikes which as allowed me to track down which FSM was causing this.

Also it turns out converting float to string causes quite a bit of garbage collection.

-Stephen

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Re: Huge performance hit spike every few seconds.
« Reply #4 on: November 23, 2016, 05:51:22 AM »
I think Playmaker itself has very little overhead in performance, but it's still very possible to "write" inefficient code or use actions that can cause performance problems too liberally.

Glad you were able to find out the problem!

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Huge performance hit spike every few seconds.
« Reply #5 on: November 23, 2016, 06:15:17 AM »
I just wanted to post a quick update on this.

When i turned off 'deep profile' in the profiler, it now shows what specific objects are causing the lag spikes which as allowed me to track down which FSM was causing this.

Also it turns out converting float to string causes quite a bit of garbage collection.

-Stephen

I struggle with GC from time to time, I've read tons of comments on it and still often feel lost while dealing with it. It seems strings in general cause a lot of garbage and Unity's garbage collection system is old and sucks.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Huge performance hit spike every few seconds.
« Reply #6 on: November 23, 2016, 12:41:57 PM »
Use ConvertFloatToStringFast action from ecosystem. It has little to no GC.

Search Optimized StringBuilder in ecosystem for more optimised action with little to no GC

Spunkyinteractive

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Huge performance hit spike every few seconds.
« Reply #7 on: November 27, 2016, 02:13:50 PM »
Thanks for the replies :)

I ran a test using the 'convert float to string fast' from the ecosystem instead of the standard 'convert float to string' action included with playmaker.

Using the 'fast' ecosystem version had my game running at approx. 14fps

Using the standard playmaker action had my game running at approx. 30fps

I also see that unity gives many warnings that the 'fast' action is using legacy code that isn't supported anymore.

From my experience i suggest do not use 'ConvertFloatToStringFast' action from the ecosystem.