News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Optimization: save calls to karte_t::lookup

Started by Dwachs, February 17, 2013, 03:18:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

Here is a patch to save calls to karte_t::lookup during vehicle movement. The idea is that the routines hop() and betrete_feld() return the grund_t* pointer to the tile the vehicle moved to. Currently, when a vehicle changes to another tile karte_t::lookup is called multiple times during the chain of betrete_feld() calls. This patch saves A LOT of calls to karte_t::lookup. (More than 50% of calls for program without graphics)

TurfIt

Is it intentional that citycars no longer count as convoys passing for the waystats?
Otherwise, looks ok. I did a quicky profile using the yoshi game and my split apart/instrumented sync_step work patch which shows ~0.5% improvement to the overall sync_step time. ~1% faster for convois, ~2% citycars, but ~1.5% slower for pedestrians. Strange that last...

I'd appreciate a quick commit on this if possible, it's smack dab in the middle of my work on multithreaded sync_step which I've finally got around to resuming.

Dwachs

here is an update.

Now, citycars count again as convoys for way stats. I removed the check at the beginning of stadtauto_t::hop(), as the very same check is already done in hop_check.

TurfIt

waystats ok now. Repeated the profile - now 0.8% overall, 1.5% convoy, 0% citycar, 0.5% faster peds. Patch/nopatch difference is down in the noise of what I can measure. But, it's theoretically faster, and does hint at being measurably faster.

Dwachs