[Freeciv-Dev] Re: Profiling Civserver again
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Trent Piepho wrote:
>
> On Tue, 24 Jul 2001, Ross W. Wetmore wrote:
> > 2) TRUE, map and map_adjust_x() will need to be defined in all functions
> > that call the macro, whereas they weren't for the function call.
>
> Of course the function prototype for normalize_map_pos() is in the same header
> file that defines map_adjust_x(), so that shouldn't be a problem.
>
> But really, you're just covering up the real inefficiency. It would be more
> productive to figure out why map coordinates get normalized so many times, and
> reduce that number.
I draw your attention to the following lines from the gprof run:
[12] 20.4 100.19 102.49 159008 really_generate_warmap [12]
38.41 0.00 797302800/948124931 normalize_map_pos
[32]
This says that of the 950 million times normalize_map_pos was called 800
million of them were in really_generate_warmap. About 40% as much time
was spent in normalize_map_pos as was spent in really_generate_warmap()
itself.
In other words, the following line accounts for about 4% of all Freeciv
server CPU usage:
http://www.freeciv.org/lxr/source/server/gotohand.c?v=cvs#L313
Aside from being astounding, this is totally unnecessary and can easily
be improved on.
With the attached patch, the use of normalize_map_pos is dropped and the
normalization is handled manually. This could be improved on much more
- the normalization is still done for each of the 8 adjacent spots - but
it is more efficient than the function call or even a standard macro
would be.
jason Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.99
diff -u -r1.99 gotohand.c
--- server/gotohand.c 2001/06/29 19:39:06 1.99
+++ server/gotohand.c 2001/07/25 06:14:57
@@ -308,9 +308,9 @@
while (get_from_mapqueue(&x, &y)) {
ptile = map_get_tile(x, y);
for (dir = 0; dir < 8; dir++) {
- x1 = x + DIR_DX[dir];
+ x1 = (x + DIR_DX[dir] + map.xsize) % map.xsize;
y1 = y + DIR_DY[dir];
- if (!normalize_map_pos(&x1, &y1))
+ if (y1 < 0 || y1 >= map.ysize)
continue;
switch (move_type) {
- [Freeciv-Dev] Profiling Civserver again, Paul Zastoupil, 2001/07/24
- [Freeciv-Dev] Re: Profiling Civserver again, Vasco Alexandre Da Silva Costa, 2001/07/24
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/24
- [Freeciv-Dev] Re: Profiling Civserver again, Trent Piepho, 2001/07/24
- [Freeciv-Dev] Re: Profiling Civserver again, Jason Dorje Short, 2001/07/24
- [Freeciv-Dev] Re: Profiling Civserver again,
Jason Dorje Short <=
- [Freeciv-Dev] Re: Profiling Civserver again, Reinier Post, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Thue, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Jason Dorje Short, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Trent Piepho, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Gregory Berkolaiko, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Jason Dorje Short, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Paul Zastoupil, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/25
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/25
|
|