Periodic Map Lag

Level 5
Joined
Jul 15, 2018
Messages
112
Hello,

The map I am currently working on is experiencing 2 kinds of lag.

  1. A lag spike during map initiation.
  2. Periodic small frame stops ~4 seconds

I was planning on adding a cutscene to the start of the map, depending on the issue with initialization i'm not sure if it will help or hurt the initiation lag.

Can I have some help figuring out what is causing the issue?
 

Attachments

  • Medieval Villagers 1.09.w3x
    6.3 MB · Views: 38
Level 9
Joined
Apr 23, 2011
Messages
528
1. Normal if you have to set a lot of things on map init. Usually, big maps use a black fade (with a cutscene and/or the text "LOADING") at the first few seconds then fade in so it's not noticeable.
2. Check your triggers which periodically fire every 4 seconds, it could be a leak or it's doing something inefficiently.
 

Dr Super Good

Spell Reviewer
Level 60
Joined
Jan 18, 2005
Messages
26,837
My analysis shows the following potential causes.
  • House Rebelion: This trigger picks all units on the entire map, twice, every 20 seconds. Picking all units on the entire map is an expensive operation, especially on larger maps with lots of units. Possibly minor handle index leaks but I doubt that makes a difference.
  • Town Hall taxes: This trigger picks all units on the entire map once. Unknown execution rate. Possibly minor handle index leak but I doubt that makes a difference.
  • Wages: This trigger picks all units on the entire map once, every 60.27 seconds. Possibly minor handle index leak but I doubt that makes a difference.
  • population movement: This trigger might iterate a lot of units and has potentially complex logic. Worth noting that the event likely does not work how the author thought it would since the random number for period is computed only once at map initialization and from then on the trigger has a fixed period of that computed random number that never changes for the rest of the game.
  • population refresh: This trigger creates units periodically. I am unsure of how many but unit creation can be expensive, especially if placed inside collision or unpathable areas.
  • Item clear: This trigger picks every item in playable map area. However I do not think it is a major problem since the trigger itself is designed to remove items after a while so it should not reach a state where it causes significant frame drops.
  • Spawn Main: This trigger has complex logic iterative periodically fired every 61.23 seconds. Make sure it is only iterating as much as it has to and not that some logic error causes its complexity to increase more than intended as the game progresses.
  • Periodic merged: This trigger is very expensive as it runs complex logic on every unit on the entire map every second. Some of these units can trigger other iterations over nearby units.
 
Level 24
Joined
Feb 27, 2007
Messages
3,885
Worth noting that the event likely does not work how the author thought it would since the random number for period is computed only once at map initialization and from then on the trigger has a fixed period of that computed random number that never changes for the rest of the game.
To fix this:
  • Events
    • Time - Elapsed game time is <however long until this trigger should run the first time> seconds
    • Time - PopMoveTimer expires
  • Conditions
  • Actions
    • -------- all normal actions here --------
    • Time - Start PopMoveTimer as a one-shot timer that will expire in (random number between X and Y) seconds
 
Top