Closed Bug 1444296 Opened 6 years ago Closed 6 years ago

Include some traversal statistics in style tracing marker

Categories

(Core :: Gecko Profiler, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox60 --- wontfix
firefox61 --- fixed

People

(Reporter: xidorn, Assigned: xidorn)

References

Details

(Whiteboard: [perf-tools])

Attachments

(4 files, 1 obsolete file)

With parallel traversal, we don't include details of style threads in profile by default (and we don't want to either). This makes us completely blind on what's happening inside a restyles.

It may make sense to include some of statistics we are already collecting during traversal (as TraversalStatistics) into profile, so that we at least have some clue for long restyles in profile.

My feeling is that elements_{traversed,styled,matched} are probably the most interesting ones.
Assignee: nobody → xidorn+moz
There is some small amount of overhead during the collection phase. Can we gate that on the profiler being enabled?
I suspect gating them has a higher overhead than simply collecting them...

We should still gate them in the same way for merging the collected data, though.
(In reply to Xidorn Quan [:xidorn] UTC+10 from comment #2)
> I suspect gating them has a higher overhead than simply collecting them...
> 
> We should still gate them in the same way for merging the collected data,
> though.

Yeah, that's what I meant. Sounds like we're on the same page.
Attached file perf.html pull request
Attachment #8958051 - Flags: review?(mstange)
Comment on attachment 8958046 [details]
Bug 1444296 part 1 - Have servo report traversal statistics to gecko.

https://reviewboard.mozilla.org/r/226982/#review232824

I think we should fix up the statistics types to make things more clear.

Right now there are some stats that are gathered per-thread and then aggregated, whereas others are collected at the end via finish(). The type system doesn't enforce correctness here, making mistakes possible, and this patch makes the meaning of |finish| even less clear (since we don't call it for the |report| case).

So I think we should separate out the per-thread things into a TraversalStatisticsInner, and replace TraversalStatistics::finish() with a TraversalStatistics::new() that takes a TraversalStatisticsInner along with the other necessary bits. Then when we're reporting but not dumping, we can just collect and aggregated TraversalStatisticsInner instances, and then the dump code can construct a TraversalStatistics afterwards if it wants.

::: layout/style/ServoTraversalStatistics.h:26
(Diff revision 1)
> +  uint32_t mElementsMatched = 0;
> +  uint32_t mStylesShared = 0;
> +  uint32_t mStylesReused = 0;
> +
> +  static bool sActive;
> +  static ServoTraversalStatistics sStats;

Let's call this |singleton|.
Attachment #8958046 - Flags: review?(bobbyholley) → review-
Blocks: 1363424
Priority: -- → P1
Whiteboard: [perf-tools]
Status: NEW → ASSIGNED
Comment on attachment 8958284 [details]
Split TraversalStatistics into two parts.

https://reviewboard.mozilla.org/r/227212/#review233018

This looks great, thanks. Please test that DUMP_STYLE_STATISTICS=1 still works on top of your patches.

r=me with that

::: servo/components/style/context.rs:328
(Diff revision 1)
> +        }
> +    }
> +}
> +
> +/// Statistics gathered during the traversal plus some other information
> +/// get from other sources including stylist.

s/get//
Attachment #8958284 - Flags: review?(bobbyholley) → review+
Comment on attachment 8958046 [details]
Bug 1444296 part 1 - Have servo report traversal statistics to gecko.

https://reviewboard.mozilla.org/r/226982/#review233022
Attachment #8958046 - Flags: review?(bobbyholley) → review+
(In reply to Bobby Holley (:bholley) from comment #11)
> This looks great, thanks. Please test that DUMP_STYLE_STATISTICS=1 still
> works on top of your patches.

Yeah, it still works.
Comment on attachment 8958047 [details]
Bug 1444296 part 2 - Have a separate marker for styles to present stats.

https://reviewboard.mozilla.org/r/226984/#review233588
Attachment #8958047 - Flags: review?(mstange) → review+
Comment on attachment 8958284 [details]
Split TraversalStatistics into two parts.

https://reviewboard.mozilla.org/r/227212/#review233600

::: servo/components/style/context.rs:314
(Diff revision 1)
>      /// StyleSharingCache.
>      pub styles_reused: u32,
> +}
> +
> +/// Implementation of Add to aggregate statistics across different threads.
> +impl<'a> ops::Add for &'a TraversalStatisticsInner {

Drive-by (sorry!), but... maybe `PerThreadTraversalStatistics`, calling the `inner` member something like `aggregated` instead?

Not ultra-fond of the name either, I just dislike the `FooInner` stuff a bit :).

Feel free to not change it if you don't think it's better / worth it.
Comment on attachment 8958051 [details] [review]
perf.html pull request

Julien has r+ed this in https://github.com/devtools-html/perf.html/pull/852 .
Attachment #8958051 - Flags: review?(mstange)
(In reply to Emilio Cobos Álvarez [:emilio] from comment #15)
> Drive-by (sorry!), but... maybe `PerThreadTraversalStatistics`, calling the
> `inner` member something like `aggregated` instead?

SGTM
Attached file Servo PR
Attachment #8958284 - Attachment is obsolete: true
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ab2df71dc9de
part 1 - Have servo report traversal statistics to gecko. r=bholley
https://hg.mozilla.org/integration/autoland/rev/7701560f1b14
part 2 - Have a separate marker for styles to present stats. r=mstange
https://hg.mozilla.org/mozilla-central/rev/ab2df71dc9de
https://hg.mozilla.org/mozilla-central/rev/7701560f1b14
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: