Plummeting performance

daroweus

  • Posts: 1
Nomosoft,

Have you had any traction on this subject?

I have been working on a game for about a week just assuming that I was doing something to cause the "eventual lag" but it seems in the examples you have given where you are simply "creating actors" and "killing actors" there is significant lag after a period of time.

Is this a serious problem with stencyl? or maybe just the physics engine?
Derek Alan Rowe
Art Director @ Doctrine Creative

Nomosoft

  • Posts: 122
I suspect this is a Stencyl issue, but I can't say for sure.

However, I have just discovered a bizarre bug with recycling actors that may be related to this. I am fiddling with it, now, and will post a thread if I don't figure it out.

Also, Rob: I did some more tests.

Create Recycled/Recycle = Minimal problem
Create/Kill = Problem
Create/Recycle = Disaster

Rob

  • *
  • Posts: 1268

Also, Rob: I did some more tests.

Create Recycled/Recycle = Minimal problem
Create/Kill = Problem
Create/Recycle = Disaster

Great find, Nomo.

Did you say "Create Recycled/Recycle" has minimal degradation. If so, we just need to use that and stencyl should plan on defaulting to that and plan on to remove the others. What's your observation in term of fps after 15 minutes here?

For the star actor event, I just switch from Kill Self to Recycle self while using create Recycled actor all along for the scene?

I would really like to test it.

« Last Edit: May 04, 2012, 05:01:10 pm by Rob »
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

Nomosoft

  • Posts: 122

Also, Rob: I did some more tests.

Create Recycled/Recycle = Minimal problem
Create/Kill = Problem
Create/Recycle = Disaster

Great find, Nomo.

Did you say "Create Recycled/Recycle" has minimal degradation. If so, we just need to use that and stencyl should plan on defaulting to that and plan on to remove the others.

Can you post the exact game or code that you change for Create Recycled/Recycle?

I would really like to test it.

I have a "Die" behavior that all my actors share. So, to recycle, I just swap the "recycle" block for the "kill" block. Same thing with creating actors - I have a very complex spawn behavior that can spawn a single actor type, or multiple actor types from a list in order, or multiple actor types from a list randomly, and it can spawn every X seconds with Y probability, it can spawn in the visible screen area, or anywhere in a scene, or randomly in a selected region, and on and on, but it only has one "create" statement, and I can just swap that with a recycle. The thing is, when I tried it inside my game, I did not see the same minimal degredation. I will have to try, again.

Edit: Oh, and bullets are all spawned by my "Gun" or "Burst Gun" behaviors, and those also each have only one create spot, so it's easy to swap out. I still saw slowdown, I think. I will check again.

Rob

  • *
  • Posts: 1268
Let's just try to reduce this one by one and see if you can nail down the culprit with your game.

You rare absolutely right. If I use recycle actor/recycle for my game, I do NOT see any (hardly any) degradation at all.

One more very important note - my window task manager showing flash-10-win.exe at constant 37K mem usage. The other combinations showing much larger memory leak of up to 230K and bigger if I let it go for a while.
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

Nomosoft

  • Posts: 122
Let's just try to reduce this one by one and see if you can nail down the culprit with your game.

You rare absolutely right. If I use recycle actor/recycle for my game, I do NOT see any (hardly any) degradation at all.

One more very important note - my window task manager showing flash-10-win.exe at constant 37K mem usage. The other combinations showing much larger memory leak of up to 230K and bigger if I let it go for a while.

Yeah, this reeks of improperly disposed assets, which is what I've suspected from the beginning. In addition, I think the logic may be getting processed for some of them, but that's harder to pinpoint. I am working on something else, at the moment, but I will get back around to fiddling with my space shooter sometimes today or tonight.

Rob

  • *
  • Posts: 1268
Well done here. We definitely need more users like you to help nail down some of these gray areas.

I've done a study with the 4 scenarios you mentioned:

FPS Study

Create Recycled/Recycle -> 40-50 fps all the way
Create/ Kill -> 40-50 fps down to 18 fps after 15 minutes
Create Recycle/Kill -> 40-50 fps down to 18 fps after 15 minutes
Create/Recycle -> 40-50ps down to 2 fps within 2 minutes; game at 0 fps and not moving at all after 5 minutes

where:

Create Recycle -> create recycled actor as part of scene behavior
Create -> create actor as part of scene behavior
Recycle -> recycle self as part of actor behavior
Kill -> kill self as part of actor behavior
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

Nomosoft

  • Posts: 122
Well done here. We definitely need more users like you to help nail down some of these gray areas.

I have two talents: I can sing, and I can beta test. If I could find people to pay me steadily for either one, I'd be in hog heaven. There are many projects floating around out there with my stamp on them in everything from features and interface design to reliability. Once I get my teeth into something, I don't like to let go.

I've done a study with the 4 scenarios you mentioned:

FPS Study

Create Recycled/Recycle -> 40-50 fps all the way
Create/ Kill -> 40-50 fps down to 18 fps after 15 minutes
Create Recycle/Kill -> 40-50 fps down to 18 fps after 15 minutes
Create/Recycle -> 40-50ps down to 2 fps within 2 minutes; game at 0 fps and not moving at all after 5 minutes

where:

Create Recycle -> create recycled actor as part of scene behavior
Create -> create actor as part of scene behavior
Recycle -> recycle self as part of actor behavior
Kill -> kill self as part of actor behavior

My system takes a bit longer to bog down, but, other than that, I'd say our numbers agree quite well.

Rob

  • *
  • Posts: 1268
I thought you are from Vegas. Right?

They need singers and sharp astute guys to make sure no one cheat :)

Seriously, with upcoming 2.5, it would be nice if you can hang around to test and uncover all these nitty-gritty things. Particularly in android and html5 domain.

p.s. If you look at my game portfolio, I did made a draw poker game.
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

PressXtoNotDie

  • Posts: 94
Using the FPS.zip that rob provided, i too am experiencing this. After about 15 or so mins running that example (in standalone) frame rate went from a constant 60-61 fps, to a constant 30 fps. It is definitely Stencyl that is causing this.

For small games, this shouldnt even be a problem at all, but games that you would be playing for a significant amount of time, this could be problematic. Telling your users to refresh, reload the game every hour to avoid this, is pretty bad.

Rob

  • *
  • Posts: 1268
Note that we have identified that we should be using recycle actor and recycle self (go into star actor event page and change kill self to recycle self) and rerun. You'll see fps stay constant in that case.

So there is no issue at all. It's just a matter of reminding users to use above strategy.
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

PressXtoNotDie

  • Posts: 94
Ah i definitely read it wrong then, thought it was already recycled actors. Teached me to scim through posts again lol. And yeah it seems to run fine now.

Nomosoft

  • Posts: 122
Seriously, with upcoming 2.5, it would be nice if you can hang around to test and uncover all these nitty-gritty things. Particularly in android and html5 domain.

I've already decided not to invest too much in Stencyl. I won't bore you with details, but I discuss why in the Stencyl Pro thread. So, I can't make any promises, but if I'm around when 2.5 hits, I'll certainly contribute anything useful I come up with.

So there is no issue at all. It's just a matter of reminding users to use above strategy.

Well, there's definitely an issue, but it looks like we've found a workaround. The workaround may have issues, too, though. See my other thread about recycled actors.

captaincomic

  • *
  • Posts: 6109
FPS Study

Create Recycled/Recycle -> 40-50 fps all the way
Create/ Kill -> 40-50 fps down to 18 fps after 15 minutes
Create Recycle/Kill -> 40-50 fps down to 18 fps after 15 minutes
Create/Recycle -> 40-50ps down to 2 fps within 2 minutes; game at 0 fps and not moving at all after 5 minutes

Just by looking at these numbers, it seems Create Recycled/Recycle works fine.

Create/Kill shouldn't cause a FPS drop, it should always have the same impact on performance. Creating an actor is slow compared to "creating" a recycled actor, but it shouldn't become slower over time.

Create Recycle/Kill never takes advantage of the recycled actors, because they are never recycled, so the result is the same as with Create/Kill.

Create/Recycle is not supposed to be used together, so that's not an issue.


Nomosoft

  • Posts: 122
Create/Kill shouldn't cause a FPS drop, it should always have the same impact on performance. Creating an actor is slow compared to "creating" a recycled actor, but it shouldn't become slower over time.

I went into this assuming the slowdown was not "supposed" to happen, but it definitely does. Any ideas why? It really looks like killed actors are leaving behind ghosts who eat resources.


Create/Recycle is not supposed to be used together, so that's not an issue.

I think this still qualifies as an issue. "Compiles and executes, but utterly cripples your game" is a pretty poor outcome for this scenario. I think we'd be better served by having the game throw an exception or error, rather than happily gobbling cycles and RAM until the game halts, completely.

Also, there may still be an underlying problem. The performance loss is not linear. It isn't like we're adding thirty items at a time to the recycled actor pool and it's causing a gradual slowdown, it's more like the entire pool is being doubled or trebled every single frame.

New data: I attached my Scene Profiler behavior to both of the behaviors/events in the FPS test game and got some interesting/bizarre results.

Format = Block being used | Total milliseconds | Average milliseconds per call | Approximate FPS
Start = Data from first few frames of gameplay, Final = numbers after allowing program to run for some number of minutes

Create / Kill
(Create Start) | 128ms | 32ms | 60fps
(Kill Start) | 2ms | 0ms | 60fps
(Create Final, 24 minutes) | 41700ms | 32.6ms | 30fps
(Kill Final, 24 minutes) | 182ms | 0ms | 30fps

In this scenario, the problem is obviously happening outside of our behaviors and events, since the behavior profiles don't change, much.


Create Recycled / Recycle
(Create Recycled Start) | 258ms | 10.75ms | 60fps
(Recycle Start) | 420ms | 1ms | 60fps
(Create Recycled Final, 22 minutes) | 35472ms | 8.89ms | 60fps
(Recycle Final, 22 minutes) | 12300ms | 0.85ms | 60fps

No FPS loss or obvious resource drain.

Create / Recycle
(Create Start) | 37ms | 1.16ms | 60fps
(Recycle Start) | 134ms | 44.67ms | 60fps
(Create Final, ~2 minutes) | 3703ms | 88.17ms | 1fps
(Recycle Final, ~2 minutes) | 18856ms | 16.51ms | 1fps

Now, in this case, you can see that the slowdown came in the actual create and kill blocks, inside the behaviors. Unlike Create / Kill, where the profiled times stayed about the same despite the FPS dropping, this time we can actually see where (some of) the lost time is going. Clearly, although the creation block takes the most time per call (it is creating 30 items at a time), it is the actual recycle command that eats up most of the milliseconds. While the creation time just about doubled per call, the recycle time went up by over 10x. Whether or not those blocks are meant to be used together, I am guessing there is something in there that is not performing exactly as expected.