Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 2e5413d

Browse files
committed
Bug 1583841 - Add an expected range in ResourceProfileCounter. r=gw
Depends on D49438 Differential Revision: https://phabricator.services.mozilla.com/D49617 --HG-- extra : moz-landing-system : lando
1 parent bfc2b52 commit 2e5413d

1 file changed

Lines changed: 43 additions & 27 deletions

File tree

gfx/wr/webrender/src/profiler.rs

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,25 @@ impl ProfileCounter for PercentageProfileCounter {
339339
pub struct ResourceProfileCounter {
340340
description: &'static str,
341341
value: usize,
342+
// in bytes.
342343
size: usize,
344+
expected_count: Option<Range<usize>>,
345+
// in MB
346+
expected_size: Option<Range<f32>>,
343347
}
344348

345349
impl ResourceProfileCounter {
346-
fn new(description: &'static str) -> Self {
350+
fn new(
351+
description: &'static str,
352+
expected_count: Option<Range<usize>>,
353+
expected_size: Option<Range<f32>>
354+
) -> Self {
347355
ResourceProfileCounter {
348356
description,
349357
value: 0,
350358
size: 0,
359+
expected_count,
360+
expected_size,
351361
}
352362
}
353363

@@ -367,6 +377,10 @@ impl ResourceProfileCounter {
367377
self.value = count;
368378
self.size = size;
369379
}
380+
381+
pub fn size_mb(&self) -> f32 {
382+
self.size as f32 / (1024.0 * 1024.0)
383+
}
370384
}
371385

372386
impl ProfileCounter for ResourceProfileCounter {
@@ -375,11 +389,13 @@ impl ProfileCounter for ResourceProfileCounter {
375389
}
376390

377391
fn value(&self) -> String {
378-
let size = self.size as f32 / (1024.0 * 1024.0);
379-
format!("{} ({:.2} MB)", self.value, size)
392+
format!("{} ({:.2} MB)", self.value, self.size_mb())
380393
}
381394

382-
fn is_expected(&self) -> bool { true }
395+
fn is_expected(&self) -> bool {
396+
self.expected_count.as_ref().map(|range| range.contains(&self.value)).unwrap_or(true)
397+
&& self.expected_size.as_ref().map(|range| range.contains(&self.size_mb())).unwrap_or(true)
398+
}
383399
}
384400

385401
#[derive(Clone)]
@@ -594,12 +610,12 @@ pub struct TextureCacheProfileCounters {
594610
impl TextureCacheProfileCounters {
595611
pub fn new() -> Self {
596612
TextureCacheProfileCounters {
597-
pages_alpha8_linear: ResourceProfileCounter::new("Texture A8 cached pages"),
598-
pages_alpha16_linear: ResourceProfileCounter::new("Texture A16 cached pages"),
599-
pages_color8_linear: ResourceProfileCounter::new("Texture RGBA8 cached pages (L)"),
600-
pages_color8_nearest: ResourceProfileCounter::new("Texture RGBA8 cached pages (N)"),
601-
pages_picture: ResourceProfileCounter::new("Picture cached pages"),
602-
rasterized_blob_pixels: ResourceProfileCounter::new("Rasterized Blob Pixels"),
613+
pages_alpha8_linear: ResourceProfileCounter::new("Texture A8 cached pages", None, None),
614+
pages_alpha16_linear: ResourceProfileCounter::new("Texture A16 cached pages", None, None),
615+
pages_color8_linear: ResourceProfileCounter::new("Texture RGBA8 cached pages (L)", None, None),
616+
pages_color8_nearest: ResourceProfileCounter::new("Texture RGBA8 cached pages (N)", None, None),
617+
pages_picture: ResourceProfileCounter::new("Picture cached pages", None, None),
618+
rasterized_blob_pixels: ResourceProfileCounter::new("Rasterized Blob Pixels", None, None),
603619
}
604620
}
605621
}
@@ -727,8 +743,8 @@ impl BackendProfileCounters {
727743
Some(expected::MAX_BACKEND_CPU_TIME),
728744
),
729745
resources: ResourceProfileCounters {
730-
font_templates: ResourceProfileCounter::new("Font Templates"),
731-
image_templates: ResourceProfileCounter::new("Image Templates"),
746+
font_templates: ResourceProfileCounter::new("Font Templates", None, None),
747+
image_templates: ResourceProfileCounter::new("Image Templates", None, None),
732748
texture_cache: TextureCacheProfileCounters::new(),
733749
gpu_cache: GpuCacheProfileCounters::new(),
734750
},
@@ -749,23 +765,23 @@ impl BackendProfileCounters {
749765
"Total Display List Time", false,
750766
Some(expected::DISPLAY_LIST_TOTAL_TIME),
751767
),
752-
display_lists: ResourceProfileCounter::new("Display Lists Sent"),
768+
display_lists: ResourceProfileCounter::new("Display Lists Sent", None, None),
753769
},
754770
//TODO: generate this by a macro
755771
intern: InternProfileCounters {
756-
prim: ResourceProfileCounter::new("Interned primitives"),
757-
image: ResourceProfileCounter::new("Interned images"),
758-
image_border: ResourceProfileCounter::new("Interned image borders"),
759-
line_decoration: ResourceProfileCounter::new("Interned line decorations"),
760-
linear_grad: ResourceProfileCounter::new("Interned linear gradients"),
761-
normal_border: ResourceProfileCounter::new("Interned normal borders"),
762-
picture: ResourceProfileCounter::new("Interned pictures"),
763-
radial_grad: ResourceProfileCounter::new("Interned radial gradients"),
764-
text_run: ResourceProfileCounter::new("Interned text runs"),
765-
yuv_image: ResourceProfileCounter::new("Interned YUV images"),
766-
clip: ResourceProfileCounter::new("Interned clips"),
767-
filter_data: ResourceProfileCounter::new("Interned filter data"),
768-
backdrop: ResourceProfileCounter::new("Interned backdrops"),
772+
prim: ResourceProfileCounter::new("Interned primitives", None, None),
773+
image: ResourceProfileCounter::new("Interned images", None, None),
774+
image_border: ResourceProfileCounter::new("Interned image borders", None, None),
775+
line_decoration: ResourceProfileCounter::new("Interned line decorations", None, None),
776+
linear_grad: ResourceProfileCounter::new("Interned linear gradients", None, None),
777+
normal_border: ResourceProfileCounter::new("Interned normal borders", None, None),
778+
picture: ResourceProfileCounter::new("Interned pictures", None, None),
779+
radial_grad: ResourceProfileCounter::new("Interned radial gradients", None, None),
780+
text_run: ResourceProfileCounter::new("Interned text runs", None, None),
781+
yuv_image: ResourceProfileCounter::new("Interned YUV images", None, None),
782+
clip: ResourceProfileCounter::new("Interned clips", None, None),
783+
filter_data: ResourceProfileCounter::new("Interned filter data", None, None),
784+
backdrop: ResourceProfileCounter::new("Interned backdrops", None, None),
769785
},
770786
}
771787
}
@@ -817,7 +833,7 @@ impl RendererProfileCounters {
817833
"Vertices",
818834
None, Some(expected::VERTICES),
819835
),
820-
vao_count_and_size: ResourceProfileCounter::new("VAO"),
836+
vao_count_and_size: ResourceProfileCounter::new("VAO", None, None),
821837
color_targets: AverageIntProfileCounter::new(
822838
"Color Targets",
823839
None, Some(expected::COLOR_TARGETS),

0 commit comments

Comments
 (0)