Unverified Commit 12b596a3 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[Turbopack] use Timestamp type, allow spans less than 1µs (#75479)

### What?

The minimum span size of 1µs was a bit limiting. This changes it to 0.01µs.

A trace viewer update is also needed: https://github.com/vercel/turbo-trace-viewer/pull/11
parent 64f34a0e
...@@ -18,6 +18,7 @@ mod span_graph_ref; ...@@ -18,6 +18,7 @@ mod span_graph_ref;
mod span_ref; mod span_ref;
mod store; mod store;
mod store_container; mod store_container;
mod timestamp;
mod u64_empty_string; mod u64_empty_string;
mod u64_string; mod u64_string;
mod viewer; mod viewer;
......
...@@ -19,6 +19,7 @@ mod span_graph_ref; ...@@ -19,6 +19,7 @@ mod span_graph_ref;
mod span_ref; mod span_ref;
mod store; mod store;
mod store_container; mod store_container;
mod timestamp;
mod u64_empty_string; mod u64_empty_string;
mod u64_string; mod u64_string;
mod viewer; mod viewer;
......
...@@ -6,7 +6,7 @@ use rustc_demangle::demangle; ...@@ -6,7 +6,7 @@ use rustc_demangle::demangle;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use super::TraceFormat; use super::TraceFormat;
use crate::{span::SpanIndex, store_container::StoreContainer, FxIndexMap}; use crate::{span::SpanIndex, store_container::StoreContainer, timestamp::Timestamp, FxIndexMap};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
struct TraceNode { struct TraceNode {
...@@ -87,7 +87,7 @@ struct TraceData { ...@@ -87,7 +87,7 @@ struct TraceData {
pub struct HeaptrackFormat { pub struct HeaptrackFormat {
store: Arc<StoreContainer>, store: Arc<StoreContainer>,
version: u32, version: u32,
last_timestamp: u64, last_timestamp: Timestamp,
strings: Vec<String>, strings: Vec<String>,
traces: Vec<TraceData>, traces: Vec<TraceData>,
ip_parent_map: FxHashMap<(usize, SpanIndex), usize>, ip_parent_map: FxHashMap<(usize, SpanIndex), usize>,
...@@ -109,7 +109,7 @@ impl HeaptrackFormat { ...@@ -109,7 +109,7 @@ impl HeaptrackFormat {
Self { Self {
store, store,
version: 0, version: 0,
last_timestamp: 0, last_timestamp: Timestamp::ZERO,
strings: vec!["".to_string()], strings: vec!["".to_string()],
traces: vec![TraceData { traces: vec![TraceData {
span_index: SpanIndex::new(usize::MAX).unwrap(), span_index: SpanIndex::new(usize::MAX).unwrap(),
...@@ -411,7 +411,7 @@ impl TraceFormat for HeaptrackFormat { ...@@ -411,7 +411,7 @@ impl TraceFormat for HeaptrackFormat {
b'c' => { b'c' => {
// timestamp // timestamp
let timestamp = read_hex(&mut line)?; let timestamp = read_hex(&mut line)?;
self.last_timestamp = timestamp; self.last_timestamp = Timestamp::from_micros(timestamp);
} }
b'a' => { b'a' => {
// allocation info // allocation info
......
...@@ -4,7 +4,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; ...@@ -4,7 +4,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
use serde::Deserialize; use serde::Deserialize;
use super::TraceFormat; use super::TraceFormat;
use crate::{span::SpanIndex, store_container::StoreContainer, FxIndexMap}; use crate::{span::SpanIndex, store_container::StoreContainer, timestamp::Timestamp, FxIndexMap};
pub struct NextJsFormat { pub struct NextJsFormat {
store: Arc<StoreContainer>, store: Arc<StoreContainer>,
...@@ -51,6 +51,8 @@ impl TraceFormat for NextJsFormat { ...@@ -51,6 +51,8 @@ impl TraceFormat for NextJsFormat {
start_time: _, start_time: _,
trace_id: _, trace_id: _,
} = span; } = span;
let timestamp = Timestamp::from_micros(timestamp);
let duration = Timestamp::from_micros(duration);
let (parent, queue_parent) = if let Some(parent) = parent_id { let (parent, queue_parent) = if let Some(parent) = parent_id {
if let Some(parent) = self.id_mapping.get(&parent) { if let Some(parent) = self.id_mapping.get(&parent) {
(Some(*parent), None) (Some(*parent), None)
......
...@@ -14,6 +14,7 @@ use super::TraceFormat; ...@@ -14,6 +14,7 @@ use super::TraceFormat;
use crate::{ use crate::{
span::SpanIndex, span::SpanIndex,
store_container::{StoreContainer, StoreWriteGuard}, store_container::{StoreContainer, StoreWriteGuard},
timestamp::Timestamp,
FxIndexMap, FxIndexMap,
}; };
...@@ -42,20 +43,20 @@ impl InternalRow<'_> { ...@@ -42,20 +43,20 @@ impl InternalRow<'_> {
enum InternalRowType<'a> { enum InternalRowType<'a> {
Start { Start {
new_id: u64, new_id: u64,
ts: u64, ts: Timestamp,
name: Cow<'a, str>, name: Cow<'a, str>,
target: Cow<'a, str>, target: Cow<'a, str>,
values: Vec<(Cow<'a, str>, TraceValue<'a>)>, values: Vec<(Cow<'a, str>, TraceValue<'a>)>,
}, },
End { End {
ts: u64, ts: Timestamp,
}, },
SelfTime { SelfTime {
start: u64, start: Timestamp,
end: u64, end: Timestamp,
}, },
Event { Event {
ts: u64, ts: Timestamp,
values: Vec<(Cow<'a, str>, TraceValue<'a>)>, values: Vec<(Cow<'a, str>, TraceValue<'a>)>,
}, },
Record { Record {
...@@ -135,7 +136,7 @@ pub struct TurbopackFormat { ...@@ -135,7 +136,7 @@ pub struct TurbopackFormat {
outdated_spans: FxHashSet<SpanIndex>, outdated_spans: FxHashSet<SpanIndex>,
thread_stacks: FxHashMap<u64, Vec<u64>>, thread_stacks: FxHashMap<u64, Vec<u64>>,
thread_allocation_counters: FxHashMap<u64, AllocationInfo>, thread_allocation_counters: FxHashMap<u64, AllocationInfo>,
self_time_started: FxHashMap<(u64, u64), u64>, self_time_started: FxHashMap<(u64, u64), Timestamp>,
} }
impl TurbopackFormat { impl TurbopackFormat {
...@@ -161,6 +162,7 @@ impl TurbopackFormat { ...@@ -161,6 +162,7 @@ impl TurbopackFormat {
target, target,
values, values,
} => { } => {
let ts = Timestamp::from_micros(ts);
self.process_internal_row( self.process_internal_row(
store, store,
InternalRow { InternalRow {
...@@ -185,6 +187,7 @@ impl TurbopackFormat { ...@@ -185,6 +187,7 @@ impl TurbopackFormat {
); );
} }
TraceRow::End { ts, id } => { TraceRow::End { ts, id } => {
let ts = Timestamp::from_micros(ts);
self.process_internal_row( self.process_internal_row(
store, store,
InternalRow { InternalRow {
...@@ -194,6 +197,7 @@ impl TurbopackFormat { ...@@ -194,6 +197,7 @@ impl TurbopackFormat {
); );
} }
TraceRow::Enter { ts, id, thread_id } => { TraceRow::Enter { ts, id, thread_id } => {
let ts = Timestamp::from_micros(ts);
let stack = self.thread_stacks.entry(thread_id).or_default(); let stack = self.thread_stacks.entry(thread_id).or_default();
if let Some(&parent) = stack.last() { if let Some(&parent) = stack.last() {
if let Some(parent_start) = self.self_time_started.remove(&(parent, thread_id)) if let Some(parent_start) = self.self_time_started.remove(&(parent, thread_id))
...@@ -218,6 +222,7 @@ impl TurbopackFormat { ...@@ -218,6 +222,7 @@ impl TurbopackFormat {
self.self_time_started.insert((id, thread_id), ts); self.self_time_started.insert((id, thread_id), ts);
} }
TraceRow::Exit { ts, id, thread_id } => { TraceRow::Exit { ts, id, thread_id } => {
let ts = Timestamp::from_micros(ts);
let stack = self.thread_stacks.entry(thread_id).or_default(); let stack = self.thread_stacks.entry(thread_id).or_default();
if let Some(pos) = stack.iter().rev().position(|&x| x == id) { if let Some(pos) = stack.iter().rev().position(|&x| x == id) {
let stack_index = stack.len() - pos - 1; let stack_index = stack.len() - pos - 1;
...@@ -238,6 +243,7 @@ impl TurbopackFormat { ...@@ -238,6 +243,7 @@ impl TurbopackFormat {
} }
} }
TraceRow::Event { ts, parent, values } => { TraceRow::Event { ts, parent, values } => {
let ts = Timestamp::from_micros(ts);
self.process_internal_row( self.process_internal_row(
store, store,
InternalRow { InternalRow {
...@@ -404,10 +410,12 @@ impl TurbopackFormat { ...@@ -404,10 +410,12 @@ impl TurbopackFormat {
} }
InternalRowType::Event { ts, values } => { InternalRowType::Event { ts, values } => {
let mut values = values.into_iter().collect::<FxIndexMap<_, _>>(); let mut values = values.into_iter().collect::<FxIndexMap<_, _>>();
let duration = values let duration = Timestamp::from_micros(
.swap_remove("duration") values
.and_then(|v| v.as_u64()) .swap_remove("duration")
.unwrap_or(0); .and_then(|v| v.as_u64())
.unwrap_or(0),
);
let name = values let name = values
.swap_remove("name") .swap_remove("name")
.and_then(|v| v.as_str().map(|s| s.to_string())) .and_then(|v| v.as_str().map(|s| s.to_string()))
......
...@@ -3,6 +3,8 @@ use std::{ ...@@ -3,6 +3,8 @@ use std::{
mem::take, mem::take,
}; };
use crate::timestamp::Timestamp;
const SPLIT_COUNT: usize = 128; const SPLIT_COUNT: usize = 128;
/// Start balancing the tree when there are N times more items on one side. Must be at least 3. /// Start balancing the tree when there are N times more items on one side. Must be at least 3.
const BALANCE_THRESHOLD: usize = 3; const BALANCE_THRESHOLD: usize = 3;
...@@ -14,15 +16,15 @@ pub struct SelfTimeTree<T> { ...@@ -14,15 +16,15 @@ pub struct SelfTimeTree<T> {
} }
struct SelfTimeEntry<T> { struct SelfTimeEntry<T> {
start: u64, start: Timestamp,
end: u64, end: Timestamp,
item: T, item: T,
} }
struct SelfTimeChildren<T> { struct SelfTimeChildren<T> {
/// Entries < split_point /// Entries < split_point
left: SelfTimeTree<T>, left: SelfTimeTree<T>,
split_point: u64, split_point: Timestamp,
/// Entries >= split_point /// Entries >= split_point
right: SelfTimeTree<T>, right: SelfTimeTree<T>,
/// Number of entries in the SelfTimeTree::entries list that overlap the split point /// Number of entries in the SelfTimeTree::entries list that overlap the split point
...@@ -48,7 +50,7 @@ impl<T> SelfTimeTree<T> { ...@@ -48,7 +50,7 @@ impl<T> SelfTimeTree<T> {
self.count self.count
} }
pub fn insert(&mut self, start: u64, end: u64, item: T) { pub fn insert(&mut self, start: Timestamp, end: Timestamp, item: T) {
self.count += 1; self.count += 1;
self.entries.push(SelfTimeEntry { start, end, item }); self.entries.push(SelfTimeEntry { start, end, item });
self.check_for_split(); self.check_for_split();
...@@ -187,8 +189,8 @@ impl<T> SelfTimeTree<T> { ...@@ -187,8 +189,8 @@ impl<T> SelfTimeTree<T> {
} }
} }
pub fn lookup_range_count(&self, start: u64, end: u64) -> u64 { pub fn lookup_range_count(&self, start: Timestamp, end: Timestamp) -> Timestamp {
let mut total_count = 0; let mut total_count = Timestamp::ZERO;
for entry in &self.entries { for entry in &self.entries {
if entry.start < end && entry.end > start { if entry.start < end && entry.end > start {
let start = max(entry.start, start); let start = max(entry.start, start);
...@@ -208,11 +210,21 @@ impl<T> SelfTimeTree<T> { ...@@ -208,11 +210,21 @@ impl<T> SelfTimeTree<T> {
total_count total_count
} }
pub fn for_each_in_range(&self, start: u64, end: u64, mut f: impl FnMut(u64, u64, &T)) { pub fn for_each_in_range(
&self,
start: Timestamp,
end: Timestamp,
mut f: impl FnMut(Timestamp, Timestamp, &T),
) {
self.for_each_in_range_ref(start, end, &mut f); self.for_each_in_range_ref(start, end, &mut f);
} }
fn for_each_in_range_ref(&self, start: u64, end: u64, f: &mut impl FnMut(u64, u64, &T)) { fn for_each_in_range_ref(
&self,
start: Timestamp,
end: Timestamp,
f: &mut impl FnMut(Timestamp, Timestamp, &T),
) {
for entry in &self.entries { for entry in &self.entries {
if entry.start < end && entry.end > start { if entry.start < end && entry.end > start {
f(entry.start, entry.end, &entry.item); f(entry.start, entry.end, &entry.item);
...@@ -276,11 +288,14 @@ mod tests { ...@@ -276,11 +288,14 @@ mod tests {
let mut tree = SelfTimeTree::new(); let mut tree = SelfTimeTree::new();
let count = 10000; let count = 10000;
for i in 0..count { for i in 0..count {
tree.insert(i, i + 1, i); tree.insert(Timestamp::from_micros(i), Timestamp::from_micros(i + 1), i);
assert_eq!(tree.count, (i + 1) as usize); assert_eq!(tree.count, (i + 1) as usize);
assert_balanced(&tree); assert_balanced(&tree);
} }
assert_eq!(tree.lookup_range_count(0, count), count); assert_eq!(
tree.lookup_range_count(Timestamp::ZERO, Timestamp::from_micros(count)),
Timestamp::from_micros(count)
);
print_tree(&tree, 0); print_tree(&tree, 0);
assert_balanced(&tree); assert_balanced(&tree);
} }
...@@ -294,13 +309,16 @@ mod tests { ...@@ -294,13 +309,16 @@ mod tests {
for c in 0..10 { for c in 0..10 {
for d in 0..10 { for d in 0..10 {
let i = d * 1000 + c * 100 + b * 10 + a; let i = d * 1000 + c * 100 + b * 10 + a;
tree.insert(i, i + 1, i); tree.insert(Timestamp::from_micros(i), Timestamp::from_micros(i + 1), i);
assert_balanced(&tree); assert_balanced(&tree);
} }
} }
} }
} }
assert_eq!(tree.lookup_range_count(0, count), count); assert_eq!(
tree.lookup_range_count(Timestamp::ZERO, Timestamp::from_micros(count)),
Timestamp::from_micros(count)
);
print_tree(&tree, 0); print_tree(&tree, 0);
assert_balanced(&tree); assert_balanced(&tree);
} }
...@@ -310,11 +328,18 @@ mod tests { ...@@ -310,11 +328,18 @@ mod tests {
let mut tree = SelfTimeTree::new(); let mut tree = SelfTimeTree::new();
let count = 10000; let count = 10000;
for i in 0..count { for i in 0..count {
tree.insert(i, i + 100, i); tree.insert(
Timestamp::from_micros(i),
Timestamp::from_micros(i + 100),
i,
);
assert_eq!(tree.count, (i + 1) as usize); assert_eq!(tree.count, (i + 1) as usize);
assert_balanced(&tree); assert_balanced(&tree);
} }
assert_eq!(tree.lookup_range_count(0, count + 100), count * 100); assert_eq!(
tree.lookup_range_count(Timestamp::ZERO, Timestamp::from_micros(count + 100)),
Timestamp::from_micros(count * 100)
);
print_tree(&tree, 0); print_tree(&tree, 0);
assert_balanced(&tree); assert_balanced(&tree);
} }
...@@ -324,10 +349,17 @@ mod tests { ...@@ -324,10 +349,17 @@ mod tests {
let mut tree = SelfTimeTree::new(); let mut tree = SelfTimeTree::new();
let count = 10000; let count = 10000;
for i in 0..count { for i in 0..count {
tree.insert(i, i + 500, i); tree.insert(
Timestamp::from_micros(i),
Timestamp::from_micros(i + 500),
i,
);
assert_eq!(tree.count, (i + 1) as usize); assert_eq!(tree.count, (i + 1) as usize);
} }
assert_eq!(tree.lookup_range_count(0, count + 500), count * 500); assert_eq!(
tree.lookup_range_count(Timestamp::ZERO, Timestamp::from_micros(count + 500)),
Timestamp::from_micros(count * 500)
);
print_tree(&tree, 0); print_tree(&tree, 0);
assert_balanced(&tree); assert_balanced(&tree);
} }
......
...@@ -11,6 +11,7 @@ use tungstenite::{accept, Message}; ...@@ -11,6 +11,7 @@ use tungstenite::{accept, Message};
use crate::{ use crate::{
store::SpanId, store::SpanId,
store_container::StoreContainer, store_container::StoreContainer,
timestamp::Timestamp,
u64_string, u64_string,
viewer::{Update, ViewLineUpdate, ViewMode, Viewer}, viewer::{Update, ViewLineUpdate, ViewMode, Viewer},
}; };
...@@ -32,10 +33,10 @@ pub enum ServerToClientMessage { ...@@ -32,10 +33,10 @@ pub enum ServerToClientMessage {
#[serde(with = "u64_string")] #[serde(with = "u64_string")]
id: SpanId, id: SpanId,
is_graph: bool, is_graph: bool,
start: u64, start: Timestamp,
end: u64, end: Timestamp,
duration: u64, duration: Timestamp,
cpu: u64, cpu: Timestamp,
allocations: u64, allocations: u64,
deallocations: u64, deallocations: u64,
allocation_count: u64, allocation_count: u64,
...@@ -74,8 +75,8 @@ pub enum ClientToServerMessage { ...@@ -74,8 +75,8 @@ pub enum ClientToServerMessage {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct SpanViewEvent { pub struct SpanViewEvent {
pub start: u64, pub start: Timestamp,
pub duration: u64, pub duration: Timestamp,
pub name: String, pub name: String,
pub id: Option<SpanId>, pub id: Option<SpanId>,
} }
...@@ -312,10 +313,10 @@ fn handle_connection( ...@@ -312,10 +313,10 @@ fn handle_connection(
ServerToClientMessage::QueryResult { ServerToClientMessage::QueryResult {
id, id,
is_graph: false, is_graph: false,
start: 0, start: Timestamp::ZERO,
end: 0, end: Timestamp::ZERO,
duration: 0, duration: Timestamp::ZERO,
cpu: 0, cpu: Timestamp::ZERO,
allocations: 0, allocations: 0,
deallocations: 0, deallocations: 0,
allocation_count: 0, allocation_count: 0,
......
...@@ -5,13 +5,15 @@ use std::{ ...@@ -5,13 +5,15 @@ use std::{
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use crate::timestamp::Timestamp;
pub type SpanIndex = NonZeroUsize; pub type SpanIndex = NonZeroUsize;
pub struct Span { pub struct Span {
// These values won't change after creation: // These values won't change after creation:
pub parent: Option<SpanIndex>, pub parent: Option<SpanIndex>,
pub depth: u32, pub depth: u32,
pub start: u64, pub start: Timestamp,
pub category: String, pub category: String,
pub name: String, pub name: String,
pub args: Vec<(String, String)>, pub args: Vec<(String, String)>,
...@@ -46,16 +48,16 @@ pub struct SpanTimeData { ...@@ -46,16 +48,16 @@ pub struct SpanTimeData {
pub ignore_self_time: bool, pub ignore_self_time: bool,
// This might change during writing: // This might change during writing:
pub self_end: u64, pub self_end: Timestamp,
// These values are computed automatically: // These values are computed automatically:
pub self_time: u64, pub self_time: Timestamp,
// These values are computed when accessed (and maybe deleted during writing): // These values are computed when accessed (and maybe deleted during writing):
pub end: OnceLock<u64>, pub end: OnceLock<Timestamp>,
pub total_time: OnceLock<u64>, pub total_time: OnceLock<Timestamp>,
pub corrected_self_time: OnceLock<u64>, pub corrected_self_time: OnceLock<Timestamp>,
pub corrected_total_time: OnceLock<u64>, pub corrected_total_time: OnceLock<Timestamp>,
} }
#[derive(Default)] #[derive(Default)]
...@@ -99,7 +101,7 @@ impl Span { ...@@ -99,7 +101,7 @@ impl Span {
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
pub enum SpanEvent { pub enum SpanEvent {
SelfTime { start: u64, end: u64 }, SelfTime { start: Timestamp, end: Timestamp },
Child { index: SpanIndex }, Child { index: SpanIndex },
} }
...@@ -108,7 +110,7 @@ pub enum SpanGraphEvent { ...@@ -108,7 +110,7 @@ pub enum SpanGraphEvent {
// TODO(sokra) use events instead of children for visualizing span graphs // TODO(sokra) use events instead of children for visualizing span graphs
#[allow(dead_code)] #[allow(dead_code)]
SelfTime { SelfTime {
duration: u64, duration: Timestamp,
}, },
Child { Child {
child: Arc<SpanGraph>, child: Arc<SpanGraph>,
...@@ -123,19 +125,19 @@ pub struct SpanGraph { ...@@ -123,19 +125,19 @@ pub struct SpanGraph {
// These values are computed when accessed: // These values are computed when accessed:
pub max_depth: OnceLock<u32>, pub max_depth: OnceLock<u32>,
pub events: OnceLock<Vec<SpanGraphEvent>>, pub events: OnceLock<Vec<SpanGraphEvent>>,
pub self_time: OnceLock<u64>, pub self_time: OnceLock<Timestamp>,
pub self_allocations: OnceLock<u64>, pub self_allocations: OnceLock<u64>,
pub self_deallocations: OnceLock<u64>, pub self_deallocations: OnceLock<u64>,
pub self_persistent_allocations: OnceLock<u64>, pub self_persistent_allocations: OnceLock<u64>,
pub self_allocation_count: OnceLock<u64>, pub self_allocation_count: OnceLock<u64>,
pub total_time: OnceLock<u64>, pub total_time: OnceLock<Timestamp>,
pub total_allocations: OnceLock<u64>, pub total_allocations: OnceLock<u64>,
pub total_deallocations: OnceLock<u64>, pub total_deallocations: OnceLock<u64>,
pub total_persistent_allocations: OnceLock<u64>, pub total_persistent_allocations: OnceLock<u64>,
pub total_allocation_count: OnceLock<u64>, pub total_allocation_count: OnceLock<u64>,
pub total_span_count: OnceLock<u64>, pub total_span_count: OnceLock<u64>,
pub corrected_self_time: OnceLock<u64>, pub corrected_self_time: OnceLock<Timestamp>,
pub corrected_total_time: OnceLock<u64>, pub corrected_total_time: OnceLock<Timestamp>,
pub bottom_up: OnceLock<Vec<Arc<SpanBottomUp>>>, pub bottom_up: OnceLock<Vec<Arc<SpanBottomUp>>>,
} }
...@@ -148,8 +150,8 @@ pub struct SpanBottomUp { ...@@ -148,8 +150,8 @@ pub struct SpanBottomUp {
// These values are computed when accessed: // These values are computed when accessed:
pub max_depth: OnceLock<u32>, pub max_depth: OnceLock<u32>,
pub events: OnceLock<Vec<SpanGraphEvent>>, pub events: OnceLock<Vec<SpanGraphEvent>>,
pub self_time: OnceLock<u64>, pub self_time: OnceLock<Timestamp>,
pub corrected_self_time: OnceLock<u64>, pub corrected_self_time: OnceLock<Timestamp>,
pub self_allocations: OnceLock<u64>, pub self_allocations: OnceLock<u64>,
pub self_deallocations: OnceLock<u64>, pub self_deallocations: OnceLock<u64>,
pub self_persistent_allocations: OnceLock<u64>, pub self_persistent_allocations: OnceLock<u64>,
......
...@@ -9,6 +9,7 @@ use crate::{ ...@@ -9,6 +9,7 @@ use crate::{
span_graph_ref::{event_map_to_list, SpanGraphEventRef, SpanGraphRef}, span_graph_ref::{event_map_to_list, SpanGraphEventRef, SpanGraphRef},
span_ref::SpanRef, span_ref::SpanRef,
store::{SpanId, Store}, store::{SpanId, Store},
timestamp::Timestamp,
FxIndexMap, FxIndexMap,
}; };
...@@ -128,14 +129,14 @@ impl<'a> SpanBottomUpRef<'a> { ...@@ -128,14 +129,14 @@ impl<'a> SpanBottomUpRef<'a> {
}) })
} }
pub fn corrected_self_time(&self) -> u64 { pub fn corrected_self_time(&self) -> Timestamp {
*self *self
.bottom_up .bottom_up
.corrected_self_time .corrected_self_time
.get_or_init(|| self.spans().map(|span| span.corrected_self_time()).sum()) .get_or_init(|| self.spans().map(|span| span.corrected_self_time()).sum())
} }
pub fn self_time(&self) -> u64 { pub fn self_time(&self) -> Timestamp {
*self *self
.bottom_up .bottom_up
.self_time .self_time
......
...@@ -12,6 +12,7 @@ use crate::{ ...@@ -12,6 +12,7 @@ use crate::{
span_bottom_up_ref::SpanBottomUpRef, span_bottom_up_ref::SpanBottomUpRef,
span_ref::SpanRef, span_ref::SpanRef,
store::{SpanId, Store}, store::{SpanId, Store},
timestamp::Timestamp,
FxIndexMap, FxIndexMap,
}; };
...@@ -175,7 +176,7 @@ impl<'a> SpanGraphRef<'a> { ...@@ -175,7 +176,7 @@ impl<'a> SpanGraphRef<'a> {
}) })
} }
pub fn self_time(&self) -> u64 { pub fn self_time(&self) -> Timestamp {
*self.graph.self_time.get_or_init(|| { *self.graph.self_time.get_or_init(|| {
self.recursive_spans() self.recursive_spans()
.map(|span| span.self_time()) .map(|span| span.self_time())
...@@ -184,7 +185,7 @@ impl<'a> SpanGraphRef<'a> { ...@@ -184,7 +185,7 @@ impl<'a> SpanGraphRef<'a> {
}) })
} }
pub fn total_time(&self) -> u64 { pub fn total_time(&self) -> Timestamp {
*self.graph.total_time.get_or_init(|| { *self.graph.total_time.get_or_init(|| {
self.children() self.children()
.map(|graph| graph.total_time()) .map(|graph| graph.total_time())
...@@ -284,19 +285,19 @@ impl<'a> SpanGraphRef<'a> { ...@@ -284,19 +285,19 @@ impl<'a> SpanGraphRef<'a> {
}) })
} }
pub fn corrected_self_time(&self) -> u64 { pub fn corrected_self_time(&self) -> Timestamp {
*self.graph.corrected_self_time.get_or_init(|| { *self.graph.corrected_self_time.get_or_init(|| {
self.recursive_spans_par() self.recursive_spans_par()
.map(|span| span.corrected_self_time()) .map(|span| span.corrected_self_time())
.sum::<u64>() .sum::<Timestamp>()
}) })
} }
pub fn corrected_total_time(&self) -> u64 { pub fn corrected_total_time(&self) -> Timestamp {
*self.graph.corrected_total_time.get_or_init(|| { *self.graph.corrected_total_time.get_or_init(|| {
self.children_par() self.children_par()
.map(|graph| graph.corrected_total_time()) .map(|graph| graph.corrected_total_time())
.sum::<u64>() .sum::<Timestamp>()
+ self.corrected_self_time() + self.corrected_self_time()
}) })
} }
...@@ -353,19 +354,19 @@ impl Debug for SpanGraphRef<'_> { ...@@ -353,19 +354,19 @@ impl Debug for SpanGraphRef<'_> {
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Clone)] #[derive(Clone)]
pub enum SpanGraphEventRef<'a> { pub enum SpanGraphEventRef<'a> {
SelfTime { duration: u64 }, SelfTime { duration: Timestamp },
Child { graph: SpanGraphRef<'a> }, Child { graph: SpanGraphRef<'a> },
} }
impl SpanGraphEventRef<'_> { impl SpanGraphEventRef<'_> {
pub fn corrected_total_time(&self) -> u64 { pub fn corrected_total_time(&self) -> Timestamp {
match self { match self {
SpanGraphEventRef::SelfTime { duration } => *duration, SpanGraphEventRef::SelfTime { duration } => *duration,
SpanGraphEventRef::Child { graph } => graph.corrected_total_time(), SpanGraphEventRef::Child { graph } => graph.corrected_total_time(),
} }
} }
pub fn total_time(&self) -> u64 { pub fn total_time(&self) -> Timestamp {
match self { match self {
SpanGraphEventRef::SelfTime { duration } => *duration, SpanGraphEventRef::SelfTime { duration } => *duration,
SpanGraphEventRef::Child { graph } => graph.total_time(), SpanGraphEventRef::Child { graph } => graph.total_time(),
......
...@@ -14,6 +14,7 @@ use crate::{ ...@@ -14,6 +14,7 @@ use crate::{
span_bottom_up_ref::SpanBottomUpRef, span_bottom_up_ref::SpanBottomUpRef,
span_graph_ref::{event_map_to_list, SpanGraphEventRef, SpanGraphRef}, span_graph_ref::{event_map_to_list, SpanGraphEventRef, SpanGraphRef},
store::{SpanId, Store}, store::{SpanId, Store},
timestamp::Timestamp,
FxIndexMap, FxIndexMap,
}; };
...@@ -41,7 +42,7 @@ impl<'a> SpanRef<'a> { ...@@ -41,7 +42,7 @@ impl<'a> SpanRef<'a> {
}) })
} }
pub fn start(&self) -> u64 { pub fn start(&self) -> Timestamp {
self.span.start self.span.start
} }
...@@ -57,7 +58,7 @@ impl<'a> SpanRef<'a> { ...@@ -57,7 +58,7 @@ impl<'a> SpanRef<'a> {
self.span.names() self.span.names()
} }
pub fn end(&self) -> u64 { pub fn end(&self) -> Timestamp {
let time_data = self.time_data(); let time_data = self.time_data();
*time_data.end.get_or_init(|| { *time_data.end.get_or_init(|| {
max( max(
...@@ -137,7 +138,7 @@ impl<'a> SpanRef<'a> { ...@@ -137,7 +138,7 @@ impl<'a> SpanRef<'a> {
self.span.args.iter().map(|(k, v)| (k.as_str(), v.as_str())) self.span.args.iter().map(|(k, v)| (k.as_str(), v.as_str()))
} }
pub fn self_time(&self) -> u64 { pub fn self_time(&self) -> Timestamp {
self.time_data().self_time self.time_data().self_time
} }
...@@ -207,7 +208,7 @@ impl<'a> SpanRef<'a> { ...@@ -207,7 +208,7 @@ impl<'a> SpanRef<'a> {
}) })
} }
pub fn total_time(&self) -> u64 { pub fn total_time(&self) -> Timestamp {
*self.time_data().total_time.get_or_init(|| { *self.time_data().total_time.get_or_init(|| {
self.children() self.children()
.map(|child| child.total_time()) .map(|child| child.total_time())
...@@ -267,7 +268,7 @@ impl<'a> SpanRef<'a> { ...@@ -267,7 +268,7 @@ impl<'a> SpanRef<'a> {
}) })
} }
pub fn corrected_self_time(&self) -> u64 { pub fn corrected_self_time(&self) -> Timestamp {
let store = self.store; let store = self.store;
*self.time_data().corrected_self_time.get_or_init(|| { *self.time_data().corrected_self_time.get_or_init(|| {
let mut self_time = self let mut self_time = self
...@@ -276,31 +277,31 @@ impl<'a> SpanRef<'a> { ...@@ -276,31 +277,31 @@ impl<'a> SpanRef<'a> {
.par_iter() .par_iter()
.filter_map(|event| { .filter_map(|event| {
if let SpanEvent::SelfTime { start, end } = event { if let SpanEvent::SelfTime { start, end } = event {
let duration = end - start; let duration = *end - *start;
if duration != 0 { if !duration.is_zero() {
store.set_max_self_time_lookup(*end); store.set_max_self_time_lookup(*end);
let concurrent_time = store let concurrent_time = store
.self_time_tree .self_time_tree
.as_ref() .as_ref()
.map_or(duration, |tree| tree.lookup_range_count(*start, *end)); .map_or(duration, |tree| tree.lookup_range_count(*start, *end));
return Some(duration * duration / concurrent_time); return Some(duration * *duration / *concurrent_time);
} }
} }
None None
}) })
.sum(); .sum();
if self.children().next().is_none() { if self.children().next().is_none() {
self_time = max(self_time, 1); self_time = max(self_time, Timestamp::from_value(1));
} }
self_time self_time
}) })
} }
pub fn corrected_total_time(&self) -> u64 { pub fn corrected_total_time(&self) -> Timestamp {
*self.time_data().corrected_total_time.get_or_init(|| { *self.time_data().corrected_total_time.get_or_init(|| {
self.children_par() self.children_par()
.map(|child| child.corrected_total_time()) .map(|child| child.corrected_total_time())
.sum::<u64>() .sum::<Timestamp>()
+ self.corrected_self_time() + self.corrected_self_time()
}) })
} }
...@@ -478,6 +479,6 @@ impl Debug for SpanRef<'_> { ...@@ -478,6 +479,6 @@ impl Debug for SpanRef<'_> {
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub enum SpanEventRef<'a> { pub enum SpanEventRef<'a> {
SelfTime { start: u64, end: u64 }, SelfTime { start: Timestamp, end: Timestamp },
Child { span: SpanRef<'a> }, Child { span: SpanRef<'a> },
} }
...@@ -12,6 +12,7 @@ use crate::{ ...@@ -12,6 +12,7 @@ use crate::{
self_time_tree::SelfTimeTree, self_time_tree::SelfTimeTree,
span::{Span, SpanEvent, SpanIndex}, span::{Span, SpanEvent, SpanIndex},
span_ref::SpanRef, span_ref::SpanRef,
timestamp::Timestamp,
}; };
pub type SpanId = NonZeroUsize; pub type SpanId = NonZeroUsize;
...@@ -28,7 +29,7 @@ fn new_root_span() -> Span { ...@@ -28,7 +29,7 @@ fn new_root_span() -> Span {
Span { Span {
parent: None, parent: None,
depth: 0, depth: 0,
start: u64::MAX, start: Timestamp::MAX,
category: "".into(), category: "".into(),
name: "(root)".into(), name: "(root)".into(),
args: vec![], args: vec![],
...@@ -80,7 +81,7 @@ impl Store { ...@@ -80,7 +81,7 @@ impl Store {
pub fn add_span( pub fn add_span(
&mut self, &mut self,
parent: Option<SpanIndex>, parent: Option<SpanIndex>,
start: u64, start: Timestamp,
category: String, category: String,
name: String, name: String,
args: Vec<(String, String)>, args: Vec<(String, String)>,
...@@ -137,7 +138,8 @@ impl Store { ...@@ -137,7 +138,8 @@ impl Store {
outdated_spans.insert(span_index); outdated_spans.insert(span_index);
} }
pub fn set_max_self_time_lookup(&self, time: u64) { pub fn set_max_self_time_lookup(&self, time: Timestamp) {
let time = *time;
let mut old = self let mut old = self
.max_self_time_lookup_time .max_self_time_lookup_time
.load(std::sync::atomic::Ordering::Relaxed); .load(std::sync::atomic::Ordering::Relaxed);
...@@ -156,13 +158,13 @@ impl Store { ...@@ -156,13 +158,13 @@ impl Store {
fn insert_self_time( fn insert_self_time(
&mut self, &mut self,
start: u64, start: Timestamp,
end: u64, end: Timestamp,
span_index: SpanIndex, span_index: SpanIndex,
outdated_spans: &mut FxHashSet<SpanIndex>, outdated_spans: &mut FxHashSet<SpanIndex>,
) { ) {
if let Some(tree) = self.self_time_tree.as_mut() { if let Some(tree) = self.self_time_tree.as_mut() {
if *self.max_self_time_lookup_time.get_mut() >= start { if Timestamp::from_value(*self.max_self_time_lookup_time.get_mut()) >= start {
tree.for_each_in_range(start, end, |_, _, span| { tree.for_each_in_range(start, end, |_, _, span| {
outdated_spans.insert(*span); outdated_spans.insert(*span);
}); });
...@@ -174,8 +176,8 @@ impl Store { ...@@ -174,8 +176,8 @@ impl Store {
pub fn add_self_time( pub fn add_self_time(
&mut self, &mut self,
span_index: SpanIndex, span_index: SpanIndex,
start: u64, start: Timestamp,
end: u64, end: Timestamp,
outdated_spans: &mut FxHashSet<SpanIndex>, outdated_spans: &mut FxHashSet<SpanIndex>,
) { ) {
let span = &mut self.spans[span_index.get()]; let span = &mut self.spans[span_index.get()];
...@@ -193,8 +195,8 @@ impl Store { ...@@ -193,8 +195,8 @@ impl Store {
pub fn set_total_time( pub fn set_total_time(
&mut self, &mut self,
span_index: SpanIndex, span_index: SpanIndex,
start_time: u64, start_time: Timestamp,
total_time: u64, total_time: Timestamp,
outdated_spans: &mut FxHashSet<SpanIndex>, outdated_spans: &mut FxHashSet<SpanIndex>,
) { ) {
let span = SpanRef { let span = SpanRef {
...@@ -208,7 +210,7 @@ impl Store { ...@@ -208,7 +210,7 @@ impl Store {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
children.sort(); children.sort();
let self_end = start_time + total_time; let self_end = start_time + total_time;
let mut self_time = 0; let mut self_time = Timestamp::ZERO;
let mut current = start_time; let mut current = start_time;
let mut events = Vec::new(); let mut events = Vec::new();
for (start, end, index) in children { for (start, end, index) in children {
......
use std::{
fmt::{Debug, Display, Formatter},
iter::Sum,
ops::{Add, AddAssign, Deref, Div, DivAssign, Mul, MulAssign, Sub, SubAssign},
};
use serde::{Deserialize, Serialize};
const DUR_VALUE_MICROSECOND: u64 = 100;
#[derive(Clone, Copy, Default, Serialize, Deserialize)]
pub struct Timestamp(u64);
impl Timestamp {
pub const MAX: Self = Self(u64::MAX);
pub const ZERO: Self = Self(0);
}
impl Timestamp {
pub fn from_micros(micros: u64) -> Self {
Self(micros * DUR_VALUE_MICROSECOND)
}
pub fn is_zero(&self) -> bool {
self.0 == 0
}
pub fn from_value(value: u64) -> Self {
Self(value)
}
pub fn saturating_sub(self, rhs: Self) -> Self {
Self(self.0.saturating_sub(rhs.0))
}
}
impl Debug for Timestamp {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{:.2}μs", self.0 as f64 / DUR_VALUE_MICROSECOND as f64)
}
}
impl Display for Timestamp {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{:.2}μs", self.0 as f64 / DUR_VALUE_MICROSECOND as f64)
}
}
impl Add for Timestamp {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0)
}
}
impl AddAssign for Timestamp {
fn add_assign(&mut self, rhs: Self) {
self.0 += rhs.0;
}
}
impl Sub for Timestamp {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
Self(self.0 - rhs.0)
}
}
impl SubAssign for Timestamp {
fn sub_assign(&mut self, rhs: Self) {
self.0 -= rhs.0;
}
}
impl Div<u64> for Timestamp {
type Output = Self;
fn div(self, rhs: u64) -> Self {
Self(self.0 / rhs)
}
}
impl DivAssign<u64> for Timestamp {
fn div_assign(&mut self, rhs: u64) {
self.0 /= rhs;
}
}
impl Div for Timestamp {
type Output = u64;
fn div(self, rhs: Self) -> u64 {
self.0 / rhs.0
}
}
impl Mul<u64> for Timestamp {
type Output = Self;
fn mul(self, rhs: u64) -> Self {
Self(self.0 * rhs)
}
}
impl MulAssign<u64> for Timestamp {
fn mul_assign(&mut self, rhs: u64) {
self.0 *= rhs;
}
}
impl Sum for Timestamp {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Timestamp(0), |a, b| a + b)
}
}
impl PartialEq for Timestamp {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl Eq for Timestamp {}
impl Ord for Timestamp {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.cmp(&other.0)
}
}
impl PartialOrd for Timestamp {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Deref for Timestamp {
type Target = u64;
fn deref(&self) -> &Self::Target {
&self.0
}
}
...@@ -12,6 +12,7 @@ use crate::{ ...@@ -12,6 +12,7 @@ use crate::{
span_graph_ref::{SpanGraphEventRef, SpanGraphRef}, span_graph_ref::{SpanGraphEventRef, SpanGraphRef},
span_ref::SpanRef, span_ref::SpanRef,
store::{SpanId, Store}, store::{SpanId, Store},
timestamp::Timestamp,
u64_empty_string, u64_empty_string,
}; };
...@@ -55,8 +56,8 @@ impl ValueMode { ...@@ -55,8 +56,8 @@ impl ValueMode {
fn value_from_span(&self, span: &SpanRef<'_>) -> u64 { fn value_from_span(&self, span: &SpanRef<'_>) -> u64 {
match self { match self {
ValueMode::Duration => span.corrected_total_time(), ValueMode::Duration => *span.corrected_total_time(),
ValueMode::Cpu => span.total_time(), ValueMode::Cpu => *span.total_time(),
ValueMode::Allocations => span.total_allocations(), ValueMode::Allocations => span.total_allocations(),
ValueMode::Deallocations => span.total_deallocations(), ValueMode::Deallocations => span.total_deallocations(),
ValueMode::PersistentAllocations => span.total_persistent_allocations(), ValueMode::PersistentAllocations => span.total_persistent_allocations(),
...@@ -77,8 +78,8 @@ impl ValueMode { ...@@ -77,8 +78,8 @@ impl ValueMode {
fn value_from_graph(&self, graph: &SpanGraphRef<'_>) -> u64 { fn value_from_graph(&self, graph: &SpanGraphRef<'_>) -> u64 {
match self { match self {
ValueMode::Duration => graph.corrected_total_time(), ValueMode::Duration => *graph.corrected_total_time(),
ValueMode::Cpu => graph.total_time(), ValueMode::Cpu => *graph.total_time(),
ValueMode::Allocations => graph.total_allocations(), ValueMode::Allocations => graph.total_allocations(),
ValueMode::Deallocations => graph.total_deallocations(), ValueMode::Deallocations => graph.total_deallocations(),
ValueMode::PersistentAllocations => graph.total_persistent_allocations(), ValueMode::PersistentAllocations => graph.total_persistent_allocations(),
...@@ -99,8 +100,8 @@ impl ValueMode { ...@@ -99,8 +100,8 @@ impl ValueMode {
fn value_from_graph_event(&self, event: &SpanGraphEventRef<'_>) -> u64 { fn value_from_graph_event(&self, event: &SpanGraphEventRef<'_>) -> u64 {
match self { match self {
ValueMode::Duration => event.corrected_total_time(), ValueMode::Duration => *event.corrected_total_time(),
ValueMode::Cpu => event.total_time(), ValueMode::Cpu => *event.total_time(),
ValueMode::Allocations => event.total_allocations(), ValueMode::Allocations => event.total_allocations(),
ValueMode::Deallocations => event.total_deallocations(), ValueMode::Deallocations => event.total_deallocations(),
ValueMode::PersistentAllocations => event.total_persistent_allocations(), ValueMode::PersistentAllocations => event.total_persistent_allocations(),
...@@ -121,8 +122,8 @@ impl ValueMode { ...@@ -121,8 +122,8 @@ impl ValueMode {
fn value_from_bottom_up(&self, bottom_up: &SpanBottomUpRef<'_>) -> u64 { fn value_from_bottom_up(&self, bottom_up: &SpanBottomUpRef<'_>) -> u64 {
match self { match self {
ValueMode::Duration => bottom_up.corrected_self_time(), ValueMode::Duration => *bottom_up.corrected_self_time(),
ValueMode::Cpu => bottom_up.self_time(), ValueMode::Cpu => *bottom_up.self_time(),
ValueMode::Allocations => bottom_up.self_allocations(), ValueMode::Allocations => bottom_up.self_allocations(),
ValueMode::Deallocations => bottom_up.self_deallocations(), ValueMode::Deallocations => bottom_up.self_deallocations(),
ValueMode::PersistentAllocations => bottom_up.self_persistent_allocations(), ValueMode::PersistentAllocations => bottom_up.self_persistent_allocations(),
...@@ -145,8 +146,8 @@ impl ValueMode { ...@@ -145,8 +146,8 @@ impl ValueMode {
fn value_from_bottom_up_span(&self, bottom_up_span: &SpanRef<'_>) -> u64 { fn value_from_bottom_up_span(&self, bottom_up_span: &SpanRef<'_>) -> u64 {
match self { match self {
ValueMode::Duration => bottom_up_span.corrected_self_time(), ValueMode::Duration => *bottom_up_span.corrected_self_time(),
ValueMode::Cpu => bottom_up_span.self_time(), ValueMode::Cpu => *bottom_up_span.self_time(),
ValueMode::Allocations => bottom_up_span.self_allocations(), ValueMode::Allocations => bottom_up_span.self_allocations(),
ValueMode::Deallocations => bottom_up_span.self_deallocations(), ValueMode::Deallocations => bottom_up_span.self_deallocations(),
ValueMode::PersistentAllocations => bottom_up_span.self_persistent_allocations(), ValueMode::PersistentAllocations => bottom_up_span.self_persistent_allocations(),
...@@ -171,11 +172,11 @@ impl ValueMode { ...@@ -171,11 +172,11 @@ impl ValueMode {
/// this is unfortunately int division but itll have to do. /// this is unfortunately int division but itll have to do.
/// ///
/// cases where count per time is very low is probably not important /// cases where count per time is very low is probably not important
fn value_over_time(value: u64, time: u64) -> u64 { fn value_over_time(value: u64, time: Timestamp) -> u64 {
if time == 0 { if *time == 0 {
0 0
} else { } else {
value / time value / *time
} }
} }
...@@ -447,7 +448,7 @@ impl Viewer { ...@@ -447,7 +448,7 @@ impl Viewer {
let offset = root_spans let offset = root_spans
.iter() .iter()
.min_by_key(|span| span.start()) .min_by_key(|span| span.start())
.map_or(0, |span| span.start()); .map_or(Timestamp::ZERO, |span| span.start());
root_spans.par_iter().for_each(|span| { root_spans.par_iter().for_each(|span| {
span.max_depth(); span.max_depth();
QueueItem::Span(*span).value(value_mode); QueueItem::Span(*span).value(value_mode);
...@@ -455,7 +456,7 @@ impl Viewer { ...@@ -455,7 +456,7 @@ impl Viewer {
for span in root_spans { for span in root_spans {
if matches!(value_mode, ValueMode::Duration) { if matches!(value_mode, ValueMode::Duration) {
// Move current to start if needed. // Move current to start if needed.
current = max(current, span.start() - offset); current = max(current, *(span.start() - offset));
} }
if add_child_item( if add_child_item(
&mut children, &mut children,
...@@ -976,7 +977,7 @@ impl Viewer { ...@@ -976,7 +977,7 @@ impl Viewer {
if let Some(parent) = span.parent() { if let Some(parent) = span.parent() {
let parent_start = parent.start(); let parent_start = parent.start();
let parent_duration = parent.end() - parent_start; let parent_duration = parent.end() - parent_start;
if parent_duration > 0 { if !parent_duration.is_zero() {
start_in_parent = ((span.start() - parent_start) * 10000 start_in_parent = ((span.start() - parent_start) * 10000
/ parent_duration) / parent_duration)
as u32; as u32;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment