Page MenuHomePhabricator

Bug 1527522 - Add external hooks to WR to allow integration with the Gecko profiler.
ClosedPublic

Authored by gw on Feb 13 2019, 2:24 AM.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Build Status
Buildable 40242
Build 51238: arc lint + arc unit

Event Timeline

gw created this revision.Feb 13 2019, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2019, 2:24 AM
phab-bot requested review of this revision.Feb 13 2019, 2:24 AM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: Restricted Project.

This is a not-very-elegant integration of gecko profile markers. Maybe there is a cleaner / simpler way to implement this?

kvark accepted this revision.Feb 13 2019, 2:39 AM

Listed a few suggestions below

gfx/wr/webrender/src/frame_builder.rs
377

if we are using a macro anyway, maybe we can do "b" and "\0" in it?

gfx/wr/webrender/src/profiler.rs
28

I think it needs to be &mut self or otherwise the API allows those calls to be done concurrently

41

can we ask Gecko to just provide it in Renderer::new() constructor?

74

can we end up in a situation when the PROFILER_HOOKS was None when we began the scope but Some when we end it? Perhaps, it should be Option<'static [u8]> for the name field to reflect this

This revision is now accepted and ready to land.Feb 13 2019, 2:39 AM
gw marked an inline comment as done.Feb 13 2019, 3:01 AM
gw added inline comments.
gfx/wr/webrender/src/frame_builder.rs
377

That'd be great, if possible! I'm no expert on macros though - do you know how to achieve this?

gfx/wr/webrender/src/profiler.rs
41

I think the semantics are a bit clearer to have them set by a single function before creation of a renderer, since a new renderer is created for each window, but the intent is for the profiler to be truly global.

74

I don't think so - because we guarantee via the init atomic that the hooks will only ever be set before any WR instances are created that could invoke the profile scope. The worst case here is that we call an unmatched end_marker, which the profiler handles.

gw updated this revision to Diff 61495.Feb 13 2019, 3:01 AM
emilio added inline comments.Feb 13 2019, 3:02 AM
gfx/wr/webrender/src/frame_builder.rs
377

There's the cstr! crate that the style system uses for this.

emilio added inline comments.Feb 13 2019, 3:05 AM
gfx/wr/webrender/src/profiler.rs
36

I'd feel a little better about this if this used an atomic pointer rather than static mut. This is completely UB if called from two different threads, right? Can we somehow guarantee that they're only called on a given thread? If not, can we avoid making begin_marker and end_marker &mut self?

gw updated this revision to Diff 61496.Feb 13 2019, 3:11 AM
gw updated this revision to Diff 61499.Feb 13 2019, 3:42 AM
gw requested review of this revision.Feb 13 2019, 3:42 AM

Updated to use cstr crate.

emilio accepted this revision.Feb 13 2019, 3:57 AM

Looks much better :)

gfx/wr/webrender/src/profiler.rs
42

Maybe this should just assert!(!wr_has_been_initialized())

58

nit: No need for ref mut.

72

ditto

This revision is now accepted and ready to land.Feb 13 2019, 3:57 AM
gw updated this revision to Diff 61512.Feb 13 2019, 4:00 AM
gw marked 2 inline comments as done.Feb 13 2019, 4:01 AM
gw added inline comments.
gfx/wr/webrender/src/profiler.rs
42

It's expected to be called in the current bindings each time a new window is created, so we can't assert here.

This revision was automatically updated to reflect the committed changes.
gw updated this revision to Diff 61837.Feb 13 2019, 9:41 PM
gw reopened this revision.Feb 13 2019, 9:46 PM
This revision is now accepted and ready to land.Feb 13 2019, 9:46 PM
This revision was automatically updated to reflect the committed changes.