Questions about performance: Cybran build drones

18

This is a sub-topic of this topic. Please keep this topic clean and only talk about this one specific issue. Balance will not be changed - it is just an aesthetical change.

This specific topic is about the Cybran build animations. This is by far the most expensive build animation of the game, yet typically the most used one because of Hives. Lets start with some numbers.

The problem

The sim runs at 10 ticks a second, therefore we have 100ms for each tick. Let us compare some engineer numbers when they are building something:

  • 150 t1 Aeon engineers: The sim increases with 1 ms. (3.3 -> 4.2)
  • 150 t1 UEF engineers: The sim increases with 3 - 4 ms. (2.3 -> 5.8)
  • 150 t1 Cybran engineers: The sim increases with 4 ms. (2.0 -> 6.1)
  • 150 t1 Seraphim engineers: The sim increases with 2 - 3 ms (3.5 -> 5.0)

That isn't too bad. Lets try with 150 t3 engineers.

  • 150 t3 Aeon engineers: The sim increases with 1 ms. (3.4 -> 4.2)
  • 150 t3 UEF engineers: The sim increases with 4 - 5 ms (2.2 -> 6.9)
  • 150 t3 Cybran engineers: The sim increases with 10 - 11 ms (2.0 -> 12.8)
  • 150 t3 Seraphim engineers: the sim increases with 4 - 5 ms (4.0 -> 8.8)

And what about hives / engineering stations.

  • 150 t2 Kennel (upgraded): the sim increases with 7 - 9 ms (4.5 -> 12.2)
  • 150 t2 Hives (upgraded): the sim increases with 16 - 17 ms (2.2 -> 19.1)

Some notes:

  • Seraphim and Aeon engineers are more expensive by default (they start at a higher base value) because they have emitters underneath them. If those are not in vision they do not impact the sim.
  • Aeon engineers are cheapest because they always have only 1 beam emitter, regardless of tech.

The reason cybran engineers tend to be more specific is for one, and only one reason: they require a large number of additional (dummy) entities. As an example:

bb6c7775-b972-4bf9-a475-4acdfe518b5e-image.png

Each hive has drone bots. These are new units made from scratch each time the hive starts building while it doesn't have any drones at all. Each drone requires a random target on the structure it is building to create a beam. Each of these targets are (dummy) entities. Therefore for one hive you need:

  • 6 additional (indestructible) units
  • 6 additional (dummy) entities

Then we have the effects that the hive uses.

  • 6 beams from the drone to their own dummy entity.
  • 6 'spark effects' at each dummy entity.
  • 6 beams from the hives to the drones.

That means we introduce over 12 new entities (of which 6 are units) and 18 new emitters. As a comparison:

  • Aeon introduces one entity and one emitter for each tech.
  • Seraphim introduces one entity and 1 - 3 emitters, depending on the tech.

Other Cybran builders can be discussed in a similar manner - resulting in much higher entity and emitter counts than their co-workers.

A solution

The Cybran build effect is unique and I do not intent to take it out entirely as it is part of the game. However, having it in its current state can seriously slow things down especially for slower computers and laptops. (as a comparison: the computer of Cheese runs the sim almost twice as slow as my computer, by default).

What I suggest is the following:

  • We limit the number of drones not on build power, but on type. All engineers will only have 1 additional drone, instead of 1 / 2 / 3 depending on the tech. All hives will have up to 1 / 2 / 3 drones, instead of 2 / 4 / 6. Commanders and sub-commanders will have 1 / 2 / 3 drones depending on their enhancements, instead of 5 / 6 when they are fully upgraded.
  • We limit the number of unique targets. Instead of having each drone (and the engineer build arms) all have their own unique target, they all share the same target (as the engineers). With that we limit the number of entities (to 1 / builder) and the number of emitters (just 1 sparkle emitter / builder).
  • We limit the speed at which drones switch targets. Instead of having them switch target each 0.2 seconds, we lower it to 0.5. All drones switch targets at the same time, instead of each having drone switch targets on their own (this lowers the number of threads required).

All in all - the effect will be the same when you use 10 - 20 engineers or more. But - I expect it to be a lot cheaper when you use 50 - 100 engineers (or hives). My question to you all is - what do you think, and do you think it is worth changing for the more sim speed?

disclaimer: the times are related to the performance of your processor / RAM. You will have different timings, but their differences (in %) will be roughly the same

Clarifications

The Aeon and Seraphim have a higher baseline because they have emitters underneath for a hover effect. This means that the sim has more to do. That is why they start at about 3 ms, while the uef and cybran engineers start at about 2ms.

This topic is solely about the cost of buildings things. Therefore we do not look at the baseline, but at the difference between the baseline (idle engineers) and engineers assisting something.

1

Nice analysis.
I was aware of this issue but never took a closer look like you on it.

Really looks like we need to change this!

1

i was always wondering why just not making simspeed++ or quality of performance a ranked mod ?
it already solves the problem and doesn't require an official update but whatever,good stuff you put down there Jip,hopefully people will work on it or at least take it in consideration

0

I think this would significantly alter the look, more than needed... I think you should look at disguising removed sparkle effects - perhaps by one large somewhat random sparkle effect that encompasses the entire build.

Lastly I want to mention that, in 2007, Supreme Commander made me aware of subtractive 3d printing through the Cybran. Preserving that part of the look would be most important to me.

1

Personally, I think the aesthetic of cybran drones being a much a more chaotic way of building than what the other factions use is important for the game's art style/flavor. That's why I always found the simple lasers of simspeed++ lacking.

What you propose here seems to be a good compromise: We get rid of more than half the entities, without significantly altering the art style, while leaving gameplay completely untouched.

I'd say it's a good idea!

0

@rezy-noob said in Questions about performance: Cybran build drones:

i was always wondering why just not making simspeed++ or quality of performance a ranked mod ?
it already solves the problem and doesn't require an official update but whatever,good stuff you put down there Jip,hopefully people will work on it or at least take it in consideration

The simspeed++ mod doesn't actually do a whole lot. It just changes hives in a drastic manner last time I checked.

@valki said in Questions about performance: Cybran build drones:

I think this would significantly alter the look, more than needed... I think you should look at disguising removed sparkle effects - perhaps by one large somewhat random sparkle effect that encompasses the entire build.
Lastly I want to mention that, in 2007, Supreme Commander made me aware of subtractive 3d printing through the Cybran. Preserving that part of the look would be most important to me.

There will be a difference when you use one or two builders. But late game, you'll use dozens of builders. And you won't have the time to appreciate the animation anyhow. Having more performance at that time

If you have 2 - 3 engineers building something then it will still roughly look the same - random drones sending beams and sparkles at different locations. In the end, especially late game when it starts to matter, you typically build things with dozens of builders. And in those specific situations, it will feel the same but it will also be a lot faster and that is what matters.

I got a question from @CheeseBerry about not seeing emitters at all - does it still matter? When building, the answer is yes:

  • 150 T3 t3 Aeon engineers cost about 0.2 ms (!)
  • 150 hyves (upgraded) cost about 11 ms.
1

From my understanding you would modify the unit itself. Stupid question amyway, but can this optimisation be done only on a certain amount of engis?

0

@brutus5000 said in Questions about performance: Cybran build drones:

From my understanding you would modify the unit itself. Stupid question amyway, but can this optimisation be done only on a certain amount of engis?

Yes it can be. I am also working with ambient sounds and seeing how that impacts the sim. What you could do is keep track how many of a unit exists (that should be cheap to do) and act on that during unit creation (to prevent unnecessary checks during runtime). For example, you pre-define how many drones a unit should have.

Problem with this is that it will no longer be the same, all the time. And with aesthetics that are visible that may be strange.

edit: with that said, just because we can doesn't mean that I think we should do it. It introduces additional complexity to something that (in my opinion) doesn't require it.

3

Because simspeed lag is one of the worst aspects of this game, anything we can do to ameliorate the problem is a great idea. I don't care how many cybran drone bots are visible. In fact, I would probably PREFER to see a laser beam similar to aeon because it makes it a lot easier to see exactly what the hives are assisting. Sometimes you don't notice they started assisting your smd or something else unimportant when that was your lowest priority.

0

I had the same thought as Brutus. Since 1 hive alone doesn’t cause a huge simspeed problem, let’s leave it as it is and only change the animation once the number of hives hits a critical number where you can’t tell the difference anyways.

1

@askaholic said in Questions about performance: Cybran build drones:

I had the same thought as Brutus. Since 1 hive alone doesn’t cause a huge simspeed problem, let’s leave it as it is and only change the animation once the number of hives hits a critical number where you can’t tell the difference anyways.

Although one thing to consider is that this will increase the complexity of this portion of the code quite significantly. So we also have to consider if this is worth it from a maintenance stand point.

0

Im pretty sure in OG FA the number of build bots is exactly as you describe it, 1/2/3 per tech level. ACU has smth like 5?
Then FAF changed it, it was scaled by build power. Then the lag started, so it got nerfed and now with your changes we're going full circle, back to the original values 🙂

1

@sheikah That question applies to almost all performance optimisations.

2

The key performance issue with Cybran build bots is rather simple - unit count. Every one of those drones is a unit - and they are being created, and destroyed, at a rather fantastic pace. This has two long term side effects - each drone creates a new entity (unit) which has to be initialized just like any other unit - and when it's finished a task - it is destroyed. This process, of itself, is not very hard on the CPU except for the intangible effects of garbage collection.

The garbage collection process of SCFA can, by the time a game is more than 30 minutes old, consume almost 20%, or more, of all the clock cycles available to the SIM. Why ? Because the creation of new units, and new tables and variables in the code are too intensive - and the memory used must be reclaimed - only to be used again - in very quick succession.

The largest of all memory allocations in SCFA is the creation of a new unit. Anyone who has ever examined a blueprint for any unit knows just how many variables are involved - and that is the problem in a nutshell. If you reduce the creation of drones down to a modest level, you minimize this problem quite a bit. Now - in the end - it becomes a simple matter of aesthetic versus performance.

2

FAF is reusing the bots, as long as there is another target to build right away, they dont despawn.

0

Is changing the speed that drones change target from .2s to .5s purely a visual thing or is that a nerf to how quickly they can change what they’re assisting or building?

0

Rookie game engine question here: how did you evaluate the increase in time to render ? What console commands and such?

I would like to just for fun have some people I know with “cheese or potato” PCs run it, along with my own, see what happens.

Overall though, as Sprouto said, it’s almost as simple a fact that more units are generated.

2

@exselsior said in Questions about performance: Cybran build drones:

Is changing the speed that drones change target from .2s to .5s purely a visual thing or is that a nerf to how quickly they can change what they’re assisting or building?

Purely visual. It is how often they choose a random location within the building they are 'building'. The resources switches immediately. The beams of the engineer would follow right away. The drones would follow shortly after.

0

@Morax use ren_ShowNetWorkStats in the console. Spawn in 150 hives and make them assist a quantum gateway while you have essentially no income.

0

@jip Figured that would be the case, thanks! I like the ideas