48 |
|
#endif |
49 |
|
#endif |
50 |
|
#ifndef SORT_INTVL |
51 |
< |
#define SORT_INTVL (SORT_THRESH*8) |
51 |
> |
#define SORT_INTVL (SORT_THRESH*32) |
52 |
|
#endif |
53 |
+ |
#ifndef MAX_SORT_INTVL |
54 |
+ |
#define MAX_SORT_INTVL (SORT_INTVL<<8) |
55 |
+ |
#endif |
56 |
|
|
57 |
|
static unsigned long ambclock = 0; /* ambient access clock */ |
58 |
|
static unsigned int nambvals = 0; /* number of stored ambient values */ |
66 |
|
* claiming our own memory (copy on write). |
67 |
|
*/ |
68 |
|
#define tracktime (shm_boundary == NULL || ambfp == NULL) |
66 |
– |
#define checksort() if (ambclock > lastsort+sortintvl && \ |
67 |
– |
nambvals > SORT_THRESH) sortambvals(0) |
69 |
|
|
70 |
|
#define AMBFLUSH (BUFSIZ/AMBVALSIZ) |
71 |
|
|
201 |
|
return; |
202 |
|
} |
203 |
|
/* resort memory? */ |
204 |
< |
checksort(); |
204 |
> |
sortambvals(0); |
205 |
|
/* get ambient value */ |
206 |
|
setcolor(acol, 0.0, 0.0, 0.0); |
207 |
|
d = sumambient(acol, r, rdepth, |
587 |
|
AMBTREE oldatrunk; |
588 |
|
AMBVAL tav, *tap, *pnext; |
589 |
|
register int i, j; |
590 |
+ |
/* see if it's time yet */ |
591 |
+ |
if (!always && (ambclock < lastsort+sortintvl || |
592 |
+ |
nambvals < SORT_THRESH)) |
593 |
+ |
return; |
594 |
|
/* |
595 |
|
* The idea here is to minimize memory thrashing |
596 |
|
* in VM systems by improving reference locality. |
658 |
|
} |
659 |
|
free((char *)avlist1); |
660 |
|
free((char *)avlist2); |
661 |
< |
if (sortintvl < SORT_INTVL<<6) |
661 |
> |
/* compute new sort interval */ |
662 |
> |
sortintvl = ambclock - lastsort; |
663 |
> |
if (sortintvl > MAX_SORT_INTVL) |
664 |
> |
sortintvl = MAX_SORT_INTVL; |
665 |
> |
else |
666 |
|
sortintvl <<= 1; /* wait twice as long next */ |
667 |
|
#ifdef DEBUG |
668 |
|
eputs("done\n"); |