Question about WML optimization

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Dugi
Posts: 4931
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Question about WML optimization

Post by Dugi » June 14th, 2013, 7:27 am

Can you check how big is the save file? Although I have not found any indications for it, there might be a macro bloat somewhere and might generate really huge save files, whose generation might possibly take several seconds. Save files larger than one megabyte can be the cause.

Important note: macros, of 'the #define things', will only made the code more readable for humans or taking less place on the disk, they aren't likely to optimalise something.

Btw, your scenario looks quite interesting.

myav
Posts: 85
Joined: August 23rd, 2008, 12:53 pm

Re: Question about WML optimization

Post by myav » June 14th, 2013, 7:37 am

Max wrote:related topic: http://forums.wesnoth.org/viewtopic.php?f=21&t=38880

how big are your uncompressed save games?
1122 kb
Max wrote:i would assume that the lag is caused by preprocessing your scenario (macros). if you load a save game it's already cached.
I checked this theory. I created an event "side 3 turn" with 500 lines of different code and variables, after this I copied its one thousand times (and scenario became in 3 times larger than now). After this, I have changed names of these events (that they were different)

But I didn't receive even the slightest freezing from it at the beginning of turns.

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Question about WML optimization

Post by Max » June 14th, 2013, 7:47 am

run it once with --log-debug=all. the output is usually huge, but it's probably easier than trying out different log domains.

myav
Posts: 85
Joined: August 23rd, 2008, 12:53 pm

Re: Question about WML optimization

Post by myav » June 14th, 2013, 7:49 am

Oh sorry )) I was wrong.
1122 kb size was when I have removed all defines (but all my events remained (12.000 rows of a code))
But if not to delete defines uncompressed size of save is - 42.866 kb. Compressed - 909kb.

if a problem here how to solve it? without deleting everything

User avatar
Dugi
Posts: 4931
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Question about WML optimization

Post by Dugi » June 14th, 2013, 8:11 am

43 megabytes is surely a problem. Creating a compressed save file from this took like 5-10 seconds on my machine, always at the beginning of side 1 turn.

Because you probably don't have any custom units there, I suppose that the cause is macro bloat. That is, long macros possibly containing other (long) macros used a lot of times. They should be replaced by custom events, fire_event used instead of macro calls and variables instead of arguments. It is less comfortable, a bit slower, but it really decreases the size of save files. Read the topic Max showed you for more information.

myav
Posts: 85
Joined: August 23rd, 2008, 12:53 pm

Re: Question about WML optimization

Post by myav » June 14th, 2013, 11:50 am

Thanks to all for help))

I redid as the "events" almost all the macros (which are often repeated in other macros) and size of saves was decreased in 10 times.
After this, new turns freezes only for 2-3 seconds, but it's nothing if to compare with the old 10-15 seconds.

Post Reply