|
|
@ -159,7 +159,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc |
|
|
|
uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tablesize,uint8_t *key,int32_t keylen,uint32_t setind,void *refdata,int32_t refsize,struct iguana_ramchain *ramchain) |
|
|
|
{ |
|
|
|
static uint8_t masks[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; |
|
|
|
int32_t i,j,x,n,modval,offset; int64_t bitoffset; uint8_t *ptr; uint32_t *table; |
|
|
|
int32_t i,j,x,n,modval; int64_t bitoffset; uint8_t *ptr; uint32_t *table; |
|
|
|
if ( tablesize == 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_sparseadd tablesize zero illegal\n"); |
|
|
@ -185,29 +185,23 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl |
|
|
|
} |
|
|
|
printf("tableentries.%d\n",n); |
|
|
|
} |
|
|
|
bitoffset = (ind * width); |
|
|
|
ramchain->sparsesearches++; |
|
|
|
if ( 0 && setind == 0 ) |
|
|
|
printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); |
|
|
|
if ( (ramchain->sparsesearches % 10000000) == 0 ) |
|
|
|
printf("%7d.[%-2d %8d] %5.3f sparse searches.%-10ld iters.%-10ld hits.%-10ld %5.2f%% max.%ld\n",ramchain->height,width,tablesize,(double)ramchain->sparseiters/(1+ramchain->sparsesearches),ramchain->sparsesearches,ramchain->sparseiters,ramchain->sparsehits,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); |
|
|
|
if ( width == 32 ) |
|
|
|
{ |
|
|
|
table = (uint32_t *)bits; |
|
|
|
offset = (int32_t)(bitoffset >> 5); |
|
|
|
for (i=0; i<tablesize; i++,ind++,offset++) |
|
|
|
for (i=0; i<tablesize; i++,ind++) |
|
|
|
{ |
|
|
|
if ( ind >= tablesize ) |
|
|
|
{ |
|
|
|
ind = 0; |
|
|
|
offset = 0; |
|
|
|
} |
|
|
|
if ( (x= table[offset]) == 0 ) |
|
|
|
if ( (x= table[ind]) == 0 ) |
|
|
|
{ |
|
|
|
if ( ++i > ramchain->sparsemax ) |
|
|
|
ramchain->sparsemax = i; |
|
|
|
ramchain->sparseiters += i; |
|
|
|
table[offset] = setind; |
|
|
|
fprintf(stderr,"set table[%d] of %d <- setind.%u\n",ind,tablesize,setind); |
|
|
|
table[ind] = setind; |
|
|
|
return(setind); |
|
|
|
} |
|
|
|
else if ( memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 ) |
|
|
@ -225,6 +219,9 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bitoffset = (ind * width); |
|
|
|
if ( 0 && setind == 0 ) |
|
|
|
printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); |
|
|
|
for (i=0; i<tablesize; i++,ind++,bitoffset+=width) |
|
|
|
{ |
|
|
|
ramchain->sparseiters++; |
|
|
|