Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations
Home

[Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bh@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7342) cm patch: heap-allocate the combinations
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sat, 31 Jan 2004 19:18:39 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >

On Thu, Jan 29, 2004 at 07:55:40AM -0800, Benoit Hudson wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >
> 
> > [i-freeciv-lists@xxxxxxxxxxxxx - Thu Jan 29 09:12:53 2004]:
> > 
> > On Wed, Jan 28, 2004 at 07:12:17PM -0800, Benoit Hudson wrote:
> > > 
> > > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7342 >
> > > 
> > > Right, and here's the promised patch.
> > 
> > What about runtime impact?
> 
> I covered that with "Doesn't seem to have any measurable impact
> on running time."  I can run with profiling information if you want.

Not needed.

> > Can't MAX_COMBINATIONS be removed then?
> 
> Probably.  I use it to make sure we're not runaway allocating huge
> amounts of memory, but I'm not sure that's needed.

We should add a check into fc_(re)malloc. A malloc over 20mb should be
denied.

> > > +#if SHOW_CM_STORAGE_USED
> > > +static void report_cm_storage_used(void)
> > > +{
> > > +  int i, sum=0;
> > > +  for(i=0; i<=MAX_FIELDS_USED; ++i) {
> > > +    sum += cache3.results[i].ncombinations_allocated
> > > +      * sizeof(struct combination*);
> > > +    sum += cache3.results[i].ncombinations
> > > +      * sizeof(struct combination);
> > > +  }
> > > +  sum += sizeof(cache3);
> > > +  freelog(LOG_NORMAL, "CM: cache3 uses %d bytes", sum);
> > > +  /* we should compute the cache1 and cache2 usage as well. */
> > > +}
> > > +#endif
> > 
> > > +#if SHOW_CM_STORAGE_USED
> > > +  report_cm_storage_used();
> > > +#endif
> > 
> > If you move the #if inside the function you only have the #if one
> > time. IMHO better even if you call an empty function.
> 
> Sure.  I think even gcc is smart enough to optimize out the empty
> function anyway.  I'll work out an updated patch later today, or tomorrow.

It won't do it for the standard -O2. It doesn't make the call nor
produce code for the function with -O3.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Heuer's Law: Any feature is a bug unless it can be turned off."




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