Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: inlining functions
Home

[Freeciv-Dev] Re: inlining functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: inlining functions
From: Markus Linnala <maage@xxxxxxxxx>
Date: 20 Aug 2001 10:41:31 +0300
Reply-to: Markus Linnala <maage@xxxxxxxxx>

I propose, we make configure option --use-inline.

If you have this option, we do something like:

#if USE_INLINE
#define INLINE static inline
#else
#define INLINE
#endif

And also if we are using gcc, add compiler option -Winline

Then we need to find out what functions to inline. I think you
can have reasonable information by profiling.

Here is some profiling data.
------------------------------------------------------------------------
 11.47      4.22     4.22       22   191.82   330.72  check_fow
  8.29      7.27     3.05   602241     0.01     0.01  sync_cities
  7.75     10.12     2.85 130288264     0.00     0.00  get_player
  6.74     12.60     2.48   602261     0.00     0.02  unfog_area
  5.46     14.61     2.01 33204470     0.00     0.00  map_get_tile
  5.03     16.46     1.85 24787174     0.00     0.00  map_get_player_tile
  4.73     18.20     1.74 16303894     0.00     0.00  map_get_city
  3.45     19.47     1.27       30    42.33    63.06  player_save
  3.10     20.61     1.14 26072111     0.00     0.00  find_genlist_position
  3.10     21.75     1.14 25908574     0.00     0.00  tech_exists
  2.88     22.81     1.06   604407     0.00     0.02  really_unfog_area
  2.36     23.68     0.87 26071513     0.00     0.00  genlist_iterator_init
  2.17     24.48     0.80 15213916     0.00     0.00  map_get_known
  1.85     25.16     0.68     1600     0.42     0.75  really_generate_warmap
  1.66     25.77     0.61    76837     0.01     0.02  city_desirability
  1.60     26.36     0.59  4830514     0.00     0.00  map_get_terrain
  1.49     26.91     0.55   624348     0.00     0.00  shared_vision_change_seen
  1.47     27.45     0.54  5491143     0.00     0.00  map_get_sent
  1.33     27.94     0.49  9138043     0.00     0.00  get_invention
  1.33     28.43     0.49  1990256     0.00     0.00  map_get_special
  1.28     28.90     0.47  3407921     0.00     0.00  map_get_continent
  1.14     29.32     0.42   941694     0.00     0.00  myrand
  1.11     29.73     0.41  2841846     0.00     0.00  food_weighting
  1.11     30.14     0.41   614127     0.00     0.00  send_NODRAW_tiles
  1.01     30.51     0.37    51517     0.01     0.02  find_prerequisites
  1.01     30.88     0.37      408     0.91     3.39  ai_select_tech
  1.01     31.25     0.37      297     1.25     3.39  ai_manage_explorer
------------------------------------------------------------------------

I guess we should inline only inlineable functions and only
those that are called a lot. By this data I think we should
inline all functions that are called more than 10000000 times.

To make things work, we should split inline functions to
separate files, forexample 'map_inl.h'. Move all inlined calls
there. And include it where needed. I guess we should make
guards like:

#if USE_INLINE || AT_MAP_C

INLINE struct tile *map_get_tile(....

#endif

At map.c we should also include map_inl.h like:

#define AT_MAP_C 1
#include "map_inl.c
#undef AT_MAP_C

That way we don't need extra guard everywhere else.

-- 
//Markus


[Prev in Thread] Current Thread [Next in Thread]