How bad is to include macro files in FOCS files?

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

How bad is to include macro files in FOCS files?

#1 Post by Oberlus »

This is in several places (mostly policies or macros called from them):

Code: Select all

// priority = [[DEFAULT_PRIORITY]]  // want to avoid needing to include the priorities-defining macro in all policies...
That made me wonder if it is bad for performance including many/long macro files in FOCS files.

For example, I'm working in a rework of the priorities macros for clarity when scripting (to avoid unintended/unexpected orderings in application of additive/scaling effects), and I could tailor the DEFAULT_PRIORITY value (and the rest around it) to coincide with current use of most Target meters or most (Current) meters. Since many effects on Target and Current meters use (implicitly or explicitly) DEFAULT_PRIORITY, and I'm trying to separate into two stages all target meters from all current meters, if I pick the later (DEFAULT_PRIORITY for current meters), most policy files would require to include the priorities macro file because they would be using an explicit priority macro (TARGET_DEFAULT_PRIORITY). If I pick the former, other files would be the ones not being able to use the implicit DEFAULT_PRIORITY.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: How bad is to include macro files in FOCS files?

#2 Post by Geoff the Medio »

Don't know... you should probably test it.

Ophiuchus
Programmer
Posts: 3427
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: How bad is to include macro files in FOCS files?

#3 Post by Ophiuchus »

Oberlus wrote: Tue Oct 13, 2020 4:03 pm That made me wonder if it is bad for performance including many/long macro files in FOCS files.
macros are only visible at parse-time, so at runtime there wont be any difference.

+1 to what geoff said ;) you could measure startup time (my guess is you wont see much of a difference)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: How bad is to include macro files in FOCS files?

#4 Post by Geoff the Medio »

You can check parse times in the log files when starting up the client... eg:

Code: Select all

02:35:47.152348 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_EAXAW.focs.txt" time:     51.1 ms
02:35:47.196361 {0x00004b00} [debug] timer : scopedtimer.cpp:48 : parse_file "EXPERIMENTOR_OUTPOST.focs.txt" time:       29 ms
02:35:47.199362 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_EGASSEM.focs.txt" time:     47.2 ms
02:35:47.210364 {0x0000496c} [debug] timer : scopedtimer.cpp:48 : Techs Parsing time:      723 ms
02:35:47.246372 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_ETTY.focs.txt" time:     46.7 ms
02:35:47.290384 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_EXOBOT.focs.txt" time:       44 ms
02:35:47.334394 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_EXPERIMENTOR.focs.txt" time:     43.8 ms
02:35:47.377404 {0x00004f98} [debug] timer : scopedtimer.cpp:48 : parse_file "SP_FIFTYSEVEN.focs.txt" time:     42.8 ms
02:35:47.403330 {0x00004b00} [debug] timer : scopedtimer.cpp:48 : Buildings Parsing time:      917 ms
There will probably be some variation between runs due to it running multithreaded.

Ophiuchus
Programmer
Posts: 3427
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: How bad is to include macro files in FOCS files?

#5 Post by Ophiuchus »

Geoff the Medio wrote: Thu Oct 15, 2020 8:47 pm There will probably be some variation between runs due to it running multithreaded.
could one restrict it to a single thread?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: How bad is to include macro files in FOCS files?

#6 Post by Geoff the Medio »

Ophiuchus wrote: Fri Oct 16, 2020 12:01 pm
Geoff the Medio wrote: Thu Oct 15, 2020 8:47 pm There will probably be some variation between runs due to it running multithreaded.
could one restrict it to a single thread?
In https://github.com/freeorion/freeorion/ ... ing.h#L106 maybe change from launch::async to launch::deferred ?

See: https://en.cppreference.com/w/cpp/thread/launch

Post Reply