Currently Online

Latest Posts

Topic: Low FPS

ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-07, 17:30

Tibor wrote:

What I am afraid about caching of pre-calculates routed is huge number of combinations that would need to be cached.

It's not that bad. Only requested routes get cached, and for them only next flag and final destination. The resulting number of combinations scales in parallel with the economy (just like the increased number of wares does now), it doesn't skyrocket.


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-07, 17:49

ypopezios wrote:

Tibor wrote:

What I am afraid about caching of pre-calculates routed is huge number of combinations that would need to be cached.

It's not that bad. Only requested routes get cached, and for them only next flag and final destination. The resulting number of combinations scales in parallel with the economy (just like the increased number of wares does now), it doesn't skyrocket.

Oh, perhaps this is not exactly what you mean, but I can imagine that each flag has dictionary (map) of target:road (coming from this flag), so a ware sitting on a flag going to a productionsite at 144x54, would just look up next road for the target 144x54 and be moved over the road to the next flag, and do the same there.

If the map does not contain target coordinates, the path would need to be calculated.

So if we have 400 flags, each one would keep map of 50 targets...

But the way of invalidating the cache would be bit complicated.

But such mechanism would be very interesting...


Top Quote
ypopezios
Avatar
Joined: 2018-04-20, 00:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-05-07, 17:58

Tibor wrote:

But such mechanism would be very interesting...

It is very interesting and has room for further optimizations. But we have to keep this thread on topic, so I'm stopping here. If someone opens a new thread, feel free to invite me.


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-07, 18:06

ypopezios wrote:

Tibor wrote:

But such mechanism would be very interesting...

It is very interesting and has room for further optimizations. But we have to keep this thread on topic, so I'm stopping here. If someone opens a new thread, feel free to invite me.

Yes, considering how fast your branch is being developed we have plenty of time face-wink.png


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2018-05-07, 22:00

@Tibor/GunChleoc

Which file(s) is(are) responsible for path finding and ware routing?


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-07, 22:06

einstein13 wrote:

@Tibor/GunChleoc

Which file(s) is(are) responsible for path finding and ware routing?

You can start in economy/economy.cc with Supply* Economy::find_best_supply() function


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2018-05-11, 17:58

Hey!

I have said to myself: let's try this game one more time. On the best CPU I have (and recent DEV from Tino).

So I have simplified a bit my economy by destroying unnecessary roads (dead ends after dismantling buildings). And the game run again well. So what changed?

  1. Some buildings finished the construction (about 40 of them?)
  2. The roads are now simplified (unnecessary dead ends are cut)
  3. Many resources finally got to warehouses
  4. Part of buildings are idling

So my question is about point 1: is animation of building up CPU-intensive?

Since I have a Widelands game with border situation (little more CPU will cause lags), I can test any scenario you want.


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-05-12, 09:58
  1. I don't know - somebody would have to profile this.

Busy indexing nil values

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-05-12, 22:21

OK, so I profiled the very first savegame in the thread and here are the results:

99.0 0.00 114.49 main
99.0 0.00 114.47 1 WLApplication::run()
99.0 0.00 114.43 1 Widelands::Game::run_load_game(std::__cxx11::basic_stri
96.3 0.00 111.39 1 Widelands::Game::run(UI::ProgressWindow*, Widelands::Ga
90.3 0.00 104.39 1 UI::Panel::Returncodes UI::Panel::run<UI::Panel::Return
90.3 0.07 104.32 1 UI::Panel::do_run()
55.5 0.01 64.17 6329+69769 UI::Panel::do_think()
55.5 0.00 64.17 6329 InteractivePlayer::think()
55.4 0.00 64.08 6329 InteractiveBase::think()
55.4 0.00 64.00 6329 Widelands::Game::think()
55.4 0.00 64.00 6329 Widelands::CmdQueue::run_queue(int, unsigned int&)
55.3 0.00 63.93 70487 Widelands::Economy::find_route(Widelands::Flag&, Widela
55.3 0.06 63.87 70487 Widelands::Router::find_route(Widelands::RoutingNode&,
54.0 0.00 62.38 5538 Widelands::CmdCallEconomyBalance::execute(Widelands::Ga
54.0 0.00 62.38 5538 Widelands::Economy::balance(unsigned int)
53.9 0.00 62.37 35 Widelands::Economy::balance_requestsupply(Widelands::Ga
53.9 0.00 62.32 35 Widelands::Economy::process_requests(Widelands::Game&,
53.9 0.07 62.25 8697 Widelands::Economy::find_best_supply(Widelands::Game&,
53.9 0.97 61.29 33082088 Widelands::RouteAStar<Widelands::AStarEstimator>::step
29.8 6.78 27.69 72027618 CookiePriorityQueue<Widelands::RoutingNode, Widelands:
24.9 0.19 28.65 33082088 CookiePriorityQueue<Widelands::RoutingNode, Widelands:
22.2 1.21 24.42 32991661 CookiePriorityQueue<Widelands::RoutingNode, Widelands:
21.9 0.19 25.10 43463400 Widelands::RouteAStar<Widelands::AStarEstimator>::push
21.0 0.02 24.29 12341+284453 <cycle 18 as a whole>
21.0 0.01 24.23 148397 UI::Panel::do_draw_inner(RenderTarget&) <cycle 18>

Third column is percentage of CPU time per function and all functions called by it.

So the winner here is Economy::balance_requestsupply() and related Economy::find_best_supply() function as I expected.

Also I loaded the game with my version for AI training (that includes also economy patch) and in auto_speed mode it runs in range of 2x - 7x speed, so not bad at all


Top Quote
einstein13
Avatar
Topic Opener
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2018-05-13, 00:32

Thank you, Tibor for that!

I have noticed that the game is slowing down especially when you build something up because the economy is trying to find at once several different types of wares.

Second time I have noticed that when I made a short bypasses (traffic jams were around), the game speeded up.

So my next step is to think how the ware transportation system should be faster (as CPU needs). For sure that will be a very big step forward and I need some time to solve the problem. Build21 is my milestone for that face-wink.png .

Edited: 2018-05-13, 00:32

einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote