{"id":279,"date":"2021-11-15T13:57:18","date_gmt":"2021-11-15T21:57:18","guid":{"rendered":"https:\/\/blog.mozilla.org\/performance\/?p=279"},"modified":"2022-02-10T12:46:26","modified_gmt":"2022-02-10T20:46:26","slug":"performance-tools-newsletter-q3-2021","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/performance\/2021\/11\/15\/performance-tools-newsletter-q3-2021\/","title":{"rendered":"Performance Tools Newsletter (Q3 2021)"},"content":{"rendered":"<p>As the Perf-Tools team, we are responsible for the <a href=\"https:\/\/profiler.firefox.com\/\">Firefox Profiler<\/a>. This newsletter gives an overview of the new features and improvements we\u2019ve done in Q3 2021.<\/p>\n<p>This is our second newsletter and you can find the first one <a href=\"https:\/\/blog.mozilla.org\/performance\/2021\/07\/08\/performance-tools-newsletter-h1-2021\/\">here<\/a> which was about the H1 2021. With this newsletter, we wanted to focus on only Q3, so it would be less crowded and you can see the new features and improvements easily. I hope you enjoy the work that we\u2019ve done this quarter.<\/p>\n<p>Let\u2019s get started with the highlights.<\/p>\n<h2>Network marker Improvements<\/h2>\n<p>We had network markers for a while and we had both a network track in the timeline and a network chart in the bottom panel. It was working fine for a while but it was lacking some functionalities. Also, we had some correctness issues around the markers, like sometimes we were missing some network markers. We\u2019ve worked on this task to improve both the Firefox Profiler analysis page and also the correctness of the values in the back-end.<br \/>\nHere are some of the things that we\u2019ve done:<\/p>\n<h3>Highlight network markers in both the timeline and the network chart<\/h3>\n<p>Previously, network markers in the timeline and network chart were independent. When you interacted with one, it wasn\u2019t changing the other one. After this work, when you hover over a network marker, the same marker in the other part will be highlighted. Here\u2019s an example:<\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-279-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/quicktime\" src=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-marker-hover.mov?_=1\" \/><source type=\"video\/quicktime\" src=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-marker-hover.mov?_=1\" \/><a href=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-marker-hover.mov\">https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-marker-hover.mov<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<h3>Clicking a request in the network track selects the right line in the network chart<\/h3>\n<p>Previously, clicking on a network track wasn\u2019t doing anything. With this work, if you click on a network request in the network track in the timeline, it will automatically select the network marker in the network chart. It is helpful for quickly finding the network request you are looking for.<\/p>\n<h3>New context menu in the network track<\/h3>\n<p>We have a context menu for the network chart in the bottom panel, but we didn\u2019t have one in the timeline network tracks. We\u2019ve added the context menu to the network tracks now and they can be used as the same. We are hoping that with this and other network track works, network track will be a lot more useful.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-281\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/network-track-context-menu.png\" alt=\"Picture of new network track context menu when you press right click on a network request.\" width=\"325\" height=\"280\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/network-track-context-menu.png 325w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/network-track-context-menu-300x258.png 300w\" sizes=\"(max-width: 325px) 100vw, 325px\" \/><\/p>\n<h3>Display network markers in the marker chart<\/h3>\n<p>We\u2019ve started to show the network markers in the marker chart as well. It could be helpful when you are also looking for other markers and want to align the network markers with them.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-286\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart.png\" alt=\"Example that shows network markers in marker chart.\" width=\"1204\" height=\"181\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart.png 1204w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart-300x45.png 300w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart-600x90.png 600w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart-768x115.png 768w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-network-markers-in-marker-chart-1000x150.png 1000w\" sizes=\"(max-width: 1204px) 100vw, 1204px\" \/><\/p>\n<h3>Support for network requests cancellations<\/h3>\n<p>This is one of the improvements that we made in the back-end to make the data more consistent and accurate. Firefox profiler didn\u2019t support the network request cancellations on service workers before. Now, you can see if a network request is being canceled and when.<\/p>\n<h2>Profiling overhead reductions<\/h2>\n<h3>Reducing the overhead of profiling Firefox sleeping threads<\/h3>\n<p>Previously, we were doing some costly operations for sampling even when a thread is idle. With this work, we\u2019ve reduced the overhead of profiling the sleeping thread dramatically. I\u2019m not going to get into the details of this improvement since our colleague Gerald Squelart wrote a great blog post about it already. <a href=\"https:\/\/blog.mozilla.org\/performance\/2021\/10\/08\/reducing-the-overhead-of-profiling-firefox-sleeping-threads\/\">You can take a look at it here if you are curious about the optimization he came up with and the implementation details. <\/a><\/p>\n<h3>Reducing the overhead of Firefox Profiler recording by reducing mutex lockings<\/h3>\n<p>Firefox Profiler has an internal mutex inside of it. It is being used so other threads can modify the same data without any data loss or data race. But this mutex brings some overhead because when two threads need to add a marker at the same time, they both need to acquire the mutex lock. In that case, one of them had to wait for the other one. And this was bringing some overhead because of this mutex lock waiting time.<br \/>\nWith this work, we\u2019ve removed the need for mutexes from lots of places, including most importantly from marker recording sites.<\/p>\n<h2>Rust API for Firefox Profiler<\/h2>\n<p>Firefox Profiler has some APIs for various languages like C++, JavaScript, and Java\/Kotlin inside the mozilla-central codebase. We also had some hacks around the Rust codebases, but they were added for each Rust project when they were needed and we had lots of code duplication because of it. Also, they weren\u2019t maintained by the Firefox Profiler team and they were prone to misuse. With this work, we\u2019ve created a canonical Rust API for the Firefox Profiler and removed all the code duplications\/hacks around the codebase.<\/p>\n<p>We have three main functionalities with this API:<\/p>\n<ol>\n<li>Registering Rust threads:\n<ol>\n<li>With this functionality, you can register a Rust thread, so Firefox Profiler can find it and possibly profile it. It\u2019s good to keep in mind that only registering a thread will not make it appear in the profile data. In addition, you need to add it to the \u201cThreads\u201d filter in about:profiling.<br \/>\nWe had some hacks around the thread registration for Servo and WebRender threads, so we could profile them. But they were duplicated and were using the raw FFI bindings.<\/li>\n<\/ol>\n<\/li>\n<li>Adding stack frame labels:\n<ol>\n<li aria-level=\"2\">Stack frame labels are useful for annotating a part of the call stack with a category. The category will appear in the various places on the Firefox Profiler analysis page like timeline, call tree tab, flame graph tab, etc.<\/li>\n<\/ol>\n<\/li>\n<li aria-level=\"1\">Adding profiler markers:\n<ol>\n<li aria-level=\"2\">Markers are packets of arbitrary data that are added to a profile by the Firefox code, usually to indicate something important happening at a point in time, or during an interval of time.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>We also have documentation about this API <a href=\"https:\/\/firefox-source-docs.mozilla.org\/tools\/profiler\/instrumenting-rust.html\">in the Firefox source docs<\/a>. Please take a look at it for more details and examples if you are interested. Also, we are going to be writing a blog post about this API soon. Stay tuned!<\/p>\n<h2>Show the eTLD+1 of Isolated Web Content Processes as their track name<\/h2>\n<p>The timeline of the Firefox Profiler analysis page is very crucial to finding the data we are looking for. Inside the timeline, we have various registered processes and threads that Firefox had during the profiling session. When we have lots of tracks in the timeline, it might be hard to figure out which track we are interested in.<\/p>\n<p>Previously, all the web content processes had a single name called \u201cWeb Content\u201d or \u201cIsolated Web Content\u201d (<a href=\"https:\/\/wiki.mozilla.org\/Project_Fission\">when Fission is enabled<\/a>). This is not explicit when it comes to figuring out a specific tab. This was implemented this way before because there wasn\u2019t a way to determine the tab URL for a specific \u201cWeb Content\u201d process. But with Fission, we precisely know which process belongs to which eTLD+1. After this work, we\u2019ve started to show their eTLD+1 as their track name. This way, it will be a lot easier to determine which track you are looking for.<\/p>\n<p>Here\u2019s an example of before and after:<\/p>\n<div id=\"attachment_282\" style=\"width: 1816px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-282\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-282 size-full\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before.png\" alt=\"Before the change, profiler timeline was showing not-very-helpful Isolated Content Process as the name\" width=\"1806\" height=\"580\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before.png 1806w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before-300x96.png 300w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before-600x193.png 600w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before-768x247.png 768w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before-1536x493.png 1536w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-before-1000x321.png 1000w\" sizes=\"(max-width: 1806px) 100vw, 1806px\" \/><p id=\"caption-attachment-282\" class=\"wp-caption-text\">Before<\/p><\/div>\n<div id=\"attachment_283\" style=\"width: 1812px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-283\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-283 size-full\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after.png\" alt=\"After this change, profiler timeline shows the ETLD+1 as the name which is more helpful.\" width=\"1802\" height=\"574\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after.png 1802w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after-300x96.png 300w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after-600x191.png 600w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after-768x245.png 768w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after-1536x489.png 1536w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-timeline-etldplusone-after-1000x319.png 1000w\" sizes=\"(max-width: 1802px) 100vw, 1802px\" \/><p id=\"caption-attachment-283\" class=\"wp-caption-text\">After<\/p><\/div>\n<h2>Linux perf importer improvements<\/h2>\n<p>Firefox Profiler had Linux perf support for quite some time. We have this documentation about how to profile with it and how to import it.<br \/>\nOur contributor, Mark Hansen, made some great improvements on the Linux perf support to make it even better. Here are the things Mark Hansen improved:<\/p>\n<ul>\n<li aria-level=\"1\">Add support for Linux perf profiles with a header.\n<ul>\n<li>Firefox Profiler can import the profiles directly when the user records a profile with `perf script &#8211;header`. Previously it was giving an error and the header had to be removed.<\/li>\n<\/ul>\n<\/li>\n<li aria-level=\"1\">Add categories and colors to our Linux perf importer.\n<ul>\n<li>In the Firefox Profiler, we have various profiling categories for annotating different parts of the code. For example, we have JavaScript, DOM, Network, etc. For the Linux perf profiles, we didn\u2019t have any specific categories, so all the samples were marked as \u201cOther\u201d. With this work, we now have two categories for kernel and non-kernel native code. Here\u2019s a before and after:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-284\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after.png\" alt=\"Before the grap was all gray but now it's more colorful depending on the stack function category.\" width=\"1960\" height=\"816\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after.png 1960w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after-300x125.png 300w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after-600x250.png 600w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after-768x320.png 768w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after-1536x639.png 1536w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-perf-categories-before-after-1000x416.png 1000w\" sizes=\"(max-width: 1960px) 100vw, 1960px\" \/>Also, he wrote an awesome blog post about this work. <a href=\"https:\/\/www.markhansen.co.nz\/colouring-firefox-profiler-flamegraphs\/\">You can find it here.<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Support for dhat imports<\/h2>\n<p>Firefox Profiler now supports imports of dhat memory profiles. \u201cdhat\u201d is a dynamic heap analysis tool that is a part of the<a href=\"https:\/\/www.valgrind.org\/docs\/manual\/dh-manual.html\"> valgrind tools<\/a>. It\u2019s useful for examining how programs use their heap allocations. After this work, all you need to do is to drag and drop the dhat memory profile file into the Firefox Profiler and it will automatically import everything and load it for you.<\/p>\n<h2>Other updates<\/h2>\n<ul>\n<li>Localization of the Firefox Profiler\n<ul>\n<li>We\u2019ve finished the internationalization work of the Firefox Profiler analysis page in the H1 with the help of our Outreachy intern. And we were working with the l10n team to localize the Firefox Profiler.<br \/>\nIn Q3, we\u2019ve enabled 12 locales in total, and we hope to add more once the locales under development reach a certain limit! Here are the locales that we enabled so far:<br \/>\nde, el, en-GB, es-CL, ia, it, nl, pt-BR, sv-SE, uk, zh-CN, zh-TW.<br \/>\nIf you want to help translate the Firefox Profiler to your language, <a href=\"https:\/\/pontoon.mozilla.org\/projects\/firefox-profiler\/\">you can do that by visiting our project on Pontoon<\/a>.<\/li>\n<\/ul>\n<\/li>\n<li aria-level=\"1\">Compare view shows the profile names as the track names\n<ul>\n<li>Previously the <a href=\"https:\/\/profiler.firefox.com\/compare\/\">compare view<\/a> was only showing Profile 1 and Profile 2 as the profile names. Now, it will display the name if it\u2019s provided in the profile link.<\/li>\n<\/ul>\n<\/li>\n<li aria-level=\"1\">Create more compact URLs for profiles with lots of tracks\n<ul>\n<li aria-level=\"2\">Firefox Profiler keeps most of the data persistent in the URL, so when you share the link with someone else, they will see the same thing as you see. But that brings some challenges. Because there is a lot of data to keep track of, the URL sometimes ends up being really long. We are using bitly to shorten the URLs, so you don\u2019t have to worry about long URLs. But when the URL is too long, bitly fails to shorten it and you are stuck with the long URL. With this work, we\u2019ve made the URLs more compact, to ensure that we will never fail to shorten them.<\/li>\n<\/ul>\n<\/li>\n<li aria-level=\"1\">Updated \u201cExpand all\u201d menu item to include its shortcut key\n<ul>\n<li>We have an \u201cExpand all\u201d menu item in the call tree context menu. It has a shortcut key as \u201c*\u201d but that wasn\u2019t really visible before. Now, we are showing the shortcut on the right side of the menu item, so you can learn it by just looking at the context menu.<br \/>\nThis is implemented by our contributor Duncan Bain. Thanks, Duncan!<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-285\" src=\"http:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-context-menu-expand-all.png\" alt=\"&quot;Expand all&quot; context menu item shows the shortcut now.\" width=\"417\" height=\"212\" srcset=\"https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-context-menu-expand-all.png 417w, https:\/\/blog.mozilla.org\/performance\/files\/2021\/11\/profiler-context-menu-expand-all-300x153.png 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/p>\n<ul>\n<li>When a window is closed, its screenshot will stop showing up in the timeline at the point of window destruction.\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li aria-level=\"2\">Our screenshots were always showing like a window is always open even though it\u2019s being destroyed already. Now, we know when a window is being destroyed and stop showing the screenshots of that window.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Contributors in Q3 2021<\/h2>\n<p>Lots of awesome people contributed to our codebases both on GitHub and mozilla-central in. We are thankful to all of them! Here&#8217;s a list of people who contributed to Firefox Profiler code:<\/p>\n<ul>\n<li>Duncan Bain<\/li>\n<li>Florian Qu\u00e8ze<\/li>\n<li>Gerald Squelart<\/li>\n<li>Greg Tatum<\/li>\n<li>Julien Wajsberg<\/li>\n<li>Mark Hansen<\/li>\n<li>Markus Stange<\/li>\n<li>Michael Comella<\/li>\n<li>Nadinda Rachmat<\/li>\n<li>Naz\u0131m Can Alt\u0131nova<\/li>\n<\/ul>\n<p>And here&#8217;s a list of contributors who helped on the localization of Firefox Profiler:<\/p>\n<ul>\n<li>Brazilian Portuguese: Marcelo Ghelman<\/li>\n<li>British English: Ian Neal<\/li>\n<li>Chilean Spanish: ravmn<\/li>\n<li>Chinese: Gardenia Liu, hyperlwk, \u4f60\u6211\u7686\u51e1\u4eba<\/li>\n<li>Dutch: Mark Heijl<\/li>\n<li>German: Michael K\u00f6hler<\/li>\n<li>Greek: Jim Spentzos<\/li>\n<li>Interlingua: Martijn Dekker, Melo46<\/li>\n<li>Italian: Francesco Lodolo<\/li>\n<li>Kabyle: Selyan Slimane Amiri, ZiriSut<\/li>\n<li>Swedish: Andreas Pettersson, Luna Jernberg, Peter Kihlstedt<\/li>\n<li>Taiwanese Chinese: Pin-guang Chen<\/li>\n<li>Ukrainian: Artem Polivanchuk, Lobodzets, \u0406hor Hordiichuk<\/li>\n<\/ul>\n<p>Thanks a lot!<\/p>\n<h2>Conclusion<\/h2>\n<p>Thanks for reading! If you have any questions or feedback, please feel free to reach out to me on Matrix (<a href=\"https:\/\/matrix.to\/#\/@canova:mozilla.org\">@canova:mozilla.org<\/a>). You can also reach out to our team on Firefox Profiler channel on Matrix (<a href=\"https:\/\/matrix.to\/#\/#profiler:mozilla.org\">#profiler:mozilla.org<\/a>).<\/p>\n<p>If you profiled something and are puzzled with the profile you captured, we also have the Joy of Profiling (<a href=\"https:\/\/matrix.to\/#\/#joy-of-profiling:mozilla.org\">#joy-of-profiling:mozilla.org<\/a>) channel where people share their profiles and get help from the people who are more familiar with the Firefox Profiler. In addition to that, we have the Joy of Profiling Open Sessions where some Firefox Profiler and Performance engineers gather together on a Zoom call to answer questions or analyze the profiles you captured. It\u2019s usually happening every Monday, and you can follow the<a href=\"https:\/\/calendar.google.com\/calendar\/embed?src=c_cbjhkf8gu6anajlklhuo04hpko%40group.calendar.google.com\"> \u201cPerformance Office Hours\u201d calendar<\/a> to learn more about it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As the Perf-Tools team, we are responsible for the Firefox Profiler. This newsletter gives an overview of the new features and improvements we\u2019ve done in Q3 2021. This is our &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/performance\/2021\/11\/15\/performance-tools-newsletter-q3-2021\/\">Read more<\/a><\/p>\n","protected":false},"author":1859,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[447618,457005,457015,117,311,779,457016],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/posts\/279"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/users\/1859"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/performance\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}