aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/profile/time.rs
diff options
context:
space:
mode:
authorDelan Azabani <dazabani@igalia.com>2024-11-15 17:10:01 +0800
committerGitHub <noreply@github.com>2024-11-15 09:10:01 +0000
commitaa7116c75d2f13f554ce4db162344aaea59e60b0 (patch)
tree6b23fa65221101ac202e0742dc749c255627beb1 /components/shared/profile/time.rs
parent495cceb7de813f6f1936d77821e8cf04ca2857cd (diff)
downloadservo-aa7116c75d2f13f554ce4db162344aaea59e60b0.tar.gz
servo-aa7116c75d2f13f554ce4db162344aaea59e60b0.zip
Plumb time profiler output into tracing (#34238)
* Plumb time profiler output into tracing Signed-off-by: Delan Azabani <dazabani@igalia.com> * Enter the span tightly around the callback Signed-off-by: Delan Azabani <dazabani@igalia.com> * Use `info_span!()` shorthand Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
Diffstat (limited to 'components/shared/profile/time.rs')
-rw-r--r--components/shared/profile/time.rs78
1 files changed, 77 insertions, 1 deletions
diff --git a/components/shared/profile/time.rs b/components/shared/profile/time.rs
index 62ac03f3e0f..f52b087095d 100644
--- a/components/shared/profile/time.rs
+++ b/components/shared/profile/time.rs
@@ -118,6 +118,71 @@ pub enum ProfilerCategory {
IpcBytesReceiver = 0x84,
}
+impl ProfilerCategory {
+ pub const fn variant_name(&self) -> &'static str {
+ match self {
+ ProfilerCategory::Compositing => "Compositing",
+ ProfilerCategory::LayoutPerform => "LayoutPerform",
+ ProfilerCategory::LayoutStyleRecalc => "LayoutStyleRecalc",
+ ProfilerCategory::LayoutTextShaping => "LayoutTextShaping",
+ ProfilerCategory::LayoutRestyleDamagePropagation => "LayoutRestyleDamagePropagation",
+ ProfilerCategory::LayoutNonIncrementalReset => "LayoutNonIncrementalReset",
+ ProfilerCategory::LayoutSelectorMatch => "LayoutSelectorMatch",
+ ProfilerCategory::LayoutTreeBuilder => "LayoutTreeBuilder",
+ ProfilerCategory::LayoutDamagePropagate => "LayoutDamagePropagate",
+ ProfilerCategory::LayoutGeneratedContent => "LayoutGeneratedContent",
+ ProfilerCategory::LayoutDisplayListSorting => "LayoutDisplayListSorting",
+ ProfilerCategory::LayoutFloatPlacementSpeculation => "LayoutFloatPlacementSpeculation",
+ ProfilerCategory::LayoutMain => "LayoutMain",
+ ProfilerCategory::LayoutStoreOverflow => "LayoutStoreOverflow",
+ ProfilerCategory::LayoutParallelWarmup => "LayoutParallelWarmup",
+ ProfilerCategory::LayoutDispListBuild => "LayoutDispListBuild",
+ ProfilerCategory::NetHTTPRequestResponse => "NetHTTPRequestResponse",
+ ProfilerCategory::PaintingPerTile => "PaintingPerTile",
+ ProfilerCategory::PaintingPrepBuff => "PaintingPrepBuff",
+ ProfilerCategory::Painting => "Painting",
+ ProfilerCategory::ImageDecoding => "ImageDecoding",
+ ProfilerCategory::ImageSaving => "ImageSaving",
+ ProfilerCategory::ScriptAttachLayout => "ScriptAttachLayout",
+ ProfilerCategory::ScriptConstellationMsg => "ScriptConstellationMsg",
+ ProfilerCategory::ScriptDevtoolsMsg => "ScriptDevtoolsMsg",
+ ProfilerCategory::ScriptDocumentEvent => "ScriptDocumentEvent",
+ ProfilerCategory::ScriptDomEvent => "ScriptDomEvent",
+ ProfilerCategory::ScriptEvaluate => "ScriptEvaluate",
+ ProfilerCategory::ScriptEvent => "ScriptEvent",
+ ProfilerCategory::ScriptFileRead => "ScriptFileRead",
+ ProfilerCategory::ScriptImageCacheMsg => "ScriptImageCacheMsg",
+ ProfilerCategory::ScriptInputEvent => "ScriptInputEvent",
+ ProfilerCategory::ScriptNetworkEvent => "ScriptNetworkEvent",
+ ProfilerCategory::ScriptParseHTML => "ScriptParseHTML",
+ ProfilerCategory::ScriptPlannedNavigation => "ScriptPlannedNavigation",
+ ProfilerCategory::ScriptResize => "ScriptResize",
+ ProfilerCategory::ScriptSetScrollState => "ScriptSetScrollState",
+ ProfilerCategory::ScriptSetViewport => "ScriptSetViewport",
+ ProfilerCategory::ScriptTimerEvent => "ScriptTimerEvent",
+ ProfilerCategory::ScriptStylesheetLoad => "ScriptStylesheetLoad",
+ ProfilerCategory::ScriptUpdateReplacedElement => "ScriptUpdateReplacedElement",
+ ProfilerCategory::ScriptWebSocketEvent => "ScriptWebSocketEvent",
+ ProfilerCategory::ScriptWorkerEvent => "ScriptWorkerEvent",
+ ProfilerCategory::ScriptServiceWorkerEvent => "ScriptServiceWorkerEvent",
+ ProfilerCategory::ScriptParseXML => "ScriptParseXML",
+ ProfilerCategory::ScriptEnterFullscreen => "ScriptEnterFullscreen",
+ ProfilerCategory::ScriptExitFullscreen => "ScriptExitFullscreen",
+ ProfilerCategory::ScriptWebVREvent => "ScriptWebVREvent",
+ ProfilerCategory::ScriptWorkletEvent => "ScriptWorkletEvent",
+ ProfilerCategory::ScriptPerformanceEvent => "ScriptPerformanceEvent",
+ ProfilerCategory::ScriptHistoryEvent => "ScriptHistoryEvent",
+ ProfilerCategory::ScriptPortMessage => "ScriptPortMessage",
+ ProfilerCategory::ScriptWebGPUMsg => "ScriptWebGPUMsg",
+ ProfilerCategory::TimeToFirstPaint => "TimeToFirstPaint",
+ ProfilerCategory::TimeToFirstContentfulPaint => "TimeToFirstContentfulPaint",
+ ProfilerCategory::TimeToInteractive => "TimeToInteractive",
+ ProfilerCategory::IpcReceiver => "IpcReceiver",
+ ProfilerCategory::IpcBytesReceiver => "IpcBytesReceiver",
+ }
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub enum TimerMetadataFrameType {
RootWindow,
@@ -130,10 +195,17 @@ pub enum TimerMetadataReflowType {
FirstReflow,
}
+#[cfg(feature = "tracing")]
+pub type Span = tracing::Span;
+#[cfg(not(feature = "tracing"))]
+pub type Span = ();
+
pub fn profile<T, F>(
category: ProfilerCategory,
meta: Option<TimerMetadata>,
profiler_chan: ProfilerChan,
+ #[cfg(feature = "tracing")] span: Span,
+ #[cfg(not(feature = "tracing"))] _span: Span,
callback: F,
) -> T
where
@@ -143,7 +215,11 @@ where
signpost::start(category as u32, &[0, 0, 0, (category as usize) >> 4]);
}
let start_time = CrossProcessInstant::now();
- let val = callback();
+ let val = {
+ #[cfg(feature = "tracing")]
+ let _enter = span.enter();
+ callback()
+ };
let end_time = CrossProcessInstant::now();
if opts::get().debug.signpost {