--- ray/src/hd/rholo.c 1999/01/20 13:28:49 3.47 +++ ray/src/hd/rholo.c 1999/02/10 16:24:07 3.49 @@ -14,15 +14,20 @@ static char SCCSid[] = "$SunId$ SGI"; #include #include -#ifndef RTFLUSH -#define RTFLUSH 0 /* flush one at a time in batch */ -#endif #ifndef FRAGWARN #define FRAGWARN 20 /* fragmentation for warning (%) */ #endif #ifndef MAXQTIME #define MAXQTIME 5 /* target maximum seconds in queue */ #endif + /* manual cache flushing frequency */ +#ifndef RTFLUSH +#if MAXQTIME +#define RTFLUSH (300/MAXQTIME*totqlen) /* <= 5 minutes */ +#else +#define RTFLUSH (50*totqlen) /* just guess */ +#endif +#endif /* the following must be consistent with rholo.h */ int NVARS = NRHVARS; /* total number of variables */ @@ -55,7 +60,7 @@ long nraysdone = 0L; /* number of rays done */ long npacksdone = 0L; /* number of packets done */ PACKET *freepacks; /* available packets */ -int totqlen; /* maximum queue length when full */ +int totqlen; /* maximum queue length (number of packets) */ char *sigerr[NSIG]; /* signal error messages */ @@ -318,13 +323,14 @@ rholo() /* holodeck main loop */ if (reporttime > 0 && t >= reporttime) report(t); /* figure out good packet size */ + pksiz = RPACKSIZ; #if MAXQTIME - pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L)); - if (pksiz < 1) - pksiz = 1; - else if (pksiz > RPACKSIZ) + if (!chunkycmp) { + pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L)); + if (pksiz < 1) pksiz = 1; + else if (pksiz > RPACKSIZ) pksiz = RPACKSIZ; + } #endif - pksiz = RPACKSIZ; idle = 0; /* get packets to process */ while (freepacks != NULL) { p = freepacks; freepacks = p->next; p->next = NULL; @@ -516,13 +522,8 @@ PACKET *pl; p->nr*sizeof(RAYVAL)); if (outdev != NULL) /* display it */ disp_packet((PACKHEAD *)p); - if (hdcachesize <= 0) { -#if RTFLUSH - if (outdev == NULL) - hdfreebeam(hdlist[p->hd], p->bi); -#endif + if (hdcachesize <= 0) n2flush++; - } nraysdone += p->nr; npacksdone++; p->nr = 0; @@ -530,19 +531,11 @@ PACKET *pl; p->next = freepacks; /* push onto free list */ freepacks = p; } -#if MAXQTIME - if (n2flush > 300/MAXQTIME*totqlen) { -#else - if (n2flush > 50*totqlen) { -#endif -#if RTFLUSH - hdsync(NULL, outdev!=NULL); /* sync beams & directories */ -#else + if (n2flush > RTFLUSH) { if (outdev != NULL) hdsync(NULL, 1); else hdflush(NULL); -#endif n2flush = 0; } }