bugBattle for Wesnoth - Bugs: bug #16363, Lag when beginning animations if...

 
 
Show feedback again

bug #16363: Lag when beginning animations if animations have lots of frames

Submitted by:  Eli Dupree <elvish_pillager>
Submitted on:  Thu 05 Aug 2010 03:11:25 PM UTC  
 
Category: BugSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Graphics
Status: NonePrivacy: Public
Assigned to: Jérémy Rosen <boucman>Open/Closed: Open
Release: 1.8.3Operating System: Ubuntu

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 29 Aug 2010 07:08:15 PM UTC, comment #15:

Ok, the cache has been added, but unfortunately the fix can't ve tested with the savegame.

Elvish Pillager, could you do the following ?

in the "new_animation" block where you add the animation could you add an id=<something> flag, where "something" is any string that is different for each new_animation block ?

this should reduce most of what's left of the blocking time.

if that's not enough, could youpost a new save after that feature was enabled so we can look into it some more ? thx

Jérémy Rosen <boucman>
Project MemberIn charge of this item.
Sun 29 Aug 2010 07:05:21 PM UTC, SVN revision 46088:

add a cache for WML added animations, partial (and probably final) fix for bug #16363

(Browse SVN revision 46088)

Jérémy Rosen <boucman>
Project MemberIn charge of this item.
Sun 29 Aug 2010 01:05:12 PM UTC, comment #13:

note to self : ok, here is the plan...

each animation can have an id to avoid loading.

we keep some sort of global std::set which matches id to unit_animation structures (multiple du to conditional expansions)

when an animation is added to a unit, we look for the id in that set

  • if it is in, we add a copy to the unit, as we do for animations that come from the unit_type
  • if it is not call a lua function that will return the cfg to be parsed, and parse it the old way.

ask silene for implementation details.

still need to figure out where to store the set so it has the proper lifecycle

Jérémy Rosen <boucman>
Project MemberIn charge of this item.
Sun 29 Aug 2010 12:24:50 PM UTC, comment #12:

ok, we are adding custom animations, so my first idea of factoring into the type to parse them only once won't work.

basically what takes time is that we are reading the WML and filling in the structures describing the actual animations.

a complicated method would be to have a "load_animation" wml action that could be added to prestart events That would load the animation WML and attach it to an id, and then be able to attach it to a unit through the add_animation action.

Would this be fine with you ?

Jérémy Rosen <boucman>
Project MemberIn charge of this item.
Fri 06 Aug 2010 06:32:35 PM UTC, comment #11:

Updated callgraph. From an animation point of view, the biggest offenders are the 33% of unit_animation::add_anims (of which 20% are from particule::particule). On the Lua side, there are 30% spent on getting data from/to WML and engine. The remaining 35% of the profile do not show anything obvious.

(file #9722)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 06:12:34 PM UTC, SVN revision 45267:

Used the original defender and restored its hitpoints instead of copying it to a temporary unit. (Partial fix for bug #16363.)
This brings the profile footprint of unit_attack from 7% to negligible.

(Browse SVN revision 45267)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 05:31:14 PM UTC, SVN revision 45266:

Avoided copying scoped units. (Partial fix for bug #16363.)
This brings the profile footprint of variable_info from 9% to 4%.

(Browse SVN revision 45266)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 04:31:01 PM UTC, SVN revision 45262:

Added visitors for converting config attributes. (Partial fix for bug #16363.)
This brings the profile footprint of pushing units to Lua tables from 15% to 5%.

(Browse SVN revision 45262)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 02:46:06 PM UTC, SVN revision 45260:

Avoided copying units put on map if they are temporary. (Partial fix for bug #16363.)
This brings the profile footprint of putting units on map from 20% to 10% (not counting the actual cost of creating them).

(Browse SVN revision 45260)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 02:26:13 PM UTC, comment #6:

Here is an updated callgraph after applying the 4 patches. The total time has been halved, but it is still way too long for the game to be usable. The bottleneck is now:
- 80% spent in Lua/WML,
- 50% in creating units from Lua,
- 25% in adding animations to a unit,
- 15% in creating particles.

(file #9718)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 02:05:09 PM UTC, SVN revision 45257:

Avoided copying config objects just before deleting them from units. (Partial fix for bug #16363.)
This brings the profile footprint of config copy constructor from 18% to 8%.

(Browse SVN revision 45257)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 12:24:52 PM UTC, SVN revision 45254:

Delayed further the creation of config objects. (Partial fix for bug #16363.)
This brings the profile footprint of add_anims from 30% to 24%.

(Browse SVN revision 45254)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 10:33:05 AM UTC, SVN revision 45253:

Optimized the special case [filter_wml][variables] when matching units. (Partial fix for bug #16363.)
This brings the profile footprint of matches_filter from 28% to 3%.

(Browse SVN revision 45253)

Guillaume Melquiond <silene>
Fri 06 Aug 2010 08:38:40 AM UTC, SVN revision 45252:

Sped up unit animation preparation by following all the branches at once and by lazily merging children. (Partial fix for bug #16363.)
This brings the profile footprint of prepare_animation from 44% to 6%.

(Browse SVN revision 45252)

Guillaume Melquiond <silene>
Thu 05 Aug 2010 04:15:15 PM UTC, comment #1:

I have attached the callgraph obtained while the animation is playing. There is an obvious path, assuming the graph is correct:
- 90% spent in Lua scripts (luaW_pcall),
- 66% spent in creating units (unit::unit),
- 63% spent in adding animations to these units (unit_animation::add_anims),
- 42% spent in building config objects (config::append).

(file #9705)

Guillaume Melquiond <silene>
Thu 05 Aug 2010 03:11:25 PM UTC, original submission:

I've been using WML to create units with 80+ separate animations, which are understandably laggy. What seems unusual is that when I increase the number of frames in each of those animations by a lot, without increasing the number of animations, there's still a significant increase in the lag when starting animations (an increase over the situation with 80 simple animations, that is.)

There doesn't seem to be an unusual amount of lag in the actual animations - only before an animation begins.

The attached savefile illustrates such a situation: attack the wolf with the wraith to observe the lag.

Eli Dupree <elvish_pillager>

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #9722:  animation-trace10.png added by silene (695kB - image/png)
file #9718:  animation-trace5.png added by silene (736kB - image/png)
file #9705:  animation-trace.png added by silene (968kB - image/png)
file #9702:  animation_lag_example_save.gz added by elvish_pillager (194kB - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by boucman (Updated the item)
  • -unavailable- added by silene (Updated the item)
  • -unavailable- added by elvish_pillager (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 06 Aug 2010 06:32:35 PM UTCsileneAttached File-=>Added animation-trace10.png, #9722
    Fri 06 Aug 2010 02:26:13 PM UTCsileneAttached File-=>Added animation-trace5.png, #9718
    Thu 05 Aug 2010 04:37:40 PM UTCboucmanAssigned toNone=>boucman
    Thu 05 Aug 2010 04:15:15 PM UTCsileneAttached File-=>Added animation-trace.png, #9705
    Thu 05 Aug 2010 03:11:25 PM UTCelvish_pillagerAttached File-=>Added animation_lag_example_save.gz, #9702
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup