Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd a sampling profiler #23080
Add a sampling profiler #23080
Conversation
highfive
commented
Mar 22, 2019
|
Heads up! This PR modifies the following files:
|
|
@gterzian Since a lot of this work was just plugging together the existing pieces from the background hang monitor, would you like to review this? |
f7f4bc9
to
27361c5
|
@jdm Ok, I will take a look... |
|
I have a slight re-design proposal for the constellation -> bhg communication for consideration. It's a bit complicated and I think it might be worth it since it will enable toggling the sampling also in multiprocess mode:
|
| while monitor.run() { | ||
| // Monitoring until all senders have been dropped... | ||
| } | ||
| }); | ||
| Box::new(HangMonitorRegister { sender }) | ||
| } | ||
|
|
||
| pub fn toggle(rate: Duration) { |
This comment has been minimized.
This comment has been minimized.
gterzian
Mar 24, 2019
•
Member
I think there are two issues with this setup:
- I think it's not going to work in multiprocess mode(since
toggleis called from the "main" process where the embedder is running). - When you call
toggleone cannot be sure that the bhg is running, sotogglecould return successfully but not result in anything changing. - In practice there will only ever be one bhg per process, so the mutex around
SamplerStateis a pity.
|
Looks good! It is indeed a better idea to pass the control chan to the constellation when the pipeline is created, as opposed to send it in a message like I initially suggested... There are just a few Otherwise just one comment... |
| @@ -1195,6 +1217,16 @@ where | |||
| self.forward_event(destination_pipeline_id, event); | |||
| }, | |||
| FromCompositorMsg::SetCursor(cursor) => self.handle_set_cursor_msg(cursor), | |||
| FromCompositorMsg::EnableProfiler(rate) => { | |||
| for chan in &self.sampling_profiler_control { | |||
| let _ = chan.send(SamplerControlMsg::Enable(rate)); | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Mar 26, 2019
Member
Perhaps expect or warn on failure for both sends to the monitor? The constellation keeps two channels to the monitor so something is wrong if the monitor isn't receiving messages anymore...
Use mozjs profiling feature when building with frame pointer enabled This makes it possible to get more meaningful profiles with #23080. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #23081 - [x] There are no tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23095) <!-- Reviewable:end -->
Use mozjs profiling feature when building with frame pointer enabled This makes it possible to get more meaningful profiles with #23080. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #23081 - [x] There are no tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23095) <!-- Reviewable:end -->
Use mozjs profiling feature when building with frame pointer enabled This makes it possible to get more meaningful profiles with #23080. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #23081 - [x] There are no tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23095) <!-- Reviewable:end -->
|
Updated the tests. I intend to keep the printlns, because there is no feedback on what's happening otherwise and resolving can take a really long time, and quitting while it's resolving means the profile is lost. |
|
@bors-servo r=gterzian |
|
|
|
@bors-servo r=gterzian |
|
|
Add a sampling profiler This uses the code already built for the background hang monitor and adds the ability to repeatedly sample all monitored threads. This sampling allows us to generate profiles that we can translate into the format used by https://perf-html.io/, allowing us to benefit from modern Gecko performance tooling. You can run Servo with `PROFILE_OUTPUT=foo.json` and `SAMPLING_RATE=50` (for example), otherwise these values will default to `samples.json` and 10ms, respectively. To activate the profiler, press cmd+p, and to stop profiling, press cmd+p again. This will the captured samples to be symbolicated, which will take a very long time, and eventually there will be a new JSON profile in the output location. To create a profile for use by Gecko's tools, run `python etc/profilicate.py path/to/profile.json >gecko_profile.json`, and load `gecko_profile.json` in the https://perf-html.io/ to see something like [this](https://profiler.firefox.com/public/8137e2b11fbb92afb80090bc534fd83015c87ee6/calltree/?globalTrackOrder=0-1&thread=1&v=3); --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13103 - [x] These changes do not require tests because way too many pieces to automate <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23080) <!-- Reviewable:end -->
|
@bors-servo r=gterzian |
|
|
Add a sampling profiler This uses the code already built for the background hang monitor and adds the ability to repeatedly sample all monitored threads. This sampling allows us to generate profiles that we can translate into the format used by https://perf-html.io/, allowing us to benefit from modern Gecko performance tooling. You can run Servo with `PROFILE_OUTPUT=foo.json` and `SAMPLING_RATE=50` (for example), otherwise these values will default to `samples.json` and 10ms, respectively. To activate the profiler, press cmd+p, and to stop profiling, press cmd+p again. This will the captured samples to be symbolicated, which will take a very long time, and eventually there will be a new JSON profile in the output location. To create a profile for use by Gecko's tools, run `python etc/profilicate.py path/to/profile.json >gecko_profile.json`, and load `gecko_profile.json` in the https://perf-html.io/ to see something like [this](https://profiler.firefox.com/public/8137e2b11fbb92afb80090bc534fd83015c87ee6/calltree/?globalTrackOrder=0-1&thread=1&v=3); --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13103 - [x] These changes do not require tests because way too many pieces to automate <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23080) <!-- Reviewable:end -->
|
|
jdm commentedMar 22, 2019
•
edited
This uses the code already built for the background hang monitor and adds the ability to repeatedly sample all monitored threads. This sampling allows us to generate profiles that we can translate into the format used by https://perf-html.io/, allowing us to benefit from modern Gecko performance tooling.
You can run Servo with
PROFILE_OUTPUT=foo.jsonandSAMPLING_RATE=50(for example), otherwise these values will default tosamples.jsonand 10ms, respectively. To activate the profiler, press cmd+p, and to stop profiling, press cmd+p again. This will the captured samples to be symbolicated, which will take a very long time, and eventually there will be a new JSON profile in the output location.To create a profile for use by Gecko's tools, run
python etc/profilicate.py path/to/profile.json >gecko_profile.json, and loadgecko_profile.jsonin the https://perf-html.io/ to see something like this;./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is