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)
| 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 |