Latest Posts

Topic: Performance discussion

Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-03-24, 20:29

Hi,

when I profiled the game a bit I noticed that function map::find_reachable_immovables takes quite a lot CPU time in late stages and on big maps. When I insterted some printfs to the code I noticed a peculiar thing.

Some buildings/workers that scans the teritory (for example for stones, or free spots to seed the trees) - in case when the search is unsucessul, repeats the search immediatelly - so many times in a second. This means futile overhead and does not make much sense. When stones are gone, or there is no game in vicinity... - I think there could be delay like 5 seconds, or even 1 second would improve the situation much.

Anybody familiar with that part of code?


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2015-03-25, 08:12

I'm not really. There should be a function run_findobject somewhere in logic/worker_program. You would have to find out how it is called and do something there, or build the delay directly into the function itself.


Busy indexing nil values

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-03-25, 20:43

GunChleoc wrote:

I'm not really. There should be a function run_findobject somewhere in logic/worker_program. You would have to find out how it is called and do something there, or build the delay directly into the function itself.

I allready spent some time looking at the code - for me it is total mess. I just hoped there is somebody who knows and will be able to fix it easily.

In fact I made some progress and forced task_idle to stonemason, it was fine CPU-wise, but % of utilization went up as successful "task_idle" contributed to statistics as success. (While there were no stones nearby...)

So... I will see ...


Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2015-03-25, 21:45

In fact I made some progress and forced task_idle to stonemason, it was fine CPU-wise, but % of utilization went up as successful "task_idle" contributed to statistics as success. (While there were no stones nearby...)

If you changed it in the conf files, adding the line return=skipped at the end of the program should do the job.


"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-03-25, 22:01

I am not sure, I want to achieve:

- add a delay after such failed job (1-5 seconds)
- "skipped" is not recorded in statistics, so such building would preserve some performance percent while in fact it does nothing. So "failed" result is needed for statistics...


Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2015-03-26, 17:27

Then try return=failed face-grin.png

The code from the quarry:

[work]
worker=cut   # This order is on purpose so that the productivity
sleep=25000  # drops fast once all stones are gone.

I reversed the order of the two statements some time ago. Before, the quarry slept 25 s before the productivity decreased if there were no stones left, which means that it took 500 s (4 min 20 s) until the productivity had reached zero. In this time, no stones were produced, so the statistic was misleading.

Now the quarry checks every 50 ms (that's in C++, SirVer said) whether there are stones, keeping the CPU busy. But changing it program to

[work]
sleep=1000
worker=cut   # This order is on purpose so that the productivity
sleep=24000  # drops fast once all stones are gone.

should solve the problem. For balancing reasons, the numbers should add to 25000.


"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-03-26, 20:24

I again spent quite a lot time trying to understand that C++ code and then I noticed that only barbarians and atlanteans quarries behaves badly and emporian ones works fine. Peculiar.

And the difference is in conf files, the way how programs are defined.

If I open the bug report, will somebody volunteer to fix these conf files?

I will keep looking at other potential performance problems, perhaps there will be another possibilities how to reduce CPU use...


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2015-03-26, 22:13

Filing a bug report is a good idea, even if nobody should have the time right now to fix it.


Busy indexing nil values

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2015-03-26, 22:41

This si something that does not require serious coding skills so perhaps..


Top Quote