Permit disabling of A* neighbor cache at compile-time
Mostly to measure its effectiveness. Compile with AS_NO_NEIGHBOR_CACHE defined to disable it. The neighbor cache turns out to be useless in my tests: it eats memory without speeding up the update's distribution path assembly.
This commit is contained in:
parent
a02d3e9fc1
commit
7edcd3ea77
1 changed files with 8 additions and 0 deletions
|
@ -40,6 +40,10 @@
|
||||||
* Define AS_NO_PATH_CACHE to disable the path cache. The path cache
|
* Define AS_NO_PATH_CACHE to disable the path cache. The path cache
|
||||||
* saves a lot of work, but uses lots of memory. It should be a
|
* saves a lot of work, but uses lots of memory. It should be a
|
||||||
* significant net win, unless you run out of memory.
|
* significant net win, unless you run out of memory.
|
||||||
|
*
|
||||||
|
* Define AS_NO_NEIGHBOR_CACHE to disable the neighbor cache. The
|
||||||
|
* neighbor cache trades a modest amount of memory to save a bit of
|
||||||
|
* work. In its current form, it doesn't really make a difference.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -87,8 +91,10 @@ bp_init(void)
|
||||||
if (bp->adp == NULL)
|
if (bp->adp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
#ifndef AS_NO_NEIGHBOR_CACHE
|
||||||
if (neighsects == NULL)
|
if (neighsects == NULL)
|
||||||
neighsects = calloc(WORLD_SZ() * 6, sizeof(struct sctstr *));
|
neighsects = calloc(WORLD_SZ() * 6, sizeof(struct sctstr *));
|
||||||
|
#endif
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
@ -125,8 +131,10 @@ best_path(struct sctstr *from, struct sctstr *to, char *path, int mob_type)
|
||||||
res = as_search(adp);
|
res = as_search(adp);
|
||||||
#ifdef AS_STATS
|
#ifdef AS_STATS
|
||||||
as_stats(adp, stderr);
|
as_stats(adp, stderr);
|
||||||
|
#ifndef AS_NO_NEIGHBOR_CACHE
|
||||||
fprintf(stderr, "neighbor cache %zu bytes\n",
|
fprintf(stderr, "neighbor cache %zu bytes\n",
|
||||||
WORLD_SZ() * 6 * sizeof(struct sctstr *));
|
WORLD_SZ() * 6 * sizeof(struct sctstr *));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue