MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_scale_tick

Function cbm_scale_tick

src/foundation/profile.c:103–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void cbm_scale_tick(cbm_scale_probe_t *probe, long done) {
104 if (!probe || probe->total < SCALE_MIN_ITEMS) {
105 return;
106 }
107 int cp = atomic_load_explicit(&probe->next_cp, memory_order_relaxed);
108 if (cp >= CBM_SCALE_CHECKPOINTS) {
109 return;
110 }
111 /* cp 0..3 -> total/8, total/4, total/2, total */
112 long threshold = probe->total >> (CBM_SCALE_CHECKPOINTS - 1 - cp);
113 if (done < threshold) {
114 return;
115 }
116 /* Exactly one thread records each checkpoint; a loser simply moves on and
117 * will re-evaluate against the next threshold on its following tick. */
118 if (!atomic_compare_exchange_strong_explicit(&probe->next_cp, &cp, cp + 1, memory_order_relaxed,
119 memory_order_relaxed)) {
120 return;
121 }
122 probe->cp_us[cp] = scale_elapsed_us(&probe->start);
123 probe->cp_items[cp] = done;
124}
125
126double cbm_scale_fit_k(long first_n, long first_us, long last_n, long last_us) {
127 if (first_n <= 0 || first_us <= 0 || last_us <= 0 || last_n <= first_n) {

Callers 3

extract_workerFunction · 0.85
resolve_workerFunction · 0.85
test_diagnostics.cFile · 0.85

Calls 1

scale_elapsed_usFunction · 0.85

Tested by

no test coverage detected