rt counters: first-use waits by site, each with its count, time and longest
Metrics::first_use_waits held every encoding call that waited for the VkPipeline it needed, in one total, so a cold play's waits could not be told apart. The total stays; each wait now also adds to its site's: first_use_variant_waits (a kernel's pipeline made on the encoding thread for a new workgroup size, threadgroup memory lengths or tiles), first_use_lowering_waits (a later lowering the reaper made while the call waited) and first_use_line_waits (a render content's line-class pipeline, at its first draw of lines), each with _nanos and _max_nanos. Only the waiting path counts. Verified: a no-device test (each_first_use_wait_adds_to_its_site_and_the_total) that each wait adds to its own site and to the total. API signature table blessed; README's counter sentence updated.
This commit is contained in:
1 parent
11c01ef32e
commit
5bd17daf4b
7 files changed
+140
-10
No files matched your search
@@ -2055,7 +2055,10 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
|
||||
for it. Nothing the runtime records
|
||||
depends on when a compile finishes: there is one recorded form, made after the wait. Each such
|
||||
wait is counted in `Metrics::first_use_waits`, with its time in `first_use_wait_nanos` and the
|
||||
longest in `first_use_wait_max_nanos`.
|
||||
longest in `first_use_wait_max_nanos`, and again by where it waited, each with its count, time
|
||||
and longest: `first_use_variant_waits` (a kernel's pipeline for a new workgroup size,
|
||||
threadgroup memory lengths or tiles), `first_use_lowering_waits` (a later lowering the reaper
|
||||
made) and `first_use_line_waits` (a render content's line-class pipeline).
|
||||
- `ComputePipelineState::precision_notes` carries the translator's notes of where the kernel's
|
||||
answers may differ from Metal's on this device, fixed per operation: those of the modules made
|
||||
with the state, and the emulated-SIMD-group module's once it is lowered. A kernel compiled
|
||||
|
||||
@@ -49,6 +49,20 @@ pub(crate) enum Part {
|
||||
/// The number of [`Part`]s.
|
||||
const PARTS: usize = Part::LongTakeZeroWrite as usize + 1;
|
||||
|
||||
/// Where a first-use wait made the `VkPipeline` it waited for ([`Metrics::first_use_waits`]).
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum FirstUse {
|
||||
/// A compute kernel's pipeline for a new workgroup size, threadgroup memory lengths or tiles
|
||||
/// ([`Metrics::first_use_variant_waits`]).
|
||||
Variant,
|
||||
/// A lowering the reaper made for the encoding call that waits for it
|
||||
/// ([`Metrics::first_use_lowering_waits`]).
|
||||
Lowering,
|
||||
/// A render content's line-class pipeline, at its first draw of lines
|
||||
/// ([`Metrics::first_use_line_waits`]).
|
||||
Lines,
|
||||
}
|
||||
|
||||
/// A [`Part`]'s longest call: its nanoseconds, its bytes, and whether it made an allocation of
|
||||
/// its own ([`Timed::longest_made`]).
|
||||
#[derive(Clone, Copy, Default)]
|
||||
@@ -331,6 +345,8 @@ struct Atomics {
|
||||
first_use_waits: AtomicU64,
|
||||
first_use_wait_nanos: AtomicU64,
|
||||
first_use_wait_max_nanos: AtomicU64,
|
||||
/// Each [`FirstUse`] site's waits, at its index: their count, total and longest nanoseconds.
|
||||
first_use_sites: [[AtomicU64; 3]; 3],
|
||||
blocks_made: AtomicU64,
|
||||
block_bytes_made: AtomicU64,
|
||||
consumer_allocations: AtomicU64,
|
||||
@@ -523,13 +539,17 @@ impl Counters {
|
||||
}
|
||||
}
|
||||
|
||||
/// One more first-use wait: an encoding call that made the `VkPipeline` it needed, for
|
||||
/// `nanos` nanoseconds.
|
||||
pub(crate) fn first_use_wait(&self, nanos: u64) {
|
||||
/// One more first-use wait at `site`: an encoding call that made the `VkPipeline` it needed,
|
||||
/// for `nanos` nanoseconds, in the total and in its site's.
|
||||
pub(crate) fn first_use_wait(&self, site: FirstUse, nanos: u64) {
|
||||
let a = &self.atomics;
|
||||
a.first_use_waits.fetch_add(1, Relaxed);
|
||||
a.first_use_wait_nanos.fetch_add(nanos, Relaxed);
|
||||
a.first_use_wait_max_nanos.fetch_max(nanos, Relaxed);
|
||||
let [count, total, longest] = &a.first_use_sites[site as usize];
|
||||
count.fetch_add(1, Relaxed);
|
||||
total.fetch_add(nanos, Relaxed);
|
||||
longest.fetch_max(nanos, Relaxed);
|
||||
}
|
||||
|
||||
/// One more surface wait ([`Metrics::surface_waits`]): `nanos` nanoseconds, for `submissions`
|
||||
@@ -931,6 +951,13 @@ impl Counters {
|
||||
longest_nanos: longest.load(Relaxed),
|
||||
}
|
||||
};
|
||||
let first_use =
|
||||
|site: FirstUse| (a.first_use_sites[site as usize].each_ref()).map(|n| n.load(Relaxed));
|
||||
let (variant, lowering, lines) = (
|
||||
first_use(FirstUse::Variant),
|
||||
first_use(FirstUse::Lowering),
|
||||
first_use(FirstUse::Lines),
|
||||
);
|
||||
let part = |part: Part| {
|
||||
let [count, bytes, total, _, over_1, over_5, over_20] = &a.parts[part as usize];
|
||||
let longest =
|
||||
@@ -964,6 +991,15 @@ impl Counters {
|
||||
first_use_waits: a.first_use_waits.load(Relaxed),
|
||||
first_use_wait_nanos: a.first_use_wait_nanos.load(Relaxed),
|
||||
first_use_wait_max_nanos: a.first_use_wait_max_nanos.load(Relaxed),
|
||||
first_use_variant_waits: variant[0],
|
||||
first_use_variant_wait_nanos: variant[1],
|
||||
first_use_variant_wait_max_nanos: variant[2],
|
||||
first_use_lowering_waits: lowering[0],
|
||||
first_use_lowering_wait_nanos: lowering[1],
|
||||
first_use_lowering_wait_max_nanos: lowering[2],
|
||||
first_use_line_waits: lines[0],
|
||||
first_use_line_wait_nanos: lines[1],
|
||||
first_use_line_wait_max_nanos: lines[2],
|
||||
blocks_made: a.blocks_made.load(Relaxed),
|
||||
block_bytes_made: a.block_bytes_made.load(Relaxed),
|
||||
consumer_allocations: a.consumer_allocations.load(Relaxed),
|
||||
@@ -1186,6 +1222,34 @@ pub struct Metrics {
|
||||
/// The longest first-use wait, in nanoseconds; a maximum since the device was made, so the
|
||||
/// difference of two reads does not apply to it.
|
||||
pub first_use_wait_max_nanos: u64,
|
||||
/// Of the [`first_use_waits`](Self::first_use_waits), those for a compute kernel's pipeline
|
||||
/// made on the encoding thread for a workgroup size, threadgroup memory lengths or tiles none
|
||||
/// of its states had run with (`vkCreateComputePipelines`).
|
||||
pub first_use_variant_waits: u64,
|
||||
/// The nanoseconds of the [`first_use_variant_waits`](Self::first_use_variant_waits), in
|
||||
/// total.
|
||||
pub first_use_variant_wait_nanos: u64,
|
||||
/// The longest of the [`first_use_variant_waits`](Self::first_use_variant_waits), in
|
||||
/// nanoseconds; a maximum since the device was made.
|
||||
pub first_use_variant_wait_max_nanos: u64,
|
||||
/// Of the [`first_use_waits`](Self::first_use_waits), those for a kernel's later lowering
|
||||
/// (the partial-threadgroups or the emulated form), made by the reaper thread while the
|
||||
/// encoding call waited.
|
||||
pub first_use_lowering_waits: u64,
|
||||
/// The nanoseconds of the [`first_use_lowering_waits`](Self::first_use_lowering_waits), in
|
||||
/// total.
|
||||
pub first_use_lowering_wait_nanos: u64,
|
||||
/// The longest of the [`first_use_lowering_waits`](Self::first_use_lowering_waits), in
|
||||
/// nanoseconds; a maximum since the device was made.
|
||||
pub first_use_lowering_wait_max_nanos: u64,
|
||||
/// Of the [`first_use_waits`](Self::first_use_waits), those for a render content's
|
||||
/// line-class pipeline, made by its first draw of lines.
|
||||
pub first_use_line_waits: u64,
|
||||
/// The nanoseconds of the [`first_use_line_waits`](Self::first_use_line_waits), in total.
|
||||
pub first_use_line_wait_nanos: u64,
|
||||
/// The longest of the [`first_use_line_waits`](Self::first_use_line_waits), in nanoseconds;
|
||||
/// a maximum since the device was made.
|
||||
pub first_use_line_wait_max_nanos: u64,
|
||||
/// `VkDeviceMemory` allocations made: the allocations blocks are ranges of (the texture
|
||||
/// blocks among them), the zero source and the parameter ring's blocks.
|
||||
pub blocks_made: u64,
|
||||
|
||||
@@ -1437,9 +1437,10 @@ impl Compiled {
|
||||
let began = host_time();
|
||||
self.core.reaper.lower(Arc::downgrade(self), which);
|
||||
let lowered = later.lowered.wait();
|
||||
self.core
|
||||
.counters
|
||||
.first_use_wait(host_time().saturating_sub(began));
|
||||
self.core.counters.first_use_wait(
|
||||
crate::counters::FirstUse::Lowering,
|
||||
host_time().saturating_sub(began),
|
||||
);
|
||||
lowered
|
||||
}
|
||||
};
|
||||
@@ -1572,8 +1573,10 @@ impl Kernel {
|
||||
};
|
||||
let began = host_time();
|
||||
let pipeline = self.make(core, &variant)?;
|
||||
core.counters
|
||||
.first_use_wait(host_time().saturating_sub(began));
|
||||
core.counters.first_use_wait(
|
||||
crate::counters::FirstUse::Variant,
|
||||
host_time().saturating_sub(began),
|
||||
);
|
||||
variants.keep(&mut more, variant, pipeline);
|
||||
Ok(pipeline)
|
||||
}
|
||||
|
||||
@@ -868,7 +868,10 @@ impl RenderCompiled {
|
||||
if *lines == vk::Pipeline::null() {
|
||||
let began = host_time();
|
||||
*lines = self.make(vk::PrimitiveTopology::LINE_LIST)?;
|
||||
(self.core.counters).first_use_wait(host_time().saturating_sub(began));
|
||||
(self.core.counters).first_use_wait(
|
||||
crate::counters::FirstUse::Lines,
|
||||
host_time().saturating_sub(began),
|
||||
);
|
||||
}
|
||||
Ok(*lines)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//! First-use waits by site, without a device: each wait adds to its own site's count, time and
|
||||
//! longest, and to the total's.
|
||||
|
||||
use crate::counters::{Counters, FirstUse};
|
||||
|
||||
/// A wait at each site adds to that site alone and to the total; the longest is each one's own.
|
||||
#[test]
|
||||
fn each_first_use_wait_adds_to_its_site_and_the_total() {
|
||||
let counters = Counters::new();
|
||||
counters.first_use_wait(FirstUse::Variant, 3_000);
|
||||
counters.first_use_wait(FirstUse::Variant, 7_000);
|
||||
counters.first_use_wait(FirstUse::Lowering, 11_000);
|
||||
counters.first_use_wait(FirstUse::Lines, 2_000);
|
||||
let m = counters.metrics();
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_variant_waits,
|
||||
m.first_use_variant_wait_nanos,
|
||||
m.first_use_variant_wait_max_nanos
|
||||
),
|
||||
(2, 10_000, 7_000)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_lowering_waits,
|
||||
m.first_use_lowering_wait_nanos,
|
||||
m.first_use_lowering_wait_max_nanos
|
||||
),
|
||||
(1, 11_000, 11_000)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_line_waits,
|
||||
m.first_use_line_wait_nanos,
|
||||
m.first_use_line_wait_max_nanos
|
||||
),
|
||||
(1, 2_000, 2_000)
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
m.first_use_waits,
|
||||
m.first_use_wait_nanos,
|
||||
m.first_use_wait_max_nanos
|
||||
),
|
||||
(4, 23_000, 11_000)
|
||||
);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ mod draw;
|
||||
mod export;
|
||||
mod fence;
|
||||
mod fetch;
|
||||
mod first_use_sites;
|
||||
mod floor;
|
||||
mod hazard;
|
||||
mod heap;
|
||||
|
||||
@@ -2403,6 +2403,15 @@ field metal2vulkan-rt::Metrics.creations_before_seed pub creations_before_seed:
|
||||
field metal2vulkan-rt::Metrics.dispatches_without_effects pub dispatches_without_effects: u64
|
||||
field metal2vulkan-rt::Metrics.external_acquires pub external_acquires: u64
|
||||
field metal2vulkan-rt::Metrics.external_releases pub external_releases: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_line_wait_max_nanos pub first_use_line_wait_max_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_line_wait_nanos pub first_use_line_wait_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_line_waits pub first_use_line_waits: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_lowering_wait_max_nanos pub first_use_lowering_wait_max_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_lowering_wait_nanos pub first_use_lowering_wait_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_lowering_waits pub first_use_lowering_waits: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_variant_wait_max_nanos pub first_use_variant_wait_max_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_variant_wait_nanos pub first_use_variant_wait_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_variant_waits pub first_use_variant_waits: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_wait_max_nanos pub first_use_wait_max_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_wait_nanos pub first_use_wait_nanos: u64
|
||||
field metal2vulkan-rt::Metrics.first_use_waits pub first_use_waits: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user