WorkCounts time each commit call, phase by phase
reims measured CommandBuffer::commit_and_submit holding their commit thread ~30 ms (p50) per command buffer before submission starts. The program's commit, commit_and_submit and commit_failed calls now run under a clock of their thread (commit_times.rs), which counts the call (WorkCounts::commit_calls), its whole time (commit_nanos) and each phase's own time, every phase timed apart from the phases inside it so they sum to at most the whole: - commit_lowering_nanos: settle_end_committing, the render encoders' calls left to the lowering thread lowered on this one, and the carried draw let go; - commit_recording_nanos: Deferred::prepare of the work its encoders left to the commit; - commit_pipeline_wait_nanos: that recording's wait_made for a render pass's draw pipelines; - commit_lock_wait_nanos: submit_at_commit taking the scheduler's lock (pass_once_then, and pass_again after a check); - commit_pass_nanos: the pass under the lock and its bookkeeping, its submissions apart; - commit_submit_nanos: submit_batch on the committing thread, and the submission checks and handlers it ran (a commit a handler makes is counted there and as a call of its own). Outside a commit call (the scheduler's thread, the lowering thread) a phase costs one read of a thread-local and times nothing; nothing is timed per draw or per command. Test: tests::commit_and_submit::a_commit_call_is_timed_phase_by_phase_within_its_whole. api_signatures blessed (8 fields); README names the counters.
This commit is contained in:
1 parent
89c22c7a2c
commit
6f882ce2bb
9 files changed
+358
-45
No files matched your search
@@ -585,7 +585,11 @@ Calls Metal does not have, for a consumer that emulates a Metal device:
|
||||
`batches_checked_at_commit`). Under `RenderLoweringPolicy::Worker`, one whose last render
|
||||
encoder's end the lowering thread has not lowered returns as `commit` does, and the thread that
|
||||
runs its commit once the end is lowered (the lowering thread, or one waiting for the command
|
||||
buffer) makes that pass, its checks and handlers with it.
|
||||
buffer) makes that pass, its checks and handlers with it. How long the program's `commit`,
|
||||
`commit_and_submit` and `commit_failed` calls held its thread, and how much of it each phase
|
||||
took (lowering, recording the work left to the commit, its pipeline waits, the scheduler lock's
|
||||
wait, the pass, the submissions with their checks and handlers), each apart from the others:
|
||||
`WorkCounts::commit_calls`, `commit_nanos` and the `commit_*_nanos` beside it.
|
||||
- `RenderCommandEncoder::set_color_resolve_target`, `set_depth_resolve_target` and
|
||||
`set_stencil_resolve_target` change where a pass resolves until it ends (the last target set
|
||||
wins), as Metal's private calls do.
|
||||
|
||||
@@ -61,6 +61,7 @@ use rebound_use::{ReboundUse, Unlogged};
|
||||
pub(super) use submit::{BatchLists, Submitting};
|
||||
|
||||
use super::apple_only::AppleOnly;
|
||||
use super::commit_times::{self, CommitClock, Phase};
|
||||
use super::compute::EncoderState;
|
||||
use super::contexts::{self, Run};
|
||||
use super::copied::CopiesReached;
|
||||
@@ -2682,8 +2683,10 @@ impl CommandBuffer {
|
||||
/// [`settle_end`](Self::settle_end) at a commit: a kept draw carried is let go uncounted, as
|
||||
/// no render encoder of the command buffer comes after it.
|
||||
fn settle_end_committing(&self) {
|
||||
self.settle_ended();
|
||||
self.let_go_carried(None);
|
||||
commit_times::phase(Phase::Lowering, || {
|
||||
self.settle_ended();
|
||||
self.let_go_carried(None);
|
||||
});
|
||||
}
|
||||
|
||||
/// [`settle_end`](Self::settle_end), but a kept draw the last render encoder carried stays
|
||||
@@ -3168,6 +3171,7 @@ impl CommandBuffer {
|
||||
/// [`refusal`](Self::refusal) keeps the error): it completes in its queue's order, its
|
||||
/// completed handlers run.
|
||||
pub fn commit(&self) -> Result<(), Error> {
|
||||
let _clock = CommitClock::start(&self.0.device);
|
||||
self.commit_as("commit", None, Hand::Wake)
|
||||
}
|
||||
|
||||
@@ -3217,12 +3221,14 @@ impl CommandBuffer {
|
||||
///
|
||||
/// Refused, changing nothing, as [`commit`](Self::commit) is. Counted:
|
||||
/// `WorkCounts::scheduler_passes_at_commit`, `WorkCounts::batches_submitted_at_commit`,
|
||||
/// `WorkCounts::batches_checked_at_commit`.
|
||||
/// `WorkCounts::batches_checked_at_commit`; timed, phase by phase, as every commit call is:
|
||||
/// `WorkCounts::commit_nanos` and kin.
|
||||
pub fn commit_and_submit(&self) -> Result<(), Error> {
|
||||
let device = &self.0.device;
|
||||
if exit_guard::serving_completion() {
|
||||
return self.commit();
|
||||
}
|
||||
let _clock = CommitClock::start(device);
|
||||
self.commit_as("commit_and_submit", None, Hand::Pass)?;
|
||||
device.shared().scheduler.submit_at_commit(device);
|
||||
Ok(())
|
||||
@@ -3253,6 +3259,7 @@ impl CommandBuffer {
|
||||
/// encoder past the ended ones (`Invalid`, `Problem::IndexOutOfRange`, its `limit` the
|
||||
/// number ended). (A code of 0 was refused, `Problem::UndefinedValue`.)
|
||||
pub fn commit_failed(&self, failure: CommitFailure) -> Result<(), Error> {
|
||||
let _clock = CommitClock::start(&self.0.device);
|
||||
self.commit_as("commit_failed", Some(failure), Hand::Wake)
|
||||
}
|
||||
|
||||
@@ -3622,11 +3629,14 @@ impl CommandBuffer {
|
||||
let listing = Listing::new(device, used);
|
||||
// Recorded, or settled for their host steps, with the lock free: their dispatches take it,
|
||||
// and announce degradations.
|
||||
let prepared: Result<Vec<_>, Error> = segments
|
||||
.iter()
|
||||
.zip(&places)
|
||||
.map(|((work, host), _)| work.prepare(self, *host))
|
||||
.collect();
|
||||
let prepared: Result<Vec<_>, Error> = match segments.is_empty() {
|
||||
true => Ok(Vec::new()),
|
||||
false => commit_times::phase(Phase::Recording, || {
|
||||
(segments.iter().zip(&places))
|
||||
.map(|((work, host), _)| work.prepare(self, *host))
|
||||
.collect()
|
||||
}),
|
||||
};
|
||||
let prepared = match prepared {
|
||||
Ok(prepared) => prepared,
|
||||
Err(error) => {
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
//! What a program's commit calls spend, phase by phase (`WorkCounts::commit_nanos` and kin): the
|
||||
//! time a call of `CommandBuffer::commit`, `commit_and_submit` or `commit_failed` holds the
|
||||
//! program's thread, and how much of it each phase took. Not part of the API.
|
||||
//!
|
||||
//! - **One clock a call.** Each such call runs under a [`CommitClock`], this thread's while it
|
||||
//! lasts: its whole time, and each phase's own time as the call enters it ([`phase`]). Each
|
||||
//! phase is timed apart from the phases inside it: a phase entered inside another pauses that
|
||||
//! one until it ends, so the phases' times never overlap and sum to at most the call's. A
|
||||
//! commit inside a call (a submission handler's) runs under a clock of its own, its whole time
|
||||
//! counted in the phase of the outer call that ran it.
|
||||
//! - **Nowhere else.** Outside such a call (the scheduler's thread, the lowering thread, a thread
|
||||
//! that waits) a phase costs one read of this thread's clock and is timed by nothing, so the
|
||||
//! paths it marks pay nothing more. A call pays two `Instant` reads for itself and two for each
|
||||
//! phase it enters: none per draw or per command.
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use crate::device::Device;
|
||||
|
||||
/// A phase of a commit call, in [`Times`]'s order (`WorkCounts::commit_lowering_nanos` and kin).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Phase {
|
||||
/// The encoders' calls left to the device's lowering thread, lowered on this one.
|
||||
Lowering,
|
||||
/// The work its encoders left to the commit, recorded or settled for its host steps.
|
||||
Recording,
|
||||
/// That recording's waits for its draws' pipelines being made.
|
||||
PipelineWait,
|
||||
/// Taking the scheduler's lock for the pass at commit.
|
||||
LockWait,
|
||||
/// That pass, but its submissions.
|
||||
Pass,
|
||||
/// Its submissions, with the submission checks and handlers it runs.
|
||||
Submit,
|
||||
}
|
||||
|
||||
/// How many phases there are.
|
||||
const PHASES: usize = 6;
|
||||
|
||||
impl Phase {
|
||||
/// Its place in [`Times`].
|
||||
fn at(self) -> usize {
|
||||
match self {
|
||||
Phase::Lowering => 0,
|
||||
Phase::Recording => 1,
|
||||
Phase::PipelineWait => 2,
|
||||
Phase::LockWait => 3,
|
||||
Phase::Pass => 4,
|
||||
Phase::Submit => 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Nanoseconds a call spent in each phase, by [`Phase`]'s place.
|
||||
pub(crate) type Times = [u64; PHASES];
|
||||
|
||||
/// A call's clock: its phases' times so far, and the phase it is in, since when.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Clock {
|
||||
times: Times,
|
||||
current: Option<(Phase, Instant)>,
|
||||
}
|
||||
|
||||
impl Clock {
|
||||
/// `phase` took `spent` more.
|
||||
fn add(&mut self, phase: Phase, spent: Duration) {
|
||||
self.times[phase.at()] += nanos(spent);
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// The clock of the commit call this thread runs, where it runs one.
|
||||
static CLOCK: Cell<Option<Clock>> = const { Cell::new(None) };
|
||||
}
|
||||
|
||||
/// `spent` in nanoseconds, saturated.
|
||||
fn nanos(spent: Duration) -> u64 {
|
||||
u64::try_from(spent.as_nanos()).unwrap_or(u64::MAX)
|
||||
}
|
||||
|
||||
/// A commit call's clock on this thread, from its making until it goes, which counts the call
|
||||
/// and its phases' times in its device's work counts (the module docs).
|
||||
pub(crate) struct CommitClock<'a> {
|
||||
device: &'a Device,
|
||||
started: Instant,
|
||||
/// The clock of the call this one runs inside, where it does, which it puts back.
|
||||
outer: Option<Clock>,
|
||||
}
|
||||
|
||||
impl CommitClock<'_> {
|
||||
/// A commit call of `device`'s starts now on this thread.
|
||||
pub(crate) fn start(device: &Device) -> CommitClock<'_> {
|
||||
let fresh = Clock {
|
||||
times: [0; PHASES],
|
||||
current: None,
|
||||
};
|
||||
let outer = CLOCK.replace(Some(fresh));
|
||||
CommitClock {
|
||||
device,
|
||||
started: Instant::now(),
|
||||
outer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CommitClock<'_> {
|
||||
/// The call returns: counted, with its phases' times, and the outer call's clock back.
|
||||
fn drop(&mut self) {
|
||||
let whole = nanos(self.started.elapsed());
|
||||
let clock = CLOCK.replace(self.outer.take());
|
||||
let times = clock.map_or([0; PHASES], |clock| clock.times);
|
||||
self.device.shared().counts.commit_timed(whole, ×);
|
||||
}
|
||||
}
|
||||
|
||||
/// Run `run`, the commit call's `phase`, timed apart from the phase it runs inside, which it
|
||||
/// pauses meanwhile; timed by nothing outside a commit call (the module docs).
|
||||
pub(crate) fn phase<R>(phase: Phase, run: impl FnOnce() -> R) -> R {
|
||||
let Some(mut clock) = CLOCK.get() else {
|
||||
return run();
|
||||
};
|
||||
let now = Instant::now();
|
||||
let outer = clock.current.replace((phase, now));
|
||||
if let Some((was, since)) = outer {
|
||||
clock.add(was, now - since);
|
||||
}
|
||||
CLOCK.set(Some(clock));
|
||||
let ran = run();
|
||||
let end = Instant::now();
|
||||
// The clock as `run` left it: its phases inside added, `phase` current again.
|
||||
if let Some(mut clock) = CLOCK.get() {
|
||||
if let Some((was, since)) = clock.current {
|
||||
clock.add(was, end - since);
|
||||
}
|
||||
clock.current = outer.map(|(was, _)| (was, end));
|
||||
CLOCK.set(Some(clock));
|
||||
}
|
||||
ran
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
use super::command_buffer::rerun::LoopCheck;
|
||||
use super::command_buffer::CommandBuffer;
|
||||
use super::commit_times::{self, Phase};
|
||||
use super::device::lock;
|
||||
use super::encoder::RecordedSegment;
|
||||
use super::error::{internal, Error};
|
||||
@@ -399,7 +400,8 @@ impl Deferred {
|
||||
// they stand now waits for them first.
|
||||
Deferred::RenderPass(pass) => {
|
||||
if pass.reads_at_commit() {
|
||||
pass.wait_made(command_buffer.making_deadline());
|
||||
let deadline = command_buffer.making_deadline();
|
||||
commit_times::phase(Phase::PipelineWait, || pass.wait_made(deadline));
|
||||
}
|
||||
if pass.making() || pass.failed() {
|
||||
return Ok(Prepared {
|
||||
|
||||
@@ -62,6 +62,7 @@ mod color_list;
|
||||
mod color_reformat;
|
||||
mod color_resolve;
|
||||
mod command_buffer;
|
||||
mod commit_times;
|
||||
mod compressed_blit;
|
||||
mod compute;
|
||||
mod contexts;
|
||||
|
||||
@@ -203,6 +203,7 @@ use super::command_buffer::kept_barriers::KeptBarriers;
|
||||
use super::command_buffer::BatchLists;
|
||||
use super::command_buffer::CommandBufferShared;
|
||||
use super::command_buffer::{Group, GroupEnd, Submitting, GROUP_BATCHES};
|
||||
use super::commit_times::{self, Phase};
|
||||
use super::device::functions::Functions;
|
||||
use super::device::lock;
|
||||
use super::device::submit_stalls::{IdleCounts, IdleStalls, IDLE_NANOS};
|
||||
@@ -969,38 +970,22 @@ impl Scheduler {
|
||||
/// handler thread, as the thread's passes leave it.
|
||||
pub(crate) fn submit_at_commit(&self, device: &Device) {
|
||||
let shared = &*self.shared;
|
||||
let passed = shared.inbox.pass_once_then(
|
||||
|state, commits| {
|
||||
let mut spent = Spent::new();
|
||||
let taken = take_in(state, commits, &mut spent);
|
||||
let pass = AtCommit::pass(state, spent, PASS_SUBMISSIONS);
|
||||
shared.took_in(taken);
|
||||
pass
|
||||
},
|
||||
|mut pass| {
|
||||
let (mut submitted, mut alone, mut checked) = (0, 0, 0);
|
||||
loop {
|
||||
submitted += pass.submitted;
|
||||
alone += pass.alone;
|
||||
let left_over = pass.left_over;
|
||||
// The completion turn a command buffer the pass took with no submission left
|
||||
// this thread, before the handlers and the check, as the scheduler's thread
|
||||
// makes it before its handlers ([`round`]).
|
||||
device.shared().completion.turn_owed();
|
||||
let Some(check) = pass.let_go(&shared.turns, device) else {
|
||||
return (submitted, alone, checked, left_over);
|
||||
};
|
||||
// None once the process is exiting, as the thread then runs nothing more.
|
||||
if !run_work(&self.shared, Kind::Check, check) {
|
||||
return (submitted, alone, checked, left_over);
|
||||
}
|
||||
checked += 1;
|
||||
let room = PASS_SUBMISSIONS.saturating_sub(submitted);
|
||||
pass = (shared.inbox)
|
||||
.pass_again(|state| AtCommit::pass(state, Spent::new(), room));
|
||||
}
|
||||
},
|
||||
);
|
||||
// Timed as the commit call's phases (`commit_times.rs`): the lock's wait, the pass under
|
||||
// it, and the submissions, checks and handlers, each apart.
|
||||
let passed = commit_times::phase(Phase::LockWait, || {
|
||||
shared.inbox.pass_once_then(
|
||||
|state, commits| {
|
||||
commit_times::phase(Phase::Pass, || {
|
||||
let mut spent = Spent::new();
|
||||
let taken = take_in(state, commits, &mut spent);
|
||||
let pass = AtCommit::pass(state, spent, PASS_SUBMISSIONS);
|
||||
shared.took_in(taken);
|
||||
pass
|
||||
})
|
||||
},
|
||||
|pass| commit_times::phase(Phase::Pass, || self.after_pass_at_commit(device, pass)),
|
||||
)
|
||||
});
|
||||
let Some((submitted, alone, checked, left_over)) = passed else {
|
||||
return;
|
||||
};
|
||||
@@ -1013,6 +998,42 @@ impl Scheduler {
|
||||
}
|
||||
}
|
||||
|
||||
/// [`submit_at_commit`](Self::submit_at_commit)'s work after its first pass, still counted as
|
||||
/// the passer: the pass's submission handlers, the check it took and its pass again, and so
|
||||
/// on. How many batches it submitted, alone, and checked, and whether it left any over.
|
||||
fn after_pass_at_commit(
|
||||
&self,
|
||||
device: &Device,
|
||||
mut pass: AtCommit,
|
||||
) -> (usize, usize, usize, bool) {
|
||||
let shared = &*self.shared;
|
||||
let (mut submitted, mut alone, mut checked) = (0, 0, 0);
|
||||
loop {
|
||||
submitted += pass.submitted;
|
||||
alone += pass.alone;
|
||||
let left_over = pass.left_over;
|
||||
// The completion turn a command buffer the pass took with no submission left this
|
||||
// thread, before the handlers and the check, as the scheduler's thread makes it before
|
||||
// its handlers ([`round`]).
|
||||
device.shared().completion.turn_owed();
|
||||
let let_go = || pass.let_go(&shared.turns, device);
|
||||
let Some(check) = commit_times::phase(Phase::Submit, let_go) else {
|
||||
return (submitted, alone, checked, left_over);
|
||||
};
|
||||
// None once the process is exiting, as the thread then runs nothing more.
|
||||
let ran = || run_work(&self.shared, Kind::Check, check);
|
||||
if !commit_times::phase(Phase::Submit, ran) {
|
||||
return (submitted, alone, checked, left_over);
|
||||
}
|
||||
checked += 1;
|
||||
let room = PASS_SUBMISSIONS.saturating_sub(submitted);
|
||||
let again = |state: &mut State| {
|
||||
commit_times::phase(Phase::Pass, || AtCommit::pass(state, Spent::new(), room))
|
||||
};
|
||||
pass = commit_times::phase(Phase::LockWait, || shared.inbox.pass_again(again));
|
||||
}
|
||||
}
|
||||
|
||||
/// What makes the thread look for work again from any thread: a pipeline a held batch's
|
||||
/// host step waits for was made (`render/pending.rs`). It holds the thread's state weakly,
|
||||
/// so a making it waits on keeps nothing of the scheduler alive.
|
||||
@@ -1941,9 +1962,9 @@ fn submit_plain_ready(
|
||||
drop(busy);
|
||||
return submitted;
|
||||
};
|
||||
let answer = held
|
||||
.buffer
|
||||
.submit_batch(held.index, held.last, &waits, true, state);
|
||||
// A committing thread's submission, timed as its commit call's (`commit_times.rs`).
|
||||
let submit = || (held.buffer).submit_batch(held.index, held.last, &waits, true, state);
|
||||
let answer = commit_times::phase(Phase::Submit, submit);
|
||||
// Its waits for values found reached go: it waits for none of them.
|
||||
if matches!(answer, Ok(Submitting::Submitted(_))) {
|
||||
held.hold_ended();
|
||||
|
||||
@@ -136,6 +136,66 @@ fn a_submission_handler_runs_on_the_committing_thread_before_scheduled() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Each commit call is timed, phase by phase (`commit_times.rs`, `WorkCounts::commit_nanos` and
|
||||
/// kin): `commit_and_submit` calls whose passes submitted at commit, each with a submission handler
|
||||
/// that runs a while, time their lowering, lock wait, pass and submissions, and `commit` calls
|
||||
/// their lowering alone; neither records work left to the commit nor waits for a pipeline (a
|
||||
/// fill leaves none); and the phases sum to at most the calls' whole time.
|
||||
#[test]
|
||||
fn a_commit_call_is_timed_phase_by_phase_within_its_whole() {
|
||||
let device = device();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let target = device.new_buffer(256, ResourceOptions::private()).unwrap();
|
||||
let before = device.work_counts();
|
||||
for round in 0..ROUNDS {
|
||||
let command_buffer = fill(&queue, &target, round as u8);
|
||||
command_buffer
|
||||
.add_submission_handler(Box::new(|_: &CommandBuffer| {
|
||||
std::thread::sleep(Duration::from_micros(50));
|
||||
}))
|
||||
.unwrap();
|
||||
match round % 2 {
|
||||
0 => command_buffer.commit_and_submit().unwrap(),
|
||||
_ => command_buffer.commit().unwrap(),
|
||||
}
|
||||
command_buffer.wait_until_completed().unwrap();
|
||||
}
|
||||
let after = device.work_counts();
|
||||
let moved = |count: fn(&crate::WorkCounts) -> u64| count(&after) - count(&before);
|
||||
let calls = moved(|c| c.commit_calls);
|
||||
let whole = moved(|c| c.commit_nanos);
|
||||
let phases = [
|
||||
("lowering", moved(|c| c.commit_lowering_nanos)),
|
||||
("recording", moved(|c| c.commit_recording_nanos)),
|
||||
("pipeline wait", moved(|c| c.commit_pipeline_wait_nanos)),
|
||||
("lock wait", moved(|c| c.commit_lock_wait_nanos)),
|
||||
("pass", moved(|c| c.commit_pass_nanos)),
|
||||
("submit", moved(|c| c.commit_submit_nanos)),
|
||||
];
|
||||
let batches = moved(|c| c.batches_submitted_at_commit);
|
||||
println!("{calls} commit calls, {whole} ns; {phases:?}; batches submitted at commit {batches}");
|
||||
assert_eq!(calls, ROUNDS, "every commit call counted once");
|
||||
let [lowering, recording, pipeline_wait, lock_wait, pass, submit] = phases.map(|(_, n)| n);
|
||||
assert!(lowering > 0 && lock_wait > 0 && pass > 0, "{phases:?}");
|
||||
assert_eq!(
|
||||
(recording, pipeline_wait),
|
||||
(0, 0),
|
||||
"a fill leaves no work to the commit"
|
||||
);
|
||||
// A pass of the scheduler's thread under way at a commit takes it in instead: rarely, on an
|
||||
// idle device. Each batch a pass at commit submitted ran its handler's 50 us inside the call.
|
||||
assert!(batches > 0, "no batch submitted at commit");
|
||||
assert!(
|
||||
submit >= batches * 50_000,
|
||||
"{submit} ns of submissions for {batches} batches"
|
||||
);
|
||||
let parts: u64 = phases.iter().map(|(_, n)| n).sum();
|
||||
assert!(
|
||||
parts <= whole,
|
||||
"the phases' {parts} ns past the calls' {whole} ns"
|
||||
);
|
||||
}
|
||||
|
||||
/// Two threads commit 1000 command buffers to one queue, each in turn with `commit` and with
|
||||
/// `commit_and_submit`, their commits in one order (a lock held across each call): every
|
||||
/// submission handler runs in that order, some on a committing thread and some on the
|
||||
|
||||
@@ -255,6 +255,14 @@ pub(crate) struct Counters {
|
||||
scheduler_passes_at_commit: AtomicU64,
|
||||
batches_submitted_at_commit: AtomicU64,
|
||||
batches_checked_at_commit: AtomicU64,
|
||||
commit_calls: AtomicU64,
|
||||
commit_nanos: AtomicU64,
|
||||
commit_lowering_nanos: AtomicU64,
|
||||
commit_recording_nanos: AtomicU64,
|
||||
commit_pipeline_wait_nanos: AtomicU64,
|
||||
commit_lock_wait_nanos: AtomicU64,
|
||||
commit_pass_nanos: AtomicU64,
|
||||
commit_submit_nanos: AtomicU64,
|
||||
footprints_built: AtomicU64,
|
||||
footprint_lock_waits: AtomicU64,
|
||||
command_buffer_wakes: AtomicU64,
|
||||
@@ -3089,6 +3097,22 @@ impl Counters {
|
||||
.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A program's commit call took `whole` nanoseconds on its thread, `phases` of them in its
|
||||
/// phases, each apart from the others (`commit_times.rs`: lowering, recording, pipeline
|
||||
/// waits, lock wait, pass, submissions).
|
||||
pub(crate) fn commit_timed(&self, whole: u64, phases: &crate::commit_times::Times) {
|
||||
let [lowering, recording, pipeline_wait, lock_wait, pass, submit] = *phases;
|
||||
self.commit_calls.fetch_add(1, Ordering::Relaxed);
|
||||
self.commit_nanos.fetch_add(whole, Ordering::Relaxed);
|
||||
(self.commit_lowering_nanos).fetch_add(lowering, Ordering::Relaxed);
|
||||
(self.commit_recording_nanos).fetch_add(recording, Ordering::Relaxed);
|
||||
(self.commit_pipeline_wait_nanos).fetch_add(pipeline_wait, Ordering::Relaxed);
|
||||
(self.commit_lock_wait_nanos).fetch_add(lock_wait, Ordering::Relaxed);
|
||||
self.commit_pass_nanos.fetch_add(pass, Ordering::Relaxed);
|
||||
self.commit_submit_nanos
|
||||
.fetch_add(submit, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A commit left its batches to the scheduler's thread (`scheduler/inbox.rs`).
|
||||
pub(crate) fn commit_handed_off(&self) {
|
||||
self.commits_handed_off.fetch_add(1, Ordering::Relaxed);
|
||||
@@ -6262,6 +6286,41 @@ pub struct WorkCounts {
|
||||
/// signal to land, or whose checks the scheduler's thread took first, is left to that thread,
|
||||
/// uncounted here, and holds back no later commit of another queue but those behind it.
|
||||
pub batches_checked_at_commit: u64,
|
||||
/// The program's calls of `CommandBuffer::commit`, `commit_and_submit` and `commit_failed`,
|
||||
/// which the commit times below sum over (`commit_times.rs`). A call a submission handler
|
||||
/// makes inside another is one of them too, its time counted in both.
|
||||
pub commit_calls: u64,
|
||||
/// Nanoseconds those calls held the program's thread, each from its start to its return.
|
||||
/// The phases below are parts of it, each timed apart from the others, so they sum to at
|
||||
/// most this; the rest is the commit's checks and bookkeeping (its hazard and residency
|
||||
/// lists, its copies in, its posting to the scheduler).
|
||||
pub commit_nanos: u64,
|
||||
/// Of `commit_nanos`, lowering on the calling thread the encoders' calls a render encoder
|
||||
/// left to the device's lowering thread (`RenderLoweringPolicy::Worker`) and its end, and
|
||||
/// letting go of the draw its last render encoder kept for the next: about nothing under
|
||||
/// `RenderLoweringPolicy::AtCall`, which lowered each call inside it.
|
||||
pub commit_lowering_nanos: u64,
|
||||
/// Of `commit_nanos`, recording the work its encoders left to the commit, or settling it for
|
||||
/// its host steps (`Deferred::prepare`): an indirect command buffer's execution, a render pass
|
||||
/// whose draws' pipelines were being made, an indirect dispatch's variants. Its waits for
|
||||
/// pipelines are `commit_pipeline_wait_nanos`, apart from this.
|
||||
pub commit_recording_nanos: u64,
|
||||
/// Of `commit_nanos`, that recording's waits for the pipelines being made of a render pass
|
||||
/// whose executions read the CPU's records as they stand at the commit, up to the command
|
||||
/// buffer's bound under `PipelineWaitPolicy::Bounded`.
|
||||
pub commit_pipeline_wait_nanos: u64,
|
||||
/// Of `commit_nanos`, `commit_and_submit`'s wait to take the scheduler's lock for its pass at
|
||||
/// commit, and for each pass again after a submission check it ran. Where a pass is under way
|
||||
/// the call makes none and waits for none: that pass takes the commit in.
|
||||
pub commit_lock_wait_nanos: u64,
|
||||
/// Of `commit_nanos`, `commit_and_submit`'s pass at commit under the scheduler's lock: taking
|
||||
/// in what was posted, ordering it and picking what it submits (`Scheduler::submit_at_commit`),
|
||||
/// its submissions apart.
|
||||
pub commit_pass_nanos: u64,
|
||||
/// Of `commit_nanos`, that pass's submissions (`CommandBufferShared::submit_batch`: the
|
||||
/// batch's barriers and `vkQueueSubmit`), and the submission checks and submission handlers
|
||||
/// the call ran for them, with the commits a handler made inside it.
|
||||
pub commit_submit_nanos: u64,
|
||||
/// Footprints of batches the scheduler built to order them across queues
|
||||
/// (`scheduler/order.rs`), one each time: each batch's is built where a pass first compares
|
||||
/// it with another queue's and kept, and built again only where what it is built from
|
||||
@@ -9390,6 +9449,14 @@ impl Device {
|
||||
.batches_submitted_at_commit
|
||||
.load(Ordering::Relaxed),
|
||||
batches_checked_at_commit: counters.batches_checked_at_commit.load(Ordering::Relaxed),
|
||||
commit_calls: counters.commit_calls.load(Ordering::Relaxed),
|
||||
commit_nanos: counters.commit_nanos.load(Ordering::Relaxed),
|
||||
commit_lowering_nanos: counters.commit_lowering_nanos.load(Ordering::Relaxed),
|
||||
commit_recording_nanos: counters.commit_recording_nanos.load(Ordering::Relaxed),
|
||||
commit_pipeline_wait_nanos: counters.commit_pipeline_wait_nanos.load(Ordering::Relaxed),
|
||||
commit_lock_wait_nanos: counters.commit_lock_wait_nanos.load(Ordering::Relaxed),
|
||||
commit_pass_nanos: counters.commit_pass_nanos.load(Ordering::Relaxed),
|
||||
commit_submit_nanos: counters.commit_submit_nanos.load(Ordering::Relaxed),
|
||||
wakes_completion_waiters: completion_wakes,
|
||||
completion_waiter_parks: completion_parks,
|
||||
completion_waiter_parks_timed_out: completion_parks_timed_out,
|
||||
|
||||
@@ -2685,7 +2685,15 @@ field metal2vulkan-runtime::WorkCounts.command_queues_live_most pub command_queu
|
||||
field metal2vulkan-runtime::WorkCounts.commands_noted_as_before pub commands_noted_as_before: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commands_recorded pub commands_recorded: CommandsRecorded
|
||||
field metal2vulkan-runtime::WorkCounts.commands_uncounted pub commands_uncounted: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_calls pub commit_calls: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_lock_wait_nanos pub commit_lock_wait_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_lowering_nanos pub commit_lowering_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_nanos pub commit_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_pass_nanos pub commit_pass_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_pipeline_wait_nanos pub commit_pipeline_wait_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_recording_nanos pub commit_recording_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_refusals_held pub commit_refusals_held: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commit_submit_nanos pub commit_submit_nanos: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commits_handed_off pub commits_handed_off: u64
|
||||
field metal2vulkan-runtime::WorkCounts.commits_taken_in pub commits_taken_in: u64
|
||||
field metal2vulkan-runtime::WorkCounts.completed_waits pub completed_waits: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user