Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/spark-harness/src/scheduler/timing.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / spark-harness / src / scheduler / timing.rs` 72 lines ยท 2589 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Per-task timing from the scheduler's monotonic clock, for the M6 A/B 17 //! analysis. Times are clock ticks as returned by the injected clock (the 18 //! default clock counts nanoseconds). Every value is derived from event 19 //! times recorded in the journal, so a replay reproduces the trace exactly. 20 21 use crate::execution::TaskState; 22 use serde::Serialize; 23 24 #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)] 25 pub struct TaskTiming { 26 /// Ticks spent `Blocked` (including waiting in the ready queue). 27 pub blocked: u64, 28 /// Ticks spent `Provisional` (running, holding permits). 29 pub provisional: u64, 30 /// Ticks spent `AwaitingFinalProof`. 31 pub awaiting_final_proof: u64, 32 pub registered_at: u64, 33 pub first_dispatch_at: Option, 34 pub committable_at: Option, 35 pub dispatches: u32, 36 pub revocations: u32, 37 /// Start of the current state. 38 pub since: u64, 39 } 40 41 impl TaskTiming { 42 pub fn new(at: u64) -> Self { 43 TaskTiming { 44 registered_at: at, 45 since: at, 46 ..TaskTiming::default() 47 } 48 } 49 50 /// Charge the time since the last transition to `state`. 51 pub fn close(&mut self, state: TaskState, at: u64) { 52 let spent = at.saturating_sub(self.since); 53 match state { 54 TaskState::Blocked => self.blocked += spent, 55 TaskState::Provisional => self.provisional += spent, 56 TaskState::AwaitingFinalProof => self.awaiting_final_proof += spent, 57 TaskState::Committable 58 | TaskState::Aborted 59 | TaskState::Committing 60 | TaskState::Committed 61 | TaskState::CommitUncertain => {} 62 } 63 self.since = at; 64 } 65 66 /// Totals as of `now`, counting the open interval in the current state. 67 pub fn as_of(&self, state: TaskState, now: u64) -> TaskTiming { 68 let mut t = self.clone(); 69 t.close(state, now); 70 t 71 } 72 }