Stellaris

Stellaris

! Performance Optimization for Some Mods[abandon]
neptunehs  [developer] Jan 13, 2023 @ 4:59am
For those who want to know what this mod doing
1.espionage_operation.operation_gpm_steal_relic.potential (Guilli's Planet Modifiers and Features)
change all opinion_level trigger to is_attitude_to trigger

2.decision.decision_acot_emissary_landing.potential
decision.decision_deploy_phanon_operative.potential (Ancient Cache of Technologies)
add prerequisites

3.technology.gpm_tech_ringworld_XXX.potential (Guilli's Planet Modifiers and Features)
change
any_planet_within_border = {
gpm_is_planet_class_ringworld = yes
is_colony = yes
}
to
any_planet_within_border = {
is_colony = yes
gpm_is_planet_class_ringworld = yes
}

4.decision.decision_gpm_machine_world_core_relic.potential (Guilli's Planet Modifiers and Features)
change potential,first check space_owner

5.decision.gpm_decision_dig_for_precursor_artifacts.potential (Guilli's Planet Modifiers and Features)
change potential order

6.event.ag_ancient.2102.immediate.effect(Ancient Empire)
Add triggers,but I don't know if this trigger is right

7.event.mem_wpdr.1.immediate.effect(More events Mod)
Rewrite it to use on_action other than triggers every month.
Last edited by neptunehs; Feb 6, 2023 @ 6:41am
< >
Showing 1-4 of 4 comments
Ulthar Jan 13, 2023 @ 8:18am 
If we don't read code, could you explain this to point by point of what it does?

Example would be on item one, does it get rid of an unneccesary calculation?
Last edited by Ulthar; Jan 13, 2023 @ 8:19am
neptunehs  [developer] Jan 15, 2023 @ 2:49am 
@Ulthar Ah...I think I must reply to you with my mother language
===============================================
首先,我们需要知道的事情有:
1.这游戏所有的AND判断,都是从第一个条件开始,碰到一个false,后续的不再判断,包括隐藏的AND比如potential,possible
2.这游戏存在部分语句的性能较差,典型的是espionage_operation.operation_gpm_steal_relic.potential 里使用的opinion_level,跟所有跟megastructure有关的语句
3.部分地方的potential跟possible判断是每天执行的,比如casus_belli跟decision
4.同样,部分地方进行判断的对象比较多,比如decision是对所有的星球,casus_belli虽然是对所有的国家,但如果你在casus_belli里使用了需要对这个国家的所有船只甚至人口进行判断的句子,相当于你对整个游戏的所有船只甚至人口进行判断,哪怕每次判断占用的计算资源非常少,最后都将非常可观
5.但是,不管是对多少个对象进行判断,如果使用的是flag,那资源消耗均可以忽略不计
6.从3.6开始,所有没有MTTH的event均会被报错,这些均是需要进行现代化的语句

因此,这个mod做的事情主要是,使用控制台中的script_profiling语句,找出明显运行时间较长的语句,然后做如下的事情
1.改写语句。将opinion_level跟megastructure之类的计算性能比较差的语句换成效果接近的语句,或者将判断移到定时(非每天)执行的event并通过flag传导到casus_belli之类的每天执行的地方。但不管如何只是接近,因此可能会有结果上的损失。
2.调整AND语句中的语句顺序,将会导致结果减少最多同时不是性能较差的语句放前面,script_trigger系的均放最后。这个理论上不会导致结果上的损失。
3.将ai_weight中factor=0的放到possible中,因为ai_weight严格来说是OR语句不是AND语句。这个理论上不会导致结果上的损失。
4.(这个主要是LEX太旧了,没有现代化导致的)将部分没有MTTH的event改为每月发生一次。

另外 还顺便修正了两个Gigastructural Engineering & More (3.6)的疑似bug。
Last edited by neptunehs; Jan 15, 2023 @ 3:02am
neptunehs  [developer] Jan 15, 2023 @ 2:49am 
Then machine translate:
=============================================
First, we need to know the following things.
1. All the AND condition in this game start from the first condition, encounter a false, the subsequent ones are no longer judged, including hidden ANDs such as potential, possible
2. The game has some statements of poor performance, typically espionage_operation.operation_gpm_steal_relic.potential in the use of the opinion_level, and all the statements related to the megastructure
3. Some of the potential and possible judgments are executed daily, such as casus_belli and decision.
4. Similarly, some places have more objects for judgment, for example, decision is for all planets, and casus_belli is for all countries, but if you use a sentence in casus_belli that requires judgment on all ships and even population of this country, it is equivalent to judgment on all ships and even population of the whole game, even if each time Even if the computational resources used for each judgment are very small, it will be very significant in the end
5. However, no matter how many objects are judged, if flags are used, the resource consumption is negligible.
6. Since 3.6, all events without MTTH will be reported as errors, and these are the statements that need to be modernized.

So, what this mod does is to use the script_profiling statement in the console to find out which statements take longer to run, and then do the following
1. Rewrite the statements. Replace the statements that have poor computational performance like opinion_level and megastructure with statements that are close, or move the judgment to a timed (non-daily) event and pass it through flag to a daily execution like casus_belli. But no matter how it is just close, so there may be a loss in results.
2. Adjusting the order of the statements in the AND statement will result in the largest reduction in results while the statements that are not poor performers are placed first and the script_trigger ones are placed last. This will theoretically not lead to any loss in results.
3. Put the ones with factor=0 in ai_weight into possible, because ai_weight is strictly an OR statement, not an AND statement. This theoretically does not lead to loss of results.
4. (This is mainly caused by the fact that LEX is too old and not modernized.) Change some events that do not have MTTH to occur once a month.

In addition, two suspected bugs in Gigastructural Engineering & More (3.6) have been fixed in the meantime.
Last edited by neptunehs; Jan 15, 2023 @ 3:01am
neptunehs  [developer] Jan 15, 2023 @ 2:54am 
And for item one, it has difference calculation method,not get rid
< >
Showing 1-4 of 4 comments
Per page: 1530 50