MCPcopy Create free account
hub / github.com/argumentcomputer/ix / record_constant_fuel_used

Method record_constant_fuel_used

crates/kernel/src/perf.rs:192–213  ·  view source on GitHub ↗

Record the fuel actually consumed by a single constant check. Updates both the running max and the cumulative total. No-op when disabled.

(&self, used: u64)

Source from the content-addressed store, hash-verified

190 /// Record the fuel actually consumed by a single constant check. Updates
191 /// both the running max and the cumulative total. No-op when disabled.
192 pub fn record_constant_fuel_used(&self, used: u64) {
193 if !enabled() {
194 return;
195 }
196 self.total_rec_fuel_used.fetch_add(used, Ordering::Relaxed);
197 self.constants_checked.fetch_add(1, Ordering::Relaxed);
198
199 // CAS loop on peak. Worst-case contention is O(threads); we expect very
200 // few peak updates over the life of a check, so this is cheap.
201 let mut current = self.peak_rec_fuel_used.load(Ordering::Relaxed);
202 while used > current {
203 match self.peak_rec_fuel_used.compare_exchange_weak(
204 current,
205 used,
206 Ordering::Relaxed,
207 Ordering::Relaxed,
208 ) {
209 Ok(_) => break,
210 Err(actual) => current = actual,
211 }
212 }
213 }
214
215 // -----------------------------------------------------------------------
216 // Reporting

Callers 2

peak_fuel_is_running_maxFunction · 0.80

Calls 1

enabledFunction · 0.85

Tested by 1

peak_fuel_is_running_maxFunction · 0.64