playMaker

Author Topic: Run FSM Stutter (Garbage Collection?)  (Read 5609 times)

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Run FSM Stutter (Garbage Collection?)
« on: December 13, 2017, 11:26:26 AM »
I'm having some performance problems when using the Run FSM action as part of my VR system to interact with objects.

After using Run FSM/Finish FSM about a 100 times my game starts to stutter and becomes unplayable.

This does not happen when i remove the Run FSM actions and replace the templates with normal Fsm's.

This feels like a garbage collection problem of some sorts, are the template Fsm's actually being unloaded from memory when running Finish Fsm?
« Last Edit: December 20, 2017, 10:02:51 AM by LordHorusNL »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Run FSM Stutter (Garbage Collection?)
« Reply #1 on: December 13, 2017, 12:15:10 PM »
Hi.
Can you give some more information what is in the fsm
and maybe a video showing the issue?

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?)
« Reply #2 on: December 13, 2017, 06:26:33 PM »
Okey found the culprate! i was using one "Run Template FSM" from the ecosystem.

For some reason it does not seem to finish the templates but keeps them active, so not a playmaker bug afterall.

I'll see if this actions can be updated by the author.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
« Reply #3 on: December 14, 2017, 01:47:47 AM »
Hi,

 I am here :) run Fsm Template is tricky action ( and I don't recommend it, it's advanced, I am thinking about remove it as well...), can you tell me what you think is the problem, maybe I can do something?

 Bye,

 Jean

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
« Reply #4 on: December 14, 2017, 06:41:50 AM »
Hi jean

Run Template FSM is very handy because it allows me to choose the template to run as a variable (so i can change it on the fly)

What i think is happening is that the action somehow does not finish the template properly when running the "Finish FSM" action inside itself.

I think this is happening because the stutter i get from using this action seems to be cumulative, in that it gets progressively worse the more you use it.

However this is just from observation!

So if the action can be fixed, or replaced with a "Run FSM" variant that lets the user define the template as a variable. That would be great.

I was going to look into that myself today.
« Last Edit: December 14, 2017, 06:45:16 AM by LordHorusNL »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
« Reply #5 on: December 20, 2017, 02:53:06 AM »
Hi,

 yeah, you have a good point here, I am not cleaning up the objects:

 try this ( update the method, that method already exists)

Code: [Select]
  public override void OnExit()
        {
            if (runFsm != null)
            {
                runFsm.Stop();
            }

fsmTemplateControl = new FsmTemplateControl();
runFsm = null;
        }

let me know how it goes.

 also, you can profile this and maybe you'll see the increase in memory consuption in your case that youc an then compare with this modification.

 Bye,

 Jean

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
« Reply #6 on: December 20, 2017, 10:02:32 AM »
Thanks for looking into this jean.

Unfortunately the fix did not solve the problem, i did find that there is a memory spike when using RundTemplateFSM that is not present when using RunFSM.

However i only see the spike when i run the action, and i have no idea if this could explain the stutter buildup i am experiencing.



Still new to the profiler, so not to sure what i could be looking for.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?)
« Reply #7 on: December 21, 2017, 01:31:40 AM »
Hi,

 ok, simply click on the spike to bring the head to that spot and check what is taking the most time in the detailed.

The problem with running fsm is that it is about instantiating something at runtime and this alwasy is a costly operation, if the timing is wrong ( likely when in your gameloop) then it becomes noticeable.

I'll run the debugger on some project that use this action too and see if I can spot this on my end.
 
please bump me early next week if I haven't replied...  I need the bumps :)

 Bye,

 Jean

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?)
« Reply #8 on: December 21, 2017, 07:04:40 AM »
Ok, so i ran a comparison on the two actions and there seems to be a huge difference in resources used in the update call. (whatever it's called)

Note PlayMakerFSM.Update()

Run FSM
https://i.imgur.com/NQZW1BZ.png

Run Template FSM
https://i.imgur.com/UDDinwH.png

Should assigning a template at runtime be this costly? compared to in the editor.
« Last Edit: December 21, 2017, 07:21:33 AM by LordHorusNL »

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?)
« Reply #9 on: January 05, 2018, 10:53:52 AM »
*Bump*

Jean, I was wondering if you've had any time to look into this.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?)
« Reply #10 on: January 09, 2018, 05:32:48 AM »
Hi,

 Not yet, thanks for the bump :) Let me move that up in my long to do list :)

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?)
« Reply #11 on: January 09, 2018, 06:02:15 AM »
Hi,

 ok, I have found some obvious bad memory management, can you update the action from the Ecosystem, this will definitely improve the situation. I did not found anything when profiling, so let me know if that doesn't improve the situation on your end, maybe I'll need to check with your project.


 Bye,

 Jean

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Run FSM Stutter (Garbage Collection?)
« Reply #12 on: January 11, 2018, 06:35:52 PM »
Thanks for the update jean, unfortunately the problem still persists.

The system is setup for VR right now, so i'll have to see if i can rework it for Non-VR and see if the problem is really with the action.
« Last Edit: January 11, 2018, 06:38:15 PM by LordHorusNL »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Run FSM Stutter (Garbage Collection?)
« Reply #13 on: January 12, 2018, 01:47:33 AM »
Hi,
 
Ok, keep me up to date.

 Bye,

Jean

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
« Reply #14 on: March 20, 2018, 03:24:11 AM »
Hi,

 I am here :) run Fsm Template is tricky action
Run FSM is a different action? And Run FSM is fine?