{"componentChunkName":"component---src-templates-documentation-js","path":"/documentation/heapprofiler/","result":{"data":{"postBySlug":{"html":"<h1 id=\"heap-profiler\" style=\"position:relative;\"><a href=\"#heap-profiler\" aria-label=\"heap profiler permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Heap Profiler</h1>\n<p>If you're looking to quickly get started with understanding\nmemory profiling and learning how to optimize Node.js code then this\nis a great place to start.</p>\n<ol>\n<li><a href=\"/documentation/heapprofiler/01-setup/\">Setup</a></li>\n<li><a href=\"/documentation/heapprofiler/02-getting-ready/\">Getting ready</a></li>\n<li><a href=\"/documentation/heapprofiler/03-first-analysis/\">First analysis</a></li>\n<li><a href=\"/documentation/heapprofiler/04-flamegraphs/\">Flamegraphs</a></li>\n<li><a href=\"/documentation/heapprofiler/05-controls/\">Controls</a></li>\n<li><a href=\"/documentation/heapprofiler/06-optimizing-a-hot-function/\">Optimizing a hot function</a></li>\n</ol>","frontmatter":{"title":"","metaData":{"titleParts":["Heap Profiler","Documentation"],"description":null,"image":null}}},"tableOfContents":{"title":"Documentation","entry":{"id":"1dcb7947-5db6-529b-9573-8753924874dd","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"getting-started","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#getting-started","ariaLabel":"getting started permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Getting started"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before you get started with Clinic.js, first let's make sure we install it on our machines and run a couple of tests just to make sure everything is working fine. Let's follow these steps to kick off:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"1."}]},{"type":"text","value":" Note: You must use a version of Node.js "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":">= 16"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"2."}]},{"type":"text","value":" Confirm that it has installed ok with:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"3."}]},{"type":"text","value":" It should print something similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Clinic.js - v2.2.1\n\nGetting started\nAs a first step, run the clinic doctor:\n\n  clinic doctor -- node server.js\n\nThen benchmark your server with wrk or autocannon:\n\n  wrk http://localhost:3000\n  autocannon http://localhost:3000\n\nFinally shut down your server (Ctrl+C). Once the server process has shutdown\nclinic doctor will analyse the collected data and detect what type of issue\nyou are having. Based on the issue type, it will provide a recommendation for\nyou.\n\nFor example, to debug I/O issues, use Clinic.js Bubbleprof:\n\n  clinic bubbleprof -- node server.js\n\nThen benchmark your server again, just like you did with clinic doctor.\n\nReport an issue\nIf you encounter any issue, feel free to send us an issue report at:\n\n  https://github.com/clinicjs/node-clinic/issues\n\nUtilities\nWhen using clinic a bunch you have fill up your directory with data folders and files.\nYou can clean these easily using clinic clean.\n\nMore information\nFor information on the clinic sub-commands, use the --help option:\n\n  clinic doctor --help\n  clinic bubbleprof --help\n  clinic clean --help\n  clinic flame --help\n  clinic heapprofiler --help\n\nFlags\n-h | --help                Display Help\n-v | --version             Display Version"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"4."}]},{"type":"text","value":" We have a set of example apps on Github. Let's run through the first one using "},{"type":"element","tagName":"a","properties":{"href":"/doctor/"},"children":[{"type":"text","value":"Clinic.js Doctor"}]},{"type":"text","value":" and autocannon:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" clone https://github.com/clinicjs/node-clinic-doctor-examples.git\n"},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" node-clinic-doctor-examples\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":"\nclinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" / "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" ./slow-io"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will run autocannon against a simple app with an IO issue and once it's complete it will automatically launch the Doctor tool inside your browser."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Normally, when using Clinic.js, we begin by using Clinic.js Doctor to identify what performance problems exist in an application. Doctor will then give us recommendations on what tools and enquires to make next."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/"},"children":[{"type":"text","value":"Get started with Clinic.js Doctor"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Alternatively you can dive into an in-depth overview of the CLI."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/cli"},"children":[{"type":"text","value":"CLI"}]},{"type":"text","value":"."}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":null}}},"links":[{"title":"Bubbleprof","entry":{"id":"69303c72-e142-55cc-9f2f-337bfa1d5319","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"bubbleprof","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#bubbleprof","ariaLabel":"bubbleprof permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Bubbleprof"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So you have heard about this new exciting tool called Bubbleprof and want to take it for a spin? Don't really know where to start? Then this post is for you."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/01-setup/"},"children":[{"type":"text","value":"Setup"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/04-bubbles/"},"children":[{"type":"text","value":"Bubbles"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/05-sidebar/"},"children":[{"type":"text","value":"The sidebar"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/06-finding-the-first-bottleneck/"},"children":[{"type":"text","value":"Finding the first bottleneck"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/07-improving-our-latency/"},"children":[{"type":"text","value":"Improving our latency"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/08-parallel-queries/"},"children":[{"type":"text","value":"Parallel queries"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/09-caching-the-results/"},"children":[{"type":"text","value":"Caching the results"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":3}}},"links":[{"title":"01 Setup","entry":{"id":"05207f3c-3d51-5fb4-80f5-f8739b41fc97","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"setup","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#setup","ariaLabel":"setup permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Setup"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Bubbleprof is part of the Clinic.js suit of tools. To install Bubbleprof, simply install Clinic.js like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After installing, we can check if Bubbleprof has been installed by running the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic bubbleprof"}]},{"type":"text","value":" command with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--help"}]},{"type":"text","value":" flag."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It should print something similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Clinic.js BubbleProf - v1.11.0\n\nclinic bubbleprof helps you find asynchronous bottlenecks and debug event loop blocking.\n\nTo run clinic bubbleprof\n\n  clinic bubbleprof -- node server.js\n\nIf profiling on a server, it can be useful to only do data collection:\n\n  clinic bubbleprof --collect-only -- node server.js\n\nYou can then transfer the data and visualize it locally:\n\n  clinic bubbleprof --visualize-only PID.clinic-bubbleprof-sample\n\nFlags\n-h | --help                Display Help\n-v | --version             Display Version\n--collect-only             Do not process data on terminiation\n--visualize-only datapath  Build or rebuild visualization from data"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/01-setup/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Setup","priority":1}}}},{"title":"02 Getting Ready","entry":{"id":"240ef7e4-8fde-5295-b41b-bedc38e2c59f","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"getting-ready","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#getting-ready","ariaLabel":"getting ready permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Getting ready"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Great, now we are ready to start profiling. To start profiling we find need a server of some sorts that does some async operations to get started. To keep things simple let's use our \"official\" Bubbleprof example that evolves around optimising a server that queries a mongodb containing npm metadata data."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" clone https://github.com/clinicjs/node-clinic-bubbleprof-demo.git"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you read the example README, it will contain some instructions on how to get mongodb setup with npm data and more."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/02-getting-ready/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Getting ready","priority":2}}}},{"title":"03 First Analysis","entry":{"id":"b035eb3a-2e7a-59cd-9281-587728e99f92","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"first-analysis","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#first-analysis","ariaLabel":"first analysis permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"First analysis"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now we're ready to run an analysis. Let's try with the first server in the repo, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1-server-with-no-index.js"}]},{"type":"text","value":".\nIt contains a small server that queries mongodb for the 5 newest and 5 oldest node modules."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can run it by simply doing "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node 1-server-with-no-index.js"}]},{"type":"text","value":" and query it by going to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"localhost:3000"}]},{"type":"text","value":"\nin your browser afterwards. If it returns a JSON response things are working!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's try and profile the server with Bubbleprof to see if we can find any bottlenecks. To do that we need\na tool that can send a ton of http requests against the server fast. If you don't have one, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" is\neasy to use. You can install it from npm."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g autocannon"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To run the analysis we want to run the server with Bubbleprof and when the server is ready - i.e. starts listening\non a port - we want to send a ton of requests to it using autocannon. We can do all that in this one single command:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon -c 5 -a 500 localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"-server-with-no-index.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before running it, let's explain what's happening in there. The part after "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" is simply the command\nto start running your server. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" flag is a script that is executed as soon as your server\nstarts listening on a port. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$PORT"}]},{"type":"text","value":" variable in that script is set to the port your server started listening\non. When the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" scripts ends, the Bubbleprof analysis will run on the data collected from the server\nand open the results in a html page."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You may have also noticed "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-c 5 -a 500"}]},{"type":"text","value":" flags. This tells autocannon to send a fixed amount of requests\n(5 connections making a total of 500 requests). By default autocannon tries to apply pressure for full 10 seconds,\nthen suddenly stops. While very useful for testing load tolerance, this would make it difficult to observe performance\nimprovements in single components, as most async operations would be active for 95% of the profiling time."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now try and run it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It'll take about 15 seconds to run.\nAfterwards a html page similar to this should open:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/0d21aa67f80041328f996853361c0e89/b41cb/03-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABUElEQVQoz3WQ4U6DMBSFeQ2gtAXa3tIWKIwBi24j0V+aGH+r8f0fw9upDJeYnDSn6f1uek6kx4f75dkPZ+0msKOshv+1BzdXbqqaeXl8OS5PUZyphGqaW5Zbwk3KKlSSAbmYGxXKU5yhulQ+F02UUsALnsnFJEShz+2QZpBkKmX6MhCEG4XZNeOx8rPpDgX4aH0Lz0Sy0olmku1UuoGJJvBXWGEu25zA3Jn6XMhuhXXKDde97A4kNxpJWZf1nol6s10XqhXQSu25cIRXVziTnrsJfZwI044Zr/AjOLGFhcXaOglhBc1NRNZUoYlgYqJcPynbx0RuQ4We3F7Xe212hWxw+wYOCg0RbsEduOpSbr+7/MlMQWgPZqdML8BjO39hFpIz0Uo7Yj1ZjsGuPMKldCr82ZeyphxuYWRY4VgZeia/QVap+dUsn3B8g9O7Pn98Ae8aWEpftfXxAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"First screen","title":"","src":"/static/0d21aa67f80041328f996853361c0e89/99f37/03-A.png","srcSet":["/static/0d21aa67f80041328f996853361c0e89/6b2ea/03-A.png 275w","/static/0d21aa67f80041328f996853361c0e89/dd45a/03-A.png 550w","/static/0d21aa67f80041328f996853361c0e89/99f37/03-A.png 1100w","/static/0d21aa67f80041328f996853361c0e89/573d3/03-A.png 1650w","/static/0d21aa67f80041328f996853361c0e89/b41cb/03-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"First thought is probably something similar to \"That's a lot of bubbles!\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/04-bubbles/"},"children":[{"type":"text","value":"Bubbles"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/03-first-analysis/","template":"src/templates/documentation.js"},"frontmatter":{"title":"First analysis","priority":3}}}},{"title":"04 Bubbles","entry":{"id":"ef5a1afc-453f-5920-9fdd-4fdde90bdf54","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"bubbles","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#bubbles","ariaLabel":"bubbles permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Bubbles"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's dive into what these mean and how to interpret them."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"A bubble represents a group of async operations."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The more time spent within a group of async operations, the bigger the bubble is."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The longer the lines between bubbles, the more latency exists between them."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The way bubbles group together async time is based on a couple of heuristics."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Profiled code is grouped into 3 areas - "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"userland"}]},{"type":"text","value":" (the application being profiled), "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"dependencies"}]},{"type":"text","value":" (3rd party modules), and "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"node core"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Whenever an async operation crosses from one space into another it defines the boundary of a bubble."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clicking on a bubble steps inside it to show the bubbles it's composed of."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For example, try clicking on the yellow bubble at the bottom called mongojs. The UI tells us it contains userland code as well\nas it has a lightblue color."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/0f556ce11f2e75b01aa17f083ce1bf5e/b41cb/04-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABC0lEQVQoz32Q626EIBCFfYrGVURBYBgVRVZLu70n+6ub/uvl/d+k2G2azWI3+UImA2cOZxL0+7un12H7CJ1X7bXE6T8UzmC8Nh7NzfP+7eHlkFxlIi0gL7HkLamaUCxQ/C1OSIlicii5CbcCHFc22RCZUwhkP+eRv+YpaS6FtsPkm961w5aDSeJHeQGqGUml475EB40TYJUemYjEWaEob7GfVoZSzZQVelTaMdkXFa6ISYWl7NJckPLcvG7D2kYJg4CBsmZF3FhfMAwJY/O6m7WZAR2PnY9/BrPNiIxtw0ZrsCFzEIfYVd2eO6ek3hCxFngRC9UDLpnDFBpnvoyYDnD/JW/f5e5D7T6/AbpIVV55j1FFAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Mongo Bubble","title":"","src":"/static/0f556ce11f2e75b01aa17f083ce1bf5e/99f37/04-A.png","srcSet":["/static/0f556ce11f2e75b01aa17f083ce1bf5e/6b2ea/04-A.png 275w","/static/0f556ce11f2e75b01aa17f083ce1bf5e/dd45a/04-A.png 550w","/static/0f556ce11f2e75b01aa17f083ce1bf5e/99f37/04-A.png 1100w","/static/0f556ce11f2e75b01aa17f083ce1bf5e/573d3/04-A.png 1650w","/static/0f556ce11f2e75b01aa17f083ce1bf5e/b41cb/04-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In here we see that there are two smaller bubbles. If we click on the first one it'll show the stack trace\nfor the operation that created this as it has no sub bubbles."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/bf8f1b9f12b57c9ca6b275e42e8af30a/b41cb/04-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABc0lEQVQoz3WP626CQBCF9ykaFbmzu+yyiroIKIjQYkTa0Nr0ounN9Ecfoc/fsWkaUtPky2QyO+ecHcSiMlnWvsyoCAmfYhb8Cw+piJiI+HCWr5pkuUFnPaejUkXnmuX1Da7o7Ijm/jQtOiqxyFg1YM1z3EAzBer2saJRoPddj41KfodtOgqmIhjKkPsTwLA9dLJE+gYjfHQq7uuMcondsUNHUDWTI8hp01Ww4QgqJh3F+fPUU6lJx5hNsDsxnSF4Ic30dOuIYQvd9GCk28IkQzhbNXkbzRpQPyZsZBPfJiB2UXK+Xa732XqXlXezvAnm9TSp5Wwj53XQYhytz6vHeVk71Hc9aeEBXIfi5TZdv6TVc1Jsk/w6zpowvTpFxtVF9ZDlFRzMRAAW8GU0L25Bma726eoxKR+iRQPJ0+SyTbho5GILyXGcqTqFWMPiiopRWt4XV4e8fs0vD1n1BCF/lOAVZjey2K2at4v9Jy3evfKDf/MFPm5vHh6VaDoAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Stack Trace Bubble","title":"","src":"/static/bf8f1b9f12b57c9ca6b275e42e8af30a/99f37/04-B.png","srcSet":["/static/bf8f1b9f12b57c9ca6b275e42e8af30a/6b2ea/04-B.png 275w","/static/bf8f1b9f12b57c9ca6b275e42e8af30a/dd45a/04-B.png 550w","/static/bf8f1b9f12b57c9ca6b275e42e8af30a/99f37/04-B.png 1100w","/static/bf8f1b9f12b57c9ca6b275e42e8af30a/573d3/04-B.png 1650w","/static/bf8f1b9f12b57c9ca6b275e42e8af30a/b41cb/04-B.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This stack trace is actually a combined stack trace by multiple async operations. The userland code is highlighted\nto help you navigate to your code that triggered this bubble. In this case it tells us that it was from line 10\nin "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1-server-with-no-index.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we look into the source file we'll see that line 10 looks like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"col"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"find"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"sort"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"modified"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"-"}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"limit"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"5"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"err"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" newest"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Which makes sense, as this is a mongodb query. In fact if we look at the other yellow bubble on the page,\nwe'll see that it contains a reference to the next query inside its callback. This link indicates\nthat these bubbles are executed in series."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/05-sidebar/"},"children":[{"type":"text","value":"Sidebar"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/04-bubbles/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Bubbles","priority":4}}}},{"title":"05 Sidebar","entry":{"id":"2a7dfb28-9a34-5705-be46-70d952f7b326","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"the-sidebar","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#the-sidebar","ariaLabel":"the sidebar permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"The sidebar"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So the bubbles show an overview on where time is spent. To get an idea on how much time is spent in general\nyou can inspect the sidebar."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Try going back to the Main View. You can use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"backspace"}]},{"type":"text","value":" on your keyboard to step back, or use the on-screen controls.\nOn the right side of screen you should see a sidebar similar to this one:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/4ab5acbe9a634a2a00dbd4f6b313c944/d8c86/05-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABTUlEQVQoz3WRWU7DQAyGc40mmS2zb5m0TdJEpSpUFAkhcQceWO5/AkwKbfKAZFkjeT779+/MdKe7h5emPWq/U66Ttv03XKfjzoadrcf78+v++JytkMqxwcyTypfUFcRC5EiX02MR1HHVIGoRddJsceWzAusCG8g5PIjJSwmZ+bYoVY7UpXQNmBy7g1kPdj0SHrJ5DUgiokyDSD0PHeZx4v8+EGPjaMNB+z1kUsUZTB2DxdJQUqtjS2TNY4cqP4cr3QiThG4oDyUxV9hgtaGug1GrQtjUI2pWpYRGM2lGxl67DVdJqITmcEHcr3is63YUdg3wjUQK7JQJ3N4CX8kaHF3sfOmCeFR+wDyV1C8MI8aE3tW9Db0wG8LjAr6ch6lGTPoRCxN/gxl3THgmAq1cgcRyMpwKKWiJGDA/Oheyq+hOb/Hpyz2+u/OHP39+A97KWKN8R7JWAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"The Sidebar","title":"","src":"/static/4ab5acbe9a634a2a00dbd4f6b313c944/99f37/05-A.png","srcSet":["/static/4ab5acbe9a634a2a00dbd4f6b313c944/6b2ea/05-A.png 275w","/static/4ab5acbe9a634a2a00dbd4f6b313c944/dd45a/05-A.png 550w","/static/4ab5acbe9a634a2a00dbd4f6b313c944/99f37/05-A.png 1100w","/static/4ab5acbe9a634a2a00dbd4f6b313c944/573d3/05-A.png 1650w","/static/4ab5acbe9a634a2a00dbd4f6b313c944/d8c86/05-A.png 1663w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the top of the sidebar there are two important sections."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"A search bar that allows you to search the data to find a specific function call."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"A timeline that shows the async activity over time."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Timeline is very useful at examining throughput and that could give us a clue where the first bottleneck could be found."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/06-finding-the-first-bottleneck/"},"children":[{"type":"text","value":"Finding the first bottleneck"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/05-sidebar/","template":"src/templates/documentation.js"},"frontmatter":{"title":"The sidebar","priority":5}}}},{"title":"06 Finding The First Bottleneck","entry":{"id":"fe677894-3cc3-5826-804c-cb431ad51af9","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"finding-the-first-bottleneck","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#finding-the-first-bottleneck","ariaLabel":"finding the first bottleneck permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Finding the first bottleneck"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/0d21aa67f80041328f996853361c0e89/b41cb/03-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABUElEQVQoz3WQ4U6DMBSFeQ2gtAXa3tIWKIwBi24j0V+aGH+r8f0fw9upDJeYnDSn6f1uek6kx4f75dkPZ+0msKOshv+1BzdXbqqaeXl8OS5PUZyphGqaW5Zbwk3KKlSSAbmYGxXKU5yhulQ+F02UUsALnsnFJEShz+2QZpBkKmX6MhCEG4XZNeOx8rPpDgX4aH0Lz0Sy0olmku1UuoGJJvBXWGEu25zA3Jn6XMhuhXXKDde97A4kNxpJWZf1nol6s10XqhXQSu25cIRXVziTnrsJfZwI044Zr/AjOLGFhcXaOglhBc1NRNZUoYlgYqJcPynbx0RuQ4We3F7Xe212hWxw+wYOCg0RbsEduOpSbr+7/MlMQWgPZqdML8BjO39hFpIz0Uo7Yj1ZjsGuPMKldCr82ZeyphxuYWRY4VgZeia/QVap+dUsn3B8g9O7Pn98Ae8aWEpftfXxAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"First screen","title":"","src":"/static/0d21aa67f80041328f996853361c0e89/99f37/03-A.png","srcSet":["/static/0d21aa67f80041328f996853361c0e89/6b2ea/03-A.png 275w","/static/0d21aa67f80041328f996853361c0e89/dd45a/03-A.png 550w","/static/0d21aa67f80041328f996853361c0e89/99f37/03-A.png 1100w","/static/0d21aa67f80041328f996853361c0e89/573d3/03-A.png 1650w","/static/0d21aa67f80041328f996853361c0e89/b41cb/03-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A few things we notice by looking at this first diagram are:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"A lot of time is spent inside the mongodb bubble on the left."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Similar amount of time is spent querying in the query bubble at the bottom."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The timeline is sparse indicating low throughput."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This seems like a throughput problem, likely related to mongodb."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we investigate the database setup we notice that the server is using a\ncollection that doesn't contain an index."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This means the database has to iterate all the data every time to answer our query,\nwhich creates a lot of database latency."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can reduce this overhead by adding an index on the properties we use."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/07-improving-our-latency/"},"children":[{"type":"text","value":"Improving our latency"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/06-finding-the-first-bottleneck/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Finding the first bottleneck","priority":6}}}},{"title":"07 Improving Our Latency","entry":{"id":"b19e2483-72a0-5b25-b050-dd97f673c2f3","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"improving-our-latency","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#improving-our-latency","ariaLabel":"improving our latency permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Improving our latency"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In our example, we have already added an ascending index based on the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"modified"}]},{"type":"text","value":" (datetime)\nattribute in our data. This indexed collection is used by the second\nexample - "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"2-server-with-index.js"}]},{"type":"text","value":". Let's run our benchmark against this\nserver and see if we can improve further."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon -c 5 -a 500 localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"2"}]},{"type":"text","value":"-server-with-index.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/19688d3ad91aec599a91e6fee75a2ba8/b41cb/07-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABWElEQVQoz3VR206EMBDlMxR6hbYzvQBlYZc1upfE+OKD8VmN//8ZDsasrInJCTntzJk5PRS4e7w/P+fphGmGuLN++h9bSHtMe9/uz08vD+fn4oa7UiDXUerIVKikJ5Qc2Df5g8ZlQT0CiSjTFZUAOnx/oZJYMkdHHceShnJHNz8lAaWAGjftfPLjA6HGobjUljKzskmmm00/N2kivugvVQ7Wj7E7+niI6Vibi1h6pqKCwQ53TAdMk3Kd6XbStKvpWLtsoLeYtUlM4e9mCRvd3RG5LU3IO67wllmmPPt1jiZNzg8WehohdCiWYISjDq5TRSYXn5iG2WBP4vWjlpzSFtsthrG2HVe+WA0mLAkx3YZ8aMJcqXiViACDGcLo/MZApkSuxOSClLxuXZyZSqzuKhnW4sYmR54xN7blEq43L7EFeoy2PbUSX/78arnbv4bzJxze4PiOp48vH7dYmEuudCAAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Main view","title":"","src":"/static/19688d3ad91aec599a91e6fee75a2ba8/99f37/07-A.png","srcSet":["/static/19688d3ad91aec599a91e6fee75a2ba8/6b2ea/07-A.png 275w","/static/19688d3ad91aec599a91e6fee75a2ba8/dd45a/07-A.png 550w","/static/19688d3ad91aec599a91e6fee75a2ba8/99f37/07-A.png 1100w","/static/19688d3ad91aec599a91e6fee75a2ba8/573d3/07-A.png 1650w","/static/19688d3ad91aec599a91e6fee75a2ba8/b41cb/07-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Much better. We can immediately see that the time in mongo and fastify bubbles has dropped by about one third.\nLooking at the timeline we can also notice that the total time to serve those 500 requests went down from 15 seconds to 9 seconds.\nAlso the timeline itself became denser, meaning we spend less time waiting between serving the requests.\nIn other words - it took less time to do the same amount of work."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"How can we improve this even further? Let's explore the bubbles a bit. The mongodb bubble on the left\nis based on the mongodb npm module and there is probably not much we can do to improve this 3rd party\ndependency. Same goes for the fastify bubble on the top."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's dive in to our query bubble at the bottom:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/f4df82ba4c418ea34e1e7cb96bacfc67/b41cb/07-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABEUlEQVQoz32Q60rEMBCF8xTa7aa3NMlMLm3T27Ygu1bYX4rgbxXf/zFMV5G1rcJHGIZzcmaGqMP5bnqquhPaAcxBqO5PdA/FqIpBFeN0fj4+PJKbkAcR7BOVMENT7YuZWH0XVwRUMlnFzPo6hyblFdlRsY/BE17eL36a+99NJl3ZDca1HgYFWYs80jQ0xVUfhapBNxwqiXWa26U5jGSUaSy7rU+RgRNYS9VkvIxStWlWCbe3IafJIhy56aSqfbInzhRZKMIItBu9P9hYG3PbY9Gjbpm4JF+bfWycG7BtSMUqdr4oRwe6lfPaLvE7L0QBzXeUb17Rm3Nh5TyzY6KIUiDrhH+Q44uePuD4Cqc3vH//BMd1VZs8iDmzAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Mongo cursor","title":"","src":"/static/f4df82ba4c418ea34e1e7cb96bacfc67/99f37/07-B.png","srcSet":["/static/f4df82ba4c418ea34e1e7cb96bacfc67/6b2ea/07-B.png 275w","/static/f4df82ba4c418ea34e1e7cb96bacfc67/dd45a/07-B.png 550w","/static/f4df82ba4c418ea34e1e7cb96bacfc67/99f37/07-B.png 1100w","/static/f4df82ba4c418ea34e1e7cb96bacfc67/573d3/07-B.png 1650w","/static/f4df82ba4c418ea34e1e7cb96bacfc67/b41cb/07-B.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This bubble clearly shows that our queries are executed in series as one follows the other.\nHowever if we think about this a little bit, there is actually no need for that. Both of the\nqueries are independent so we can easily execute them in parallel. Doing that would make\nthis bubble much smaller and hopefully increase performance."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/08-parallel-queries/"},"children":[{"type":"text","value":"Parallel queries"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/07-improving-our-latency/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Improving our latency","priority":7}}}},{"title":"08 Parallel Queries","entry":{"id":"ec0cf17a-d417-5afc-9f29-d90481d28839","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"parallel-queries","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#parallel-queries","ariaLabel":"parallel queries permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Parallel queries"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The third example, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"3-server-with-index-in-parallel.js"}]},{"type":"text","value":" is similar to second example, but executes the queries\nin parallel. Let's profile it again."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon -c 5 -a 500 localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"3"}]},{"type":"text","value":"-server-with-index-in-parallel.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/f5b4d268888c3f34df7471756935735d/b41cb/08-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABa0lEQVQoz3WR367TMAzG+xiw5m+bxE6arMnWdd0O4wwhbkBCXAPi/R8Dp2enICGk76K1/Ys/2w3OH9/dv+TpGeMZhtn66f86QVwwLj4t909fbx8+N2847ARyPUg9MBVa6VuBVfTxj3ooshso27ui7di0AtZqeNGOWaaDwrxF/pZ22ZcLlosvV9Gn5jXhCGu50240+7PJi3LErw23dzkYLD5dfXgK8Sa7B+xaidIkm5c+zZgmG7Idz308VVPcvfLYQTaQLWZtIld+hSUqP3f5uhNgQzE4Ch38fhZu3w1Hym6wGSbni4XRQK1pGOVUEFDaLjDpIU2rQwfDgcn6LhVtMHnBdMJw7Oy+dq4wDcbrqmx8MmF+ywzBxk8mXHZ/PNNRaOYM4ej8gczLPhJMK3F0JKajMtngRADJhpOyBwpuOyO4t9GRZ8ydTVzC2lkAU74eWTgyU38l8kf85fiPsd3yLdx/we07vP+Bzz9/A9kqWW0H6+B3AAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Main view","title":"","src":"/static/f5b4d268888c3f34df7471756935735d/99f37/08-A.png","srcSet":["/static/f5b4d268888c3f34df7471756935735d/6b2ea/08-A.png 275w","/static/f5b4d268888c3f34df7471756935735d/dd45a/08-A.png 550w","/static/f5b4d268888c3f34df7471756935735d/99f37/08-A.png 1100w","/static/f5b4d268888c3f34df7471756935735d/573d3/08-A.png 1650w","/static/f5b4d268888c3f34df7471756935735d/b41cb/08-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now instead of having a simple mongodb query bubble we have two tiny ones each flanking our fastify\nbubble on the top. This is much better as it means we are doing more async operations in parallel."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once again we can see a drop in the total times by further one third. This is reflected both in the bubbles and the timeline."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As it stands, this bubble layout is close to optimal. We have almost no userland code taking up any time anymore,\nwhich means most time is spent in 3rd party modules - which we assume to be pretty optimal for their usecase\nas well."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The main way to improve this now, would be to get rid of the mongodb bubble or fastify bubble entirely. Getting rid of fastify would be\nhard as our application is a http server and fastify is already really good at doing http stuff. To get rid of the mongodb bubble we would\nhave to do fewer things with the database."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/09-caching-the-results/"},"children":[{"type":"text","value":"Caching the results"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/08-parallel-queries/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Parallel queries","priority":8}}}},{"title":"09 Caching The Results","entry":{"id":"39d20308-279c-57cd-863a-7554d46ce670","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"caching-the-results","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#caching-the-results","ariaLabel":"caching the results permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Caching the results"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A way to do that would be to add caching. Our result seldomly changes so caching it in an LRU cache\nwould be a great way to reduce the amount of database queries done in total."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is implemented in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"4-server-with-caching.js"}]},{"type":"text","value":". Let's run it:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon -c 5 -a 500 localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"4"}]},{"type":"text","value":"-server-with-caching.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/3569454ee519f02bbe0cdfc78fd29e67/b41cb/09-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABS0lEQVQoz3WR207DMAyG+xhoac5N4uawtvSwTmKsnG5AQlwD4v0fA3ejrEJC+hVZsT/H/pPB8HAzvdTdEeLOhcGU3f/qXRyxrEz76fH1cPecXVG7YUBl4DLkwhNenpUvwVraNVhGmDVlq0yVEeYIg9M5a0MtnhKuCYdTfEnN96YyabC7J6or7J5dclhKLddRhVb46yIOlPs1uWFOu9q3o0/30tS5WME4uYqjjr1KfZHaZj/Z0FEBhF945erC1QYqZSsq/A+cc+B6S7jnZstsxZWH1Iki5TKuHocidLZszNyiYrLMEFu2NVSWptnjqqiiHIjwCK94wLkg9eDRrS0VK3ieKna59GfPTNhRleah0F60+rRzAbXzrUVHXM11WGBqmQ6sSGdyZgRgaibXhploXYWkNokJd3l5Dhbyz//9yo5vfvpyh3d3+wHHz2+861gcE5t+KQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Main view","title":"","src":"/static/3569454ee519f02bbe0cdfc78fd29e67/99f37/09-A.png","srcSet":["/static/3569454ee519f02bbe0cdfc78fd29e67/6b2ea/09-A.png 275w","/static/3569454ee519f02bbe0cdfc78fd29e67/dd45a/09-A.png 550w","/static/3569454ee519f02bbe0cdfc78fd29e67/99f37/09-A.png 1100w","/static/3569454ee519f02bbe0cdfc78fd29e67/573d3/09-A.png 1650w","/static/3569454ee519f02bbe0cdfc78fd29e67/b41cb/09-A.png 1661w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Our mongodb bubbles have shrunk 7x. And about 20x in comparison with the first example. Also, following the yellow line in the timeline\ntells us that mongodb activity has been replaced by caching activity after initial query response arrived.\nNow our mongodb bubbles are tiny - and by far the most time is spent just serving http requests."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Hope this helps you understand the Bubbleprof tool better and how to use it to find your bottlenecks."}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/bubbleprof/09-caching-the-results/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Caching the results","priority":9}}}}]},{"title":"Cli","entry":{"id":"7d2aec31-a4ed-5496-bb4e-f065af540ca5","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"cli","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#cli","ariaLabel":"cli permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"CLI"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js comes with a number of tools to help us identify performance issues in our Node.js applications. All these tools can be accessed using the top-level "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic"}]},{"type":"text","value":" command once "},{"type":"element","tagName":"a","properties":{"href":"/documentation/"},"children":[{"type":"text","value":"Clinic.js is installed"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"the-anatomy-of-a-command","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#the-anatomy-of-a-command","ariaLabel":"the anatomy of a command permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"The anatomy of a command"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A Clinic.js command in its simplest form that generates a "},{"type":"element","tagName":"a","properties":{"href":"/doctor/"},"children":[{"type":"text","value":"Doctor"}]},{"type":"text","value":" sample is as follows:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor -- node server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" denotes the "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/api/cli.html#cli_1","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"end of the command and flags"}]},{"type":"text","value":", dividing the command into the following two related parts:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"1."}]},{"type":"text","value":" "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]},{"type":"text","value":" informs Clinic.js that we wish to use "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/"},"children":[{"type":"text","value":"Clinic.js Doctor"}]},{"type":"text","value":" to get an overview of our application's current performance."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"2."}]},{"type":"text","value":" "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node server.js"}]},{"type":"text","value":" is the command we use in order to run our Node.js application from the command line as normal. "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If our application needs some "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/api/cli.html#cli_environment_variables","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"environment variables"}]},{"type":"text","value":", we can set them beforehand:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NODE_ENV=production clinic doctor -- node server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"From here, we can start making the most out of Clinic.js by "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/01-simulating-load/"},"children":[{"type":"text","value":"simulating load"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"viewing-tool-information","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#viewing-tool-information","ariaLabel":"viewing tool information permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Viewing tool information"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To see all help information relating to a Clinic.js tool including the version and "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/04-reference/#flags"},"children":[{"type":"text","value":"supported flags"}]},{"type":"text","value":" we can simply run:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Or, to quickly see the version of each Clinic.js tool:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame --version"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we want to just see information about an installed version of Clinic.js:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Or, to just see the installed version of Clinic.js:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic --version"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For a complete list of options, see the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/04-reference"},"children":[{"type":"text","value":"CLI reference"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/01-simulating-load/"},"children":[{"type":"text","value":"Simulating load"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/cli/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":4}}},"links":[{"title":"01 Simulating Load","entry":{"id":"af6be9a5-cb28-5f06-9c6f-de2f7d91a125","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"simulating-load","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#simulating-load","ariaLabel":"simulating load permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Simulating load"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If our app handles requests, simply pointing Clinic.js at it won't be particularly insightful when testing its performance, since there will be no load to monitor unless we're manually using the running app. One way around this is to simulate load using a benchmarking tool like "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/mcollina/autocannon","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"using-autocannon","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#using-autocannon","ariaLabel":"using autocannon permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Using autocannon"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can simulate load on our server with autocannon very easily using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--autocannon"}]},{"type":"text","value":" flag:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'localhost:$PORT'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js automatically replaces the value of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$PORT"}]},{"type":"text","value":" with the actual port our server is listening to inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"server.js"}]},{"type":"text","value":". To make things even simpler, if we've set up our server to use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"PORT"}]},{"type":"text","value":" environment variable for the application port, we can produce the same results as the above command like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" / "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":" is the same as "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"'localhost:$PORT'"}]},{"type":"text","value":" inside the subargs: "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[ ]"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Be careful to ensure there is space after the opening and before the closing square bracket to ensure the subargs are parsed correctly."}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"common-autocannon-flags","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#common-autocannon-flags","ariaLabel":"common autocannon flags permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Common autocannon flags"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All available flags can be seen in the "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/mcollina/autocannon#command-line","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"autocannon README"}]},{"type":"text","value":", but some of the more common flags are documented below."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"connections","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#connections","ariaLabel":"connections permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Connections"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default, autocannon will set the number of concurrent connections to 10. To change this to 100 for example, we can set the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-c"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--connections"}]},{"type":"text","value":" flag as a subarg like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" -c "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"100"}]},{"type":"text","value":" / "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"http-methods","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#http-methods","ariaLabel":"http methods permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"HTTP methods"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's say we have an API with a POST endpoint that we want to test and monitor, this is easily accomplished using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-m"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--method"}]},{"type":"text","value":" flag as a subarg:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" -m POST /api/item "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's probably not that helpful without sending some actual data in the body of the request though, so let's add some using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-b"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--body"}]},{"type":"text","value":" flag as a subarg:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" -m POST /api/item -b "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'{\"my\": \"data\"}'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This could get a bit hard to manage with JSON strings or any other data type as part of the command, especially if we want to test different endpoints with different data sets or varying lengths. Handily autocannon supports using a local file to provide data for the request body, so with some JSON files we can simplify this load test with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-i"}]},{"type":"text","value":" flag like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" -m POST /api/item -i my-data.json "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Neat!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"using-our-own-command","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#using-our-own-command","ariaLabel":"using our own command permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Using our own command"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For more control, we can point any custom command at our server by using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" flag. With "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" globally installed we can simulate load on our app like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Just like with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--autocannon"}]},{"type":"text","value":" flag, Clinic.js replaces the value of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$PORT"}]},{"type":"text","value":" with the actual port our server is listening to inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"server.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The advantage of the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" flag is that it gives us the flexibility to use any command we like, including other benchmarking tools such as "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/wg/wrk","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"wrk"}]},{"type":"text","value":". For example, a similar command as above with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"wrk"}]},{"type":"text","value":" globally installed would be:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'wrk http://localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js then simply monitors the performance of the application under simulated load and will generate a sample when the script running "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" exits. Which script we use is entirely up to us, we might have some complicated test commands already in place as "},{"type":"element","tagName":"a","properties":{"href":"https://docs.npmjs.com/cli/run-script.html","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"NPM scripts"}]},{"type":"text","value":" so we could easily call one of those instead:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'npm run load-test'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/02-controlling-the-output/"},"children":[{"type":"text","value":"Controlling the output"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/cli/01-simulating-load/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":1}}}},{"title":"02 Controlling The Output","entry":{"id":"1defbf60-9454-5197-a678-8adc73ae2fc8","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"controlling-the-output","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#controlling-the-output","ariaLabel":"controlling the output permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Controlling the output"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default, any of the Clinic.js tool commands will generate a compiled HTML file and directory of data, so the following command:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Would generate a file structure like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".clinic/1234.clinic-doctor/1234.clinic-doctor-processstat\n.clinic/1234.clinic-doctor/1234.clinic-doctor-systeminfo\n.clinic/1234.clinic-doctor/1234.clinic-doctor-traceevent\n.clinic/1234.clinic-doctor.html"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"The exact output will vary between "},{"type":"element","tagName":"a","properties":{"href":"/doctor/"},"children":[{"type":"text","value":"Doctor"}]},{"type":"text","value":", "},{"type":"element","tagName":"a","properties":{"href":"/flame/"},"children":[{"type":"text","value":"Flame"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"/bubbleprof/"},"children":[{"type":"text","value":"Bubbleprof"}]},{"type":"text","value":" since each tool generates and requires slightly different data to create a sample."}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"collecting-data-only","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#collecting-data-only","ariaLabel":"collecting data only permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Collecting data only"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In order to prevent any tool from generating the HTML, we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--collect-only"}]},{"type":"text","value":" flag like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --collect-only -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This would generate a directory from which the HTML profile can be generated, with a file structure similar to this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".clinic/1234.clinic-doctor/1234.clinic-doctor-processstat\n.clinic/1234.clinic-doctor/1234.clinic-doctor-systeminfo\n.clinic/1234.clinic-doctor/1234.clinic-doctor-traceevent"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"visualizing-existing-data","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#visualizing-existing-data","ariaLabel":"visualizing existing data permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Visualizing existing data"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To generate or re-generate the HTML profile from Clinic.js collected data, we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--visualize-only"}]},{"type":"text","value":" flag and pass it the local path to the existing data like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --visualize-only .clinic/1234.clinic-doctor"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This would generate the following HTML file in the same directory as its data directory "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1234.clinic-doctor"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".clinic/1234.clinic-doctor.html"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Note that since we're generating the sample visualization from an existing sample, we don't need to call any server start script after a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" flag delimiter when passing a directory path to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--visualize-only"}]},{"type":"text","value":" flag."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"changing-the-output-destination","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#changing-the-output-destination","ariaLabel":"changing the output destination permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Changing the output destination"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default all tool sample files will be generated within the directory the command is run from ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"). To change this, we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--dest"}]},{"type":"text","value":" flag to point to a different destination like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --dest "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":".."}]},{"type":"text","value":"/some-other-dir -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is quite useful when generating lots of Clinic.js files to ensure they don't fall within a project directory and avoid any version control mistakes!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/03-managing-samples/"},"children":[{"type":"text","value":"Managing samples"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/cli/02-controlling-the-output/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":3}}}},{"title":"03 Managing Samples","entry":{"id":"c44f6d37-77c2-5f4c-b93f-1eed7cbf4fff","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"managing-samples","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#managing-samples","ariaLabel":"managing samples permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Managing samples"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After we've used Clinic.js tools to gain insight into our application's performance, addressed some observed bottlenecks and re-tested, we might end up with a directory filled with Clinic.js-generated samples. To remove all of these files and directories we can run the following command from the directory these samples reside in:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic clean"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we've placed our files somewhere else, we can simply add the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--path"}]},{"type":"text","value":" flag to point to that directory instead:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic clean --path "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":".."}]},{"type":"text","value":"/some-other-dir"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After running this command there should be no more samples left in the directory. This can be a handy step if we've finished analysing our app and need to push code changes, but don't want Clinic.js samples in our application's repo."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"ignoring-files-in-git","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#ignoring-files-in-git","ariaLabel":"ignoring files in git permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Ignoring files in git"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":", we can add this entry to our application's "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".gitignore"}]},{"type":"text","value":" file to ensure any samples are ignored in the future:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Alternatively, we can use a global gitignore, so the project does not have to change to accomodate Clinic.js. To configure a global ignore file for git, and add "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":".clinic"}]},{"type":"text","value":" to it, open a command line and do:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" config --global core.excludesfile ~/.gitignore_global\n"},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"echo"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'.clinic'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">>"}]},{"type":"text","value":" ~/.gitignore_global"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Get up to speed with the ins and outs of Clinic.js with the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/04-reference"},"children":[{"type":"text","value":"CLI reference"}]},{"type":"text","value":"."}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/cli/03-managing-samples/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":4}}}},{"title":"04 Reference","entry":{"id":"31fdd6f2-6df7-5014-b425-f23acd61c63d","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"reference","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#reference","ariaLabel":"reference permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Reference"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This page contains a reference of all the commands and flags supported by Clinic.js to help us get the most out of using Clinic.js."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"commands","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#commands","ariaLabel":"commands permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Commands"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-textclinic-doctorcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-textclinic-doctorcode","ariaLabel":"code classlanguage textclinic doctorcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Separated by the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" flag delimiter, this command takes a start script for a Node.js application and generates "},{"type":"element","tagName":"a","properties":{"href":"/doctor/"},"children":[{"type":"text","value":"Doctor"}]},{"type":"text","value":" sample to diagnose performance issues."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For more technical information follow the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/"},"children":[{"type":"text","value":"Doctor docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-textclinic-flamecode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-textclinic-flamecode","ariaLabel":"code classlanguage textclinic flamecode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Separated by the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" flag delimiter, this command takes a start script for a Node.js application and generates "},{"type":"element","tagName":"a","properties":{"href":"/flame/"},"children":[{"type":"text","value":"Flame"}]},{"type":"text","value":" sample to uncover bottlenecks and hot functions in code with flamegraphs."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For more technical information follow the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/"},"children":[{"type":"text","value":"Flame docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-textclinic-bubbleprofcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-textclinic-bubbleprofcode","ariaLabel":"code classlanguage textclinic bubbleprofcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic bubbleprof"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Separated by the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":" flag delimiter, this command takes a start script for a Node.js application and generates "},{"type":"element","tagName":"a","properties":{"href":"/bubbleprof/"},"children":[{"type":"text","value":"Bubbleprof"}]},{"type":"text","value":" sample to observe and map async operations."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic bubbleprof -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For more technical information follow the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/"},"children":[{"type":"text","value":"Bubbleprof docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"flags","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flags","ariaLabel":"flags permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flags"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Below is a reference list of useful flags (options) that can be passed to Clinic.js when generating samples with Doctor, Flame and Bubbleprof."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--on-portcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--on-portcode","ariaLabel":"code classlanguage text  on portcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Takes a command string which is executed when the application that's being profiled starts listening to a port."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'my-script localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"More information about this flag with use cases can be found in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/01-simulating-load/#using-our-own-command"},"children":[{"type":"text","value":"Simulating load docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--autocannoncode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--autocannoncode","ariaLabel":"code classlanguage text  autocannoncode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--autocannon"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Takes subargs inside the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[ ]"}]},{"type":"text","value":" which are passed to autocannon."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'localhost:$PORT'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"More information about this flag with use cases can be found in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/01-simulating-load/#using-autocannond"},"children":[{"type":"text","value":"Simulating load docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--collect-onlycode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--collect-onlycode","ariaLabel":"code classlanguage text  collect onlycode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--collect-only"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If used, the Clinic.js tool will only generate a directory of sample information with no visualization HTML."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --collect-only -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"More information about this flag can be found in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/02-controlling-the-output/#collecting-data-only"},"children":[{"type":"text","value":"Controlling the output docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--visualize-onlycode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--visualize-onlycode","ariaLabel":"code classlanguage text  visualize onlycode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--visualize-only"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Takes a path to a directory of previously collected Clinic tool sample data and generates visualization HTML to view the output in a browser."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --visualize-only .clinic/1234.clinic-doctor"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"More information about this flag can be found in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/02-controlling-the-output/#visualizing-existing-data"},"children":[{"type":"text","value":"Controlling the output docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--destcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--destcode","ariaLabel":"code classlanguage text  destcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--dest"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Takes a path to a local directory which the generated sample output is saved to."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --dest "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":".."}]},{"type":"text","value":"/some-other-dir -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"More information about this flag can be found in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/cli/02-controlling-the-output/#changing-the-output-destination"},"children":[{"type":"text","value":"Controlling the output docs"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Default"}]},{"type":"text","value":": "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":" (current directory)"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--sample-intervalcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--sample-intervalcode","ariaLabel":"code classlanguage text  sample intervalcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--sample-interval"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Takes a number and changes the rate at which Doctor samples an application in milliseconds."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Example"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --sample-interval "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"100"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" server.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Default"}]},{"type":"text","value":": "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"10"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"* This flag is applicable with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]},{"type":"text","value":" command."}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--versioncode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--versioncode","ariaLabel":"code classlanguage text  versioncode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--version"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If used will output the current installed version of the Clinic.js or the specific Clinic.js tool."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Examples"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic --version\n"},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"# or"}]},{"type":"text","value":"\nclinic -v\n\nclinic doctor --version\n"},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"# or"}]},{"type":"text","value":"\nclinic doctor -v"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"code-classlanguage-text--helpcode","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-classlanguage-text--helpcode","ariaLabel":"code classlanguage text  helpcode permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--help"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If used will output help text with example commands and supported flags for Clinic.js or the specific Clinic.js tool."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Examples"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic --help\n"},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"# or"}]},{"type":"text","value":"\nclinic -h\n\nclinic doctor --help\n"},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"# or"}]},{"type":"text","value":"\nclinic doctor -h"}]}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/cli/04-reference/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":5}}}}]},{"title":"Doctor","entry":{"id":"9781cdd1-6242-581b-baf2-bcb226492711","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"doctor","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#doctor","ariaLabel":"doctor permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Doctor"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Symptoms such as low CPU usage, blocking garbage collection, frequent event loop delay or a chaotic number of active handles may indicate a number of potential problems. Doctor helps narrow down the possibilities by generating a recommendation based on those symptoms. Examples such as I/O issues, non-optimized garbage collection and blocked event loop are quite common. Doctor will help you with all of these."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/01-setup/"},"children":[{"type":"text","value":"Setup"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/04-reading-a-profile/"},"children":[{"type":"text","value":"Reading a profile"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/05-fixing-event-loop-problem/"},"children":[{"type":"text","value":"Fixing an event loop problem"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/06-fixing-io-problem/"},"children":[{"type":"text","value":"Fixing an I/O problem"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":1}}},"links":[{"title":"01 Setup","entry":{"id":"e2cbd14e-7e0c-5f7c-89ab-642aee78a59a","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"setup","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#setup","ariaLabel":"setup permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Setup"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Doctor is part of the Clinic.js suit of tools. To install Doctor, simply install Clinic.js like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After installing, we can check if Doctor has been installed by running the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]},{"type":"text","value":" command\nwith the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--help"}]},{"type":"text","value":" flag."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic doctor --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It should print something similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Clinic.js Doctor - v3.12.0\n\nclinic doctor is the first step in profiling your application.\nIt will show you what kind of problem you are having and recommend the path\nforward.\n\nTo run clinic doctor\n\n  clinic doctor -- node server.js\n\nIf profiling on a server, it can be useful to only do data collection:\n\n  clinic doctor --collect-only -- node server.js\n\nYou can then transfer the data and visualize it locally:\n\n  clinic doctor --visualize-only PID.clinic-doctor-sample\n\nFlags\n-h | --help                Display Help\n-v | --version             Display Version\n--collect-only             Do not process data on termination\n--visualize-only datapath  Build or rebuild visualization from data\n--sample-interval interval Sample interval in milliseconds\n--on-port                  Run a script when the server starts listening on a port.\n--dest                     Destination for the collect data (default .)."}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/01-setup/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Setup","priority":1}}}},{"title":"02 Getting Ready","entry":{"id":"e98a591d-7f88-57ec-8cf7-9848c05b05b1","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"getting-ready","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#getting-ready","ariaLabel":"getting ready permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Getting ready"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We need some example applications to use Doctor on. The repo\n"},{"type":"element","tagName":"a","properties":{"href":"https://github.com/clinicjs/node-clinic-doctor-examples","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples"}]}]},{"type":"text","value":"\ncontains several for us to explore. Let's run the following to clone the repository\nand install its dependencies:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" clone https://github.com/clinicjs/node-clinic-doctor-examples.git\n"},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" node-clinic-doctor-examples\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/clinicjs/node-clinic-doctor-examples","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"README"}]},{"type":"text","value":" contains some\ngeneral information, which can be read while the install completes."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/02-getting-ready/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Getting ready","priority":2}}}},{"title":"03 First Analysis","entry":{"id":"6b82547c-60dd-56d2-b71e-3d632b7416ad","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"first-analysis","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#first-analysis","ariaLabel":"first analysis permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"First analysis"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We're now ready to profile one of the example applications. For the first\nexample, we will use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-event-loop"}]},{"type":"text","value":". First, let's confirm that it is ready and\nworking by running "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node slow-event-loop"}]},{"type":"text","value":" from inside the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"examples"}]},{"type":"text","value":" directory.\nOnce the process seems to be running we can visit "},{"type":"element","tagName":"a","properties":{"href":"http://localhost:3000/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"http://localhost:3000/"}]},{"type":"text","value":" in a browser to check."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We should see some basic output in the browser, like "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"{}"}]},{"type":"text","value":". Ctrl-C in the\ncommand line to close the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-event-loop"}]},{"type":"text","value":" server."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is a server, so we need to apply load. Profiling a server handling\njust one request doesn't give us much data or indication of how it performs\nwhen handling many requests. We recommend the benchmarking\ntool "},{"type":"element","tagName":"a","properties":{"href":"https://www.npmjs.com/package/autocannon","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We will execute "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" in the example application directories when\nwe call the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic"}]},{"type":"text","value":" executable, so let's install it globally, with the\nfollowing command:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"npm install -g autocannon"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To load-test the server, we want to run it with Doctor, and point\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" at it as soon as it starts listening on a port. This will\nbombard the server with requests, as soon as it is ready to handle them\nand Doctor is ready to collect data."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's do all that with this single command, which automatically assigns\nthe correct ports:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor --on-port 'autocannon localhost:$PORT' -- node slow-event-loop"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's break this command down:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]},{"type":"text","value":" portion invokes the Doctor command tool."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" flag will execute the supplied script as soon as the server starts\nlistening on a port."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$PORT"}]},{"type":"text","value":" variable in that script is set to the first port that the server began\nlistening on."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Everything after the double-dash ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":") is the command which starts the server that\nwe want to profile, in this case "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node slow-event-loop"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This one command runs three executables: the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic doctor"}]},{"type":"text","value":" parent executable, the\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" executable in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" and the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" executable."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Upon running the command, the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-event-loop"}]},{"type":"text","value":" server will be hit by requests from\n10 concurrent connections for 10 seconds (as per "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" defaults).\nthen the results be compiled into a single HTML file that should automatically\nopen in the browser."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The resulting HTML should look similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/d699a3eb16a8065de8aecbeb14f527d5/ad00e/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABX0lEQVQoz5WQSU4DMRBFfQkU0oOr3G5P7Z4yEDIxBSIhNlyBDWy4DgJxW8pORworhPTa+vXdLtUv1l7drK4f635r60tbL//E+Mt+drPbP29vnxiWzWL5MF3eTxa7yeLOU5dmfWTl2jU5vtsctGs3vttW3cY1F1h6VujWVFOQVYYmR5uBSY8kXAvVGD8v3TQXHspWqE65KaiuMH2Gjkk3S7BOwCVYnZKKKgFT6C4V9Rhsgj5y8g9YVljq1PKi4tKD9IcTyprI0KJqQXdIqC5o1WIg6Fw4Rp92vbE9osvBBNDmYOlMuebCxVA+pUTkxDPiKBdDWWlZF4UXYDk3wA2PAJiMHpNvJpmgxyFIYBA+jF2qRqA955oSRvTJwhSn4QtPIjqaZhlEXCcT1LuMOWVFUHggYknjhVIeSj/cysEJ2x6N4WwMowTOA3gCjI/itz9At2zz+rl//756+5q/fPyXHx3MbuvPwS2oAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor profile screenshot","title":"","src":"/static/d699a3eb16a8065de8aecbeb14f527d5/99f37/03.png","srcSet":["/static/d699a3eb16a8065de8aecbeb14f527d5/6b2ea/03.png 275w","/static/d699a3eb16a8065de8aecbeb14f527d5/dd45a/03.png 550w","/static/d699a3eb16a8065de8aecbeb14f527d5/99f37/03.png 1100w","/static/d699a3eb16a8065de8aecbeb14f527d5/ad00e/03.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/04-reading-a-profile/"},"children":[{"type":"text","value":"Reading a profile"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/03-first-analysis/","template":"src/templates/documentation.js"},"frontmatter":{"title":"First analysis","priority":3}}}},{"title":"04 Reading A Profile","entry":{"id":"d24edb2f-bf8d-5f52-838c-8a3b45c215e0","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"reading-a-profile","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#reading-a-profile","ariaLabel":"reading a profile permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Reading a profile"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The Clinic.js Doctor profile has three main sections:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Alert Bar"}]},{"type":"text","value":": Points us towards the main problem, if there is one. Also contains "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"View Controls"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Graphs"}]},{"type":"text","value":": Plot the data from which Doctor is drawing its conclusions"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Recommendations Panel"}]},{"type":"text","value":": Detailed explanation of the problem with next steps"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"alert-bar","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#alert-bar","ariaLabel":"alert bar permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Alert Bar"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/36bf05d98947002e03836e15c083df3a/ad00e/04-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 4%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAIAAABR8BlyAAAACXBIWXMAAAsSAAALEgHS3X78AAAAJElEQVQI12OwtPextPO2sPUCkgamztoG9jqGDgSRrpGTtoEtAJXDDN9ivJmWAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor Alert Bar - closed","title":"","src":"/static/36bf05d98947002e03836e15c083df3a/99f37/04-A.png","srcSet":["/static/36bf05d98947002e03836e15c083df3a/6b2ea/04-A.png 275w","/static/36bf05d98947002e03836e15c083df3a/dd45a/04-A.png 550w","/static/36bf05d98947002e03836e15c083df3a/99f37/04-A.png 1100w","/static/36bf05d98947002e03836e15c083df3a/ad00e/04-A.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on this to open it out, and we see a one-line summary of the main problem, if\nthere is one. Hover over this summary and it will underline the title of the specific\ngraph that Doctor thinks is most relevant to understanding the problem."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Doctor does not generally identify more than one issue, so there will generally be either one\nproblem here, or a note that no problems were found. This is because one performance problem\ncan disrupt the data needed to diagnose another problem. For example, if Doctor is sure there\nis an event loop problem, it might not be able to take enough readings to judge if there\nis an I/O problem."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A first-time user will mainly use the Alert Bar to see if there is a detected problem or not,\nbefore going straight to the description in the Recommendations Panel to understand it better.\nA more experienced user will recognise common detected problems and then study the appropriate\ngraphs for clues about how this particular example of the problem is manefesting itself."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the above example, Doctor is telling us that it has detected a problem, and the problem is\n\"a potential Event Loop issue\", which can be seen in the Event Loop Delay graph:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/c0a8148579033ba7d12a334fc122d845/ad00e/04-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 40.72727272727273%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAAsSAAALEgHS3X78AAABN0lEQVQY00WQ2U7DMBBF8xdQx/sWe5zESWlTSpFAoiJIfUGCF/7/Rxi7LNLR1Z2x5bnjRrvpfP5cL19PLx+n5/f9w2W7vG0PP8zLOi2vqMUfVjTF369d2gsNjXTjND/GuFMuS5uVn/6QLnvYD/MJ8lF3s4Od75eUjw4W3WXCfWPC3Kp4yxyyYb7iNldPrbSJ24GqRGRsVWoVUN23EljR2BjYMZepTswMzPTYrabQyoATmM0USzsyM9b+yGwp8aFGmN740fhB6sgq/IqJVHZcg8Yjm3BD/nekAUsqQyM1ZLgbw9aJyHknRBBXFaFlnmnAPbkZiAQcVZOnqyEiNAq34v6GWsJ8yyu/hjDHdU9kwi8goiO8sPlX3zg/WtsLDGZAmMSrltImDCbdoFyJLQ1IU8LXa+iBqfANPrZI8zhvrIAAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor Alert Bar - open, indicating a graph","title":"","src":"/static/c0a8148579033ba7d12a334fc122d845/99f37/04-B.png","srcSet":["/static/c0a8148579033ba7d12a334fc122d845/6b2ea/04-B.png 275w","/static/c0a8148579033ba7d12a334fc122d845/dd45a/04-B.png 550w","/static/c0a8148579033ba7d12a334fc122d845/99f37/04-B.png 1100w","/static/c0a8148579033ba7d12a334fc122d845/ad00e/04-B.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"view-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#view-controls","ariaLabel":"view controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"View controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To the right of the Alert Bar there are two buttons to change the view:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"img","properties":{"src":"/assets/images/doctor-docs-04-C.png","alt":"Grid icon","style":"vertical-align: bottom;"},"children":[]},{"type":"text","value":" "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Grid\nView / List View."}]},{"type":"text","value":" By default, Doctor shows all graphs in a grid so they can all be seen on the screen\nat once. This button switches to a List View where each graph takes the full width of the screen.\nThis can be useful for advanced users who might want to study the detail of the graphs.\nWhen in List View, clicking on the problem described in the Alert Bar scrolls\nthe page down to the most relevant graph, if it is not in view."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/a488fa25a507f7684c86653986efb60e/21482/04-E.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 40.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAAsSAAALEgHS3X78AAAA9UlEQVQY032R62pCMRCE8xrmutnEnNxP1RbRlv4pvv8rdZOjxR9F+BiGYcjuEmawni+30+V2PP8Q9fAd2zX1zxfk9SvVD/CFubCm8g6+Kps0ZglRmOU10sStxlw67UziBGQOQ4V98OyfmM3MTWQYj9p3ZaPCTJNpvvrTabQrcqqeCZlNaTgTEMEVg5nroCDSK8aN5RUmWozCTf+FYWj7fHTLmwB6vhrfXTxo3yCsCoswaQAT89A7C7Ohc6w7KBK7sFXYwoG08eGbdCOUeDcCGxUETgOZ4bLCvhEakyVDM33RLhtfiBGGTkfSafQjdOpoukJNuvEX40REuQmcB3gAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor profile in List View","title":"","src":"/static/a488fa25a507f7684c86653986efb60e/99f37/04-E.png","srcSet":["/static/a488fa25a507f7684c86653986efb60e/6b2ea/04-E.png 275w","/static/a488fa25a507f7684c86653986efb60e/dd45a/04-E.png 550w","/static/a488fa25a507f7684c86653986efb60e/99f37/04-E.png 1100w","/static/a488fa25a507f7684c86653986efb60e/21482/04-E.png 1350w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"img","properties":{"src":"/assets/images/doctor-docs-04-D.png","alt":"Eye icon","style":"vertical-align: bottom;"},"children":[]},{"type":"text","value":" "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Light\nTheme / Dark Theme."}]},{"type":"text","value":" By default, Doctor uses a theme with a dark background and light text. This is\ngood for reducing glare, but some in situations (or for some individual preferences), a theme with\na light background and dark text is better. For example, we will probably want to switch to\nthe Light Theme when taking screenshots that will be printed on paper, or when projecting\na Doctor profile in a well-lit room where the dark theme is hard to read."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/4303a4129bb57240bd7f68fda00a41a1/ad00e/04-F.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 39.63636363636363%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAAsSAAALEgHS3X78AAAA+UlEQVQY001RC5LFIAjz/kd80w/gB9RW2xtsdNu3m2EyRgQluvM4aF13ImFh5pRSfmFmqpomLGd95WSttTpTYyLokjOillJfnOcJZhYfQilF1ZKaF4/KECJ2HPm4cSAOO/snaPBGYrng3AopYSO/PSmcHDJpdj4qBCAeGPy7wIXobZY3eppus2wu0Bp15lprB+autbd2TfTerxe9N+R6O+/ruq/+x3dHzsEV/iyyrIZ3+vgNlXCWmkv9LMQ+hvQ/aRLUcnUpRll3WCIA3voyE5dheNlJMAj2sMszOZlxq8uqESPGMfb4k/gAc8NqWD8MgLkD4c0Oib/8ARrcrw7JTT4bAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor profile in Light Theme","title":"","src":"/static/4303a4129bb57240bd7f68fda00a41a1/99f37/04-F.png","srcSet":["/static/4303a4129bb57240bd7f68fda00a41a1/6b2ea/04-F.png 275w","/static/4303a4129bb57240bd7f68fda00a41a1/dd45a/04-F.png 550w","/static/4303a4129bb57240bd7f68fda00a41a1/99f37/04-F.png 1100w","/static/4303a4129bb57240bd7f68fda00a41a1/ad00e/04-F.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"graphs","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#graphs","ariaLabel":"graphs permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Graphs"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These plot various variables used in Doctor's analysis over time, from the start time of the profile\n(left end of the X-axis) to the finish time (right end of the X-axis)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All graphs use the same X-axis. We will see that hovering over one shows the values at the same\npoint in time on all the other graphs."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/b750e14ce27b15143813ea66c7b85384/ad00e/04-G.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 34.54545454545455%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsSAAALEgHS3X78AAABNUlEQVQY0zWQ60oDMRCF9yXE7maTyT2bZLe3haJIS3W12Cotij+KVAX7Cv7w8Z10K3wMZM5kOHMyaYdVbBd3u/lyS4XPqS6YLZhBcmqY8MZPtq/Hr+NvHN8QXtkw5WYo7AhUzGQ1JbLp1u/d+sD0qABPRCx4ICLkrFJuVPC42nzuP35sfX1JHUr/+PSZ2zEBWwqPy0DXCRW5btAI17Wopsq3Js76SeEmPWCGGQHHVCjBDkqJhvFZgD2T/FtQIS/VxYAVVJNThzBD0l024yrWoX3oXm7nz0IEAMeh6qHMUhlMPbtaPC3u34Rr0SoedYaHTJlGgO8e96vNAUTEkNJ6ak/VMNXkUM2Xu832W9rJoMQ43clRqpnStTYNemPSn06tucYahWkwaiYDZoZqyR1Pai/hTMrlD9ilQg4Dm9p7AAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor graphs with tooltips","title":"","src":"/static/b750e14ce27b15143813ea66c7b85384/99f37/04-G.png","srcSet":["/static/b750e14ce27b15143813ea66c7b85384/6b2ea/04-G.png 275w","/static/b750e14ce27b15143813ea66c7b85384/dd45a/04-G.png 550w","/static/b750e14ce27b15143813ea66c7b85384/99f37/04-G.png 1100w","/static/b750e14ce27b15143813ea66c7b85384/ad00e/04-G.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"cpu-usage-","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#cpu-usage-","ariaLabel":"cpu usage  permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"CPU Usage %"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This graph shows what percentage of the machine's available CPU capacity was being used by the\nNode.js process being profiled at any one point in time."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/389c9373f960566e37d4a083ebaee209/31493/04-H.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 664px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 33.45454545454545%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsSAAALEgHS3X78AAABAklEQVQY04WQ20rDQBCG8xCSNNkc9rwm2aZJE4utVVqU4o1Q21LwSorkQvENxCtf3J+kgjel8DF887MDO+Oktinr2XhyK0zhBtwjAviRCmJ9FkdldSJyrovFw3a9a9fbt+dda8u5RzhJzJlhkU1cnw5Cudl/vH/+HNqvQ/t9NX10A0oSvFCn0Y6014TZUJbT5Wb19Hq3erm5319WCyLLSI3/qP75EUJTRxbzUDdBbFwiLnzuhRKbD7qd/Uj39Ujc0Yf9t7N6meiK8hSbM2mpyCGoMc8gEUu7BJ4hAbQPpcVFHJM3ibQ4GHphRhCmhhC0TBeYhyNheshRpZVmhFClFYZ/AQO2QVDrqakTAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"CPU Usage graph","title":"","src":"/static/389c9373f960566e37d4a083ebaee209/31493/04-H.png","srcSet":["/static/389c9373f960566e37d4a083ebaee209/6b2ea/04-H.png 275w","/static/389c9373f960566e37d4a083ebaee209/dd45a/04-H.png 550w","/static/389c9373f960566e37d4a083ebaee209/31493/04-H.png 664w"],"sizes":["(max-width:","664px)","100vw,","664px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"CPU Usage can exceed 100%"}]},{"type":"text","value":" if the machine has multiple cores. 100% on this graph means\n100% of the capacity of a single core."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Spikes in this graph indicate high CPU activity. This can be a problem if it is excessive and\ncorrelates with event loop blockage (see below), but rapid spikes can be a sign that the server\nis healthily processing high load quickly. Too little CPU activity can be a sign that the Node.js\nprocess is stuck waiting for an I/O operation to complete, like a slow database query or file write."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this profile, the processor is usually fairly busy, which looks healthy."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In part 6 of this walkthrough, "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/06-fixing-io-problem/"},"children":[{"type":"text","value":"Fixing an I/O problem"}]},{"type":"text","value":",\nwe will see an example of an unhealthy CPU Usage graph."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"memory-usage-mb","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#memory-usage-mb","ariaLabel":"memory usage mb permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Memory Usage MB"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This graph has three lines, showing megabytes of memory at each point in time, all on the same\nscale."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/3ae52eee7e17187afb4f6a8f7c6b8493/3996e/04-I.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 648px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 32.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAA00lEQVQY022MWW7DIBRFWUZjTJjMPAbbleWkX93/nvrA6VcrHV3de0APYWra/qrb87F/Ha9v7dsHUTdqTdyVbxOPoRy5naU9Yz1mmaTbynq6tN+IRoRZKuPMPRlg6jDrTNT2Mia8dpi/nq45UYNc2oSpE/WYB8xCz7/85+E6MmGVbsU8/uLfRcTxKWLWzSx6md/zuujQ4uqSTqIeg3rXjagGeYc0K3TwQ0KOCV2v0OEQEjr7/MmWIHRStnAVtYMMi80cpIqLLUx61WWUJnd0Vq6C/AFxIDVZWFFWuAAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Memory Usage graph","title":"","src":"/static/3ae52eee7e17187afb4f6a8f7c6b8493/3996e/04-I.png","srcSet":["/static/3ae52eee7e17187afb4f6a8f7c6b8493/6b2ea/04-I.png 275w","/static/3ae52eee7e17187afb4f6a8f7c6b8493/dd45a/04-I.png 550w","/static/3ae52eee7e17187afb4f6a8f7c6b8493/3996e/04-I.png 648w"],"sizes":["(max-width:","648px)","100vw,","648px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The three lines are:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"RSS (Resident Set Size)"}]},{"type":"text","value":": This will always be the highest value, representing all memory\nallocated as part of the execution of this process. The gap between this line and the Total Heap\nAllocated line represents non-heap memory, such as storing of the JS code itself, the \"stack\"\nwhich contains variable pointers and primitives like boolean and integer states, and a memory pool\nfor "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/api/buffer.html","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Buffer"}]},{"type":"text","value":" contents."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"THA (Total Heap Allocated)"}]},{"type":"text","value":": This is the amount of space that has been set aside for storing\nitems that have a reference, such as strings, objects and function closures. Unlike the stack,\nwhere the reference pointers to these items are stored, a pre-set amount of memory is assigned\nfor the heap, before it is needed."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"HU (Heap Used)"}]},{"type":"text","value":": This is how much heap memory is actually being used at this point. It\nrepresents the total size of all strings, objects, closures etc that have been allocated but\nnot garbage collected at a given point in time. "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"This is usually the most interesting line"}]},{"type":"text","value":",\nwith RSS and Total Heap Allocated providing context."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A constantly increasing Heap Used line suggests a possible memory leak, where references to\nsomething are remaining in-scope, meaning it can't ever be garbage collected and therefore\ncausing available memory to eventually run dry. The opposite is perhaps a more common problem:\nmany sharp drops, correlating with high readings in the Event Loop Delay graph, suggests that\ndisruptive garbage collection events are disrupting the process and blocking\nNode.js from executing code."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this profile, the heap goes up and down fairly gradually, there is always plenty of spare\nheap allocation, and there is plenty of non-heap memory in the Resident Set as well. This looks healthy."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we encounter an unhealthy Memory graph, the specific line indicating a problem will be marked\nin red:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/54f57b35734b5bc7c4caba599f008c6d/6edca/04-Q.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.72727272727273%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABvklEQVQoz4XQ2W7TQBgFYL9FG8Ah8Tqbx56xY8/EyzSx0yZAaHHctAWEukCkvk5708dlspQrENKno3N+yzdjhJUS1RmJcg9ngAhAMhiIP/TFJ5n/etxOnFJezeZtXi2MgRMI2cSiZumEZ1M2OkF0DIjcGetOWEmiAgYSUj1zHBY4zGEwGrqBYbk0YIWDEsvnNuA6h140cLXQHCLLoyiUhArLjSwYOzABVLgw9knat7HhQOahkQciD3IPMn+L64Qke29j2w8BSoCekO8wAJieCPKB/tkCHJDUB5GPGEB8n3sDh9hugCEjKA5wTBCnONl2lFCS6E9Gz3TNITAH4I3p9kxHOzbt40PR6fYt2Ou7R+/sI33R+dbSuWcEvBCikek0xAKjjGBBiQyIDPWDoZFPRCxOCVMgyCEtYFjCSO1UHpHG5MOPxepx9vGuqq+r+qqcrqVayaodq06oNqvarGyl6g5O1rL5Kptvsr4RamWU9eWn9uFzt1mufi67X+eXm8nie6q6rPqSlhd/UZwflBdGWiybxU1ztp7N1/WsO9U5vy7rLpXzfxm9FkNtXurHF/XwnN9pT+PbJ51acf/8X78BWEGRUqUPy2QAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Doctor profile showing a memory problem","title":"","src":"/static/54f57b35734b5bc7c4caba599f008c6d/99f37/04-Q.png","srcSet":["/static/54f57b35734b5bc7c4caba599f008c6d/6b2ea/04-Q.png 275w","/static/54f57b35734b5bc7c4caba599f008c6d/dd45a/04-Q.png 550w","/static/54f57b35734b5bc7c4caba599f008c6d/99f37/04-Q.png 1100w","/static/54f57b35734b5bc7c4caba599f008c6d/6edca/04-Q.png 1351w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"event-loop-delay-ms","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#event-loop-delay-ms","ariaLabel":"event loop delay ms permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Event Loop Delay ms"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This represents points in time in which Node.js was blocked by executing synchronous\nJavaScript code."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/96a3560909bdff9ba406fa0e400777b1/23296/04-J.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 675px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 32.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAAyElEQVQY042QOwvCMBSF8zd81DbvJjW1YFuFTurgqEiHCoqD+BgEJxcHf7u3jdbXInxczj0nNyEXNRxORZhEWZaOs2QUm6HyAu7pL8QTq6mrmh2BhI6UGaw3l+3uuj/e5otdqyPbPzifgFMOY250Ny1W51l+yIvTZLoE908QkWHAQhdrp0S1PQUfgcBWK2pq31bkUt0PYsICLAyVIeZdriLCDSyCSAMtlT1SRaUjDPN7YDI/gnkEF1QP+oAVDnm0FfKVvp/B5cLuRQ03jJEtz1MAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Event Loop Delay graph","title":"","src":"/static/96a3560909bdff9ba406fa0e400777b1/23296/04-J.png","srcSet":["/static/96a3560909bdff9ba406fa0e400777b1/6b2ea/04-J.png 275w","/static/96a3560909bdff9ba406fa0e400777b1/dd45a/04-J.png 550w","/static/96a3560909bdff9ba406fa0e400777b1/23296/04-J.png 675w"],"sizes":["(max-width:","675px)","100vw,","675px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It is important that we understand how this graph works, because it\nalso gives us information about the acuity of the other graphs:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The Y-axis represents the duration of the event loop delay that ended at the moment in\ntime indicated by the tooltip arrow"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"This is then always followed by a horizontal line representing the same amount of time on\nthe X-axis. For the length of this line, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Node.js was blocked"}]},{"type":"text","value":", therefore, we don't have\nany data on "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"any"}]},{"type":"text","value":" graphs. If we run the cursor along a graph containing\nsubstantial event loop delay, the tooltip jumps - this is because no data could be\ncollected between the jumps, for any graphs, because Node.js was stuck executing some\nslow synchronous code."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For example, in the below screenshot, we can see:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"That this is the (joint) longest event loop delay seen in this profile, because it is the\nhighest point on the Y-axis."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"That this delay took up a noticable chunk of the duration of the profile, by looking at the\nhorizontal line between this tooltip and the previous one."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Moving the cursor along, we can see that four event loop delays account for most of the\nrun time. We can also see that this is causing the other data to be very course - after\nthe first quarter of a second or so, there are noticable jumps between each reading for\nmemory, CPU, etc, because Node.js was too busy executing some slow synchronous code to\neven take another reading."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is clearly not healthy - and Doctor has flagged it as such, colouring this graph\nred and pointing to it in the Alert box."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"event-loop-utilization-","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#event-loop-utilization-","ariaLabel":"event loop utilization  permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Event Loop Utilization %"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This graph shows what percentage of the Node.js Event Loop was being used by the process being profiled at any one point in time."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/6a166ca8826853a9b59017692eded19d/00e09/04-R.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 23.272727272727273%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAeklEQVQY06WPzQrCQAyE8xhVd7f729q0Wyjqwfd/sDGhiPZSwR6GLzMDAyGuD1ynO6blCeYbcjvAuB72T5ELjOQZJYzIQh1MB0Q64mXZ2B5n2+F0UMSxopHjIqMqs0Pzo1eS15e7Ga0w5gr39nFEKmuuXvPw1W9YPv4FY+uMBrcjqVUAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Event Loop Utilization graph","title":"","src":"/static/6a166ca8826853a9b59017692eded19d/99f37/04-R.png","srcSet":["/static/6a166ca8826853a9b59017692eded19d/6b2ea/04-R.png 275w","/static/6a166ca8826853a9b59017692eded19d/dd45a/04-R.png 550w","/static/6a166ca8826853a9b59017692eded19d/99f37/04-R.png 1100w","/static/6a166ca8826853a9b59017692eded19d/573d3/04-R.png 1650w","/static/6a166ca8826853a9b59017692eded19d/00e09/04-R.png 1854w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Event Loop Utilization (ELU) is a critical metric in Node.js environments, providing a more precise understanding of the event loop's efficiency and the application's performance. It measures the ratio of the event loop's busy time to its idle time, offering insights into the application's performance beyond traditional CPU metrics. CPU utilization can be misleading. A Node.js process might not use 100% of a CPU, not because it's efficient, but because it's waiting on I/O or other asynchronous operations. This waiting time can lead to underestimation of the process's actual load."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before ELU, metrics like event loop delay (the time difference between when an event was scheduled to be executed and when it was actually executed) were used. However, this metric doesn't account for the time the event loop was idle or the application's scalability."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"ELU helps in pinpointing performance bottlenecks. A high ELU value indicates that the event loop is busy, which might lead to slower request handling and reduced throughput. Understanding this can guide optimizations, such as code refactoring or load balancing. An unexpected rise in ELU can signal issues that wouldn't necessarily be caught by other metrics, such as inefficient code or resource leaks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If there is an issue with the Event Loop Utilization, a warning of type Event Loop will be triggered. "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For further reading regarding the Event Loop Utilization we can refer to the "},{"type":"element","tagName":"a","properties":{"href":"https://nodesource.com/blog/event-loop-utilization-nodejs","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Introduction to Event Loop Utilization in Node.js\n"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"active-handles","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#active-handles","ariaLabel":"active handles permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Active Handles"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This graph shows the quantity of I/O handles presently active, awaiting an output."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/219ffa9cf01783b28257f3e3e05545d9/68e9c/04-K.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 654px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 34.18181818181818%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsSAAALEgHS3X78AAAArElEQVQY042Oaw6CMBCEewyKfdCyWwoFeUWNev97OVRjDD8MyZfJzGQnrZjW+7g+lsvTUZKKSs2HMAGIOl3rdIPasGiajjErl0rDwoRV2laaWNr2VB3Gxu1lw3P+A/8l/JjwNRgvhSKpuVAsdYDZgaNdky+3XlCcHPcV9dSMMHVzhofmMuX4UR8Gx6CnOBrfYS8QrO+0az0PqFxW7E0u39HliNLWCQaXuooYvwBn+jjSAa+tOAAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Active Handles graph","title":"","src":"/static/219ffa9cf01783b28257f3e3e05545d9/68e9c/04-K.png","srcSet":["/static/219ffa9cf01783b28257f3e3e05545d9/6b2ea/04-K.png 275w","/static/219ffa9cf01783b28257f3e3e05545d9/dd45a/04-K.png 550w","/static/219ffa9cf01783b28257f3e3e05545d9/68e9c/04-K.png 654w"],"sizes":["(max-width:","654px)","100vw,","654px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When Node.js delegates asychronously, such as using "},{"type":"element","tagName":"a","properties":{"href":"https://libuv.org/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"libuv"}]},{"type":"text","value":" to delegate\na task like a file write or a database query the operating system, it stores a \"handle\". An\n\"active handle\" is a delegated task that has not reported as being complete."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The Active Handles graph therefore gives us an idea of how much asychronous I/O activity\nthe Node.js process is waiting on at any point in time. This should ideally follow an\norderly pattern, rising and falling as requests are handled and completed. It can also\noffer clues when combined with the other graphs - for example, CPU spikes on a server\nthat correlate with increased active handles should usually also correlate with\nincoming requests."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This graph generally provides context for the other graphs. It's hard to say generically\nwhat an Active Handles graph \"should\" look like: we generally can't point to an Active\nHandles graph and say \"That looks unhealthy\" without knowing the application logic."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here, we have a period with very few active handles, and very little other activity, which\npresumably represents the process getting ready. There is then a steady period of [103]\nactive handles, which presumably represents incoming requests being dealt with. It tells\nus we can probably ignore that early period with very few active handles as not\nrepresenting typical server activity."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"recommendations-panel","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#recommendations-panel","ariaLabel":"recommendations panel permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Recommendations Panel"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on the blue bar at the bottom, and it will open a panel telling us more about Doctor's\nconclusions about what is happening with this application."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/b005ce77c877d64ecf2d58d17f891e3a/ad00e/04-M.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 5.454545454545455%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAIAAABR8BlyAAAACXBIWXMAAAsSAAALEgHS3X78AAAAF0lEQVQI12NwKtvsU7vNpWKLdeFGUhEARXwbiMmxr9cAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Recommendations Panel - closed","title":"","src":"/static/b005ce77c877d64ecf2d58d17f891e3a/99f37/04-M.png","srcSet":["/static/b005ce77c877d64ecf2d58d17f891e3a/6b2ea/04-M.png 275w","/static/b005ce77c877d64ecf2d58d17f891e3a/dd45a/04-M.png 550w","/static/b005ce77c877d64ecf2d58d17f891e3a/99f37/04-M.png 1100w","/static/b005ce77c877d64ecf2d58d17f891e3a/ad00e/04-M.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is in two parts: a Recommendations Summary, and a Recommendation in Detail article\nbelow a 'Read more' button."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"recommendations-summary","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#recommendations-summary","ariaLabel":"recommendations summary permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Recommendations Summary"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This gives a simple bullet point overview of the identified problem, typically with a\nsuggested next step."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/474986b77bde7a332535c5a4a68cb27d/6edca/04-N.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 23.636363636363637%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAIAAADKYVtkAAAACXBIWXMAAAsSAAALEgHS3X78AAAAtUlEQVQY03XMWQ6CMBCA4V6Ksm9SQQSpbUAWMRLFQxhffPFaYvRizmCiD8Tky+SfSVrC0s50JLW5anOYipXRH47G+9gZdSWdlcjLqSNIxA9s2YIg3rphpbtSG0FQe61Y/AMaOQLfIwHfEbHpRdFnshPFUZYnmHG2W6zaMGm8eWF5wmO55QvFSKiZIghsXIkR7fWg0maVFlR6UH/BBYPVBmsgVL+cIvz2iq9P//JwzsMfdxcNU28PjF8FJzDgagAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Recommendations Panel - open, not expanded","title":"","src":"/static/474986b77bde7a332535c5a4a68cb27d/99f37/04-N.png","srcSet":["/static/474986b77bde7a332535c5a4a68cb27d/6b2ea/04-N.png 275w","/static/474986b77bde7a332535c5a4a68cb27d/dd45a/04-N.png 550w","/static/474986b77bde7a332535c5a4a68cb27d/99f37/04-N.png 1100w","/static/474986b77bde7a332535c5a4a68cb27d/6edca/04-N.png 1351w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are a few UI controls:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The 'x' closes the panel"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\"Browse undetected issues\" allows us to read descriptions of issues that Doctor can\nidentify but hasn't identified for this profile. Clicking on this expands out some tabs\nto show descriptions of problems that Doctor has not identified for this profile. For example,\nWe might find this useful, for example:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"While learning about Node.js performance, to avoid creating new problems while fixing\nan existing problem."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"To understand why Doctor might not have identified a known problem. As discussed in\nthe "},{"type":"element","tagName":"a","properties":{"href":"#alert-bar"},"children":[{"type":"text","value":"Alert Bar section"}]},{"type":"text","value":", Doctor generally does not diagnose more than one problem at a time."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/4bf69d3b979a9915246c8048ab673700/21482/04-O.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 4%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAIAAABR8BlyAAAACXBIWXMAAAsSAAALEgHS3X78AAAALElEQVQI12Mws/Yzs/HHjfzM7ILMHMJsnUJcvGJsnUOtHILtXMLcvGOc3CMB0rsP4W6vYzUAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Recommendations Panel - browse undetected open","title":"","src":"/static/4bf69d3b979a9915246c8048ab673700/99f37/04-O.png","srcSet":["/static/4bf69d3b979a9915246c8048ab673700/6b2ea/04-O.png 275w","/static/4bf69d3b979a9915246c8048ab673700/dd45a/04-O.png 550w","/static/4bf69d3b979a9915246c8048ab673700/99f37/04-O.png 1100w","/static/4bf69d3b979a9915246c8048ab673700/21482/04-O.png 1350w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this case, it tells us that \"There may be one or more long running synchronous operations\nblocking the thread\", and recommends using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" to narrow down."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After reading the summary, we recommend clicking \"Read more\" to understand the problem\nin more depth."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"recommendation-in-detail","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#recommendation-in-detail","ariaLabel":"recommendation in detail permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Recommendation in Detail"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clicking 'Read more' expands the Recommendations Panel to show a detailed article on the\nperformance problem that has been diagnosed. These usually have three sections (clicking\non the contents list on the left allows us to skip to a particular section):"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Understanding the analysis"}]},{"type":"text","value":" describes the problem in depth."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Next Steps"}]},{"type":"text","value":" details some recommended steps to narrow down on the exact cause of\nthe problem, so we can fix it. Usually this involves using another tool in the Clinic.js\nsuite which can identify individual lines of problematic code."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Reference"}]},{"type":"text","value":" gives links for suggested further reading and credits any sources that\nwere quoted or used in writing this recommendation."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/899f2e13b32fa86e73f309d8f410200a/ad00e/04-P.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABlElEQVQoz3XR7W6bMBQGYC5lkzp16dRkSwzBgHHMp00CxkACKVmStmu7VJr2Zxe0ttp97jS03ZR10iN0AL8H6UUbuAxT0R/S3ql10rc/DP6A23/1TvEnxAJe0EBqlLfh7NyixZjmpqt0RyI70zuONMie88xVhlcbXjNmC5i1SdSk5VUit0m+FXIbiJaGNQ0XwPGqbovhZE9hss8DksNDzaQKknG6iqYrkW1gRZi0k6hmvKHBgngVbCF+tc930r3HWbODxk8+WzRH1gzTnIZwunK8YjjmQ/PRCIuX0we0EY7HhCMr7CNmTRSLaxYtWDSHPPFLGlSmm41w8r8w/2iwt8ejN8fI48vqbKfmV0V9reqbsrkpl19VfU38uW6/8nEN4XgwJEfv0buezqJazr+kxUVWXqblZSI3M3Uu5Npm5evhrkz4SVAm9AQBnq2hQiE3vjjz+RJgqp47PwhbAplCx3CNJ0Exlatp1iYgbafZKs3XgLBcx9ywxAHN/3af/vgVfX8gu7uOs/tJbp+Gjnt7//L2b78Bgy23o7G29OUAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Recommendations Panel - open, expanded","title":"","src":"/static/899f2e13b32fa86e73f309d8f410200a/99f37/04-P.png","srcSet":["/static/899f2e13b32fa86e73f309d8f410200a/6b2ea/04-P.png 275w","/static/899f2e13b32fa86e73f309d8f410200a/dd45a/04-P.png 550w","/static/899f2e13b32fa86e73f309d8f410200a/99f37/04-P.png 1100w","/static/899f2e13b32fa86e73f309d8f410200a/ad00e/04-P.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then we're ready to look at fixing the problem."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/05-fixing-event-loop-problem"},"children":[{"type":"text","value":"Fixing an event loop problem"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/04-reading-a-profile/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Reading a profile","priority":4}}}},{"title":"05 Fixing Event Loop Problem","entry":{"id":"0ed208cb-ff47-5703-bc4a-7424c148824e","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"fixing-an-event-loop-problem","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#fixing-an-event-loop-problem","ariaLabel":"fixing an event loop problem permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Fixing an event loop problem"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/04-reading-a-profile/"},"children":[{"type":"text","value":"Reading A Profile"}]},{"type":"text","value":", we saw how to understand the\ninformation Doctor is giving us, and why it recommends what it does. Now we'll look at fixing the problems."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"consulting-the-doctor","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#consulting-the-doctor","ariaLabel":"consulting the doctor permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Consulting the Doctor"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We've already read the profile we created in\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/03-first-analysis/"},"children":[{"type":"text","value":"First Analysis"}]},{"type":"text","value":", from the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-event-loop"}]},{"type":"text","value":"\nexample server in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples"}]},{"type":"text","value":". We were told that our problem was slow synchronous\ncode "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/04-reading-a-profile/#event-loop-delay-ms/"},"children":[{"type":"text","value":"blocking the event loop"}]},{"type":"text","value":",\nand Doctor recommended using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" to identify the problem."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/474986b77bde7a332535c5a4a68cb27d/6edca/04-N.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 23.636363636363637%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAIAAADKYVtkAAAACXBIWXMAAAsSAAALEgHS3X78AAAAtUlEQVQY03XMWQ6CMBCA4V6Ksm9SQQSpbUAWMRLFQxhffPFaYvRizmCiD8Tky+SfSVrC0s50JLW5anOYipXRH47G+9gZdSWdlcjLqSNIxA9s2YIg3rphpbtSG0FQe61Y/AMaOQLfIwHfEbHpRdFnshPFUZYnmHG2W6zaMGm8eWF5wmO55QvFSKiZIghsXIkR7fWg0maVFlR6UH/BBYPVBmsgVL+cIvz2iq9P//JwzsMfdxcNU28PjF8FJzDgagAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Recommendations Panel - open, not expanded","title":"","src":"/static/474986b77bde7a332535c5a4a68cb27d/99f37/04-N.png","srcSet":["/static/474986b77bde7a332535c5a4a68cb27d/6b2ea/04-N.png 275w","/static/474986b77bde7a332535c5a4a68cb27d/dd45a/04-N.png 550w","/static/474986b77bde7a332535c5a4a68cb27d/99f37/04-N.png 1100w","/static/474986b77bde7a332535c5a4a68cb27d/6edca/04-N.png 1351w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"following-the-prescription","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#following-the-prescription","ariaLabel":"following the prescription permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Following the prescription"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can create a Flame profile with a command that is the same as for Doctor,\nbut swapping "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"flame"}]},{"type":"text","value":" in for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"doctor"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"sh"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-sh"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-sh"]},"children":[{"type":"text","value":"clinic flame --on-port 'autocannon localhost:$PORT' -- node slow-event-loop"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Our output looks something like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/2382acf296f9b09248fd36271de55118/ffaa5/05-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 50.909090909090914%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABTklEQVQoz43O2U7CQBQG4OlqCyVtKdBVYFhqURAMF0pXUFuplFpAjU288P2fwiEgV4r8+XJyMvknOWCVhJv3fBYmtv/gBKE7RaJjgvBxvsw/v57iDLxk6fMifn3bfOR5mi6i6H6ZJqvNOluv0ixD8wA9xnEUBM5iMU+S+YVpAb1uVeRmVYWq0dXqZk2DstauKhCpqa3dsqdCxejIegtNVGubA+BPZ44X2J4/cT3Edv0tb8vx9svBxPHubNfzA9txh6NbYPUuJanMC7xwAqkqS7J+Dru9q2F/MAYYXQInh2BFRmoyEsQ4pWEOAcMrOEnhBPk/nGAEhZM7nNylBb1hXgO2rAOCwnDip0T8CccZvsbVWsUqRJ+hdQOMRl2qlCma2jWOBxUwDBdEUdG1/mgMBFEQy2KhWKAoiqZpkkTn/R6CJFmWpemzYonnOE7TjW9ofESus8UPdQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Flame profile","title":"","src":"/static/2382acf296f9b09248fd36271de55118/99f37/05-A.png","srcSet":["/static/2382acf296f9b09248fd36271de55118/6b2ea/05-A.png 275w","/static/2382acf296f9b09248fd36271de55118/dd45a/05-A.png 550w","/static/2382acf296f9b09248fd36271de55118/99f37/05-A.png 1100w","/static/2382acf296f9b09248fd36271de55118/ffaa5/05-A.png 1299w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js Flame by default selects the function call that spends most time blocking\nthe event loop, and has identified that the function spending the most time blocking\nthe event loop is "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"sleep"}]},{"type":"text","value":", on line 12 of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-event-loop/index.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples"}]},{"type":"text","value":" uses very simple example servers: for\nthis example, we don't need to dig deeper into the diagram or advanced features\ndetailed in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/"},"children":[{"type":"text","value":"Clinic.js Flame documentation walkthrough"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can immediately open up "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"index.js"}]},{"type":"text","value":" and look for fixable bottlenecks in the\nline Flame has picked out:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"server"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"get"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'/'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"req"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" res"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" next"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"sleep"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"30"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  res"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"send"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"next"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"sleep(30)"}]},{"type":"text","value":" call is the one flame picked out. Let's see what this "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"sleep"}]},{"type":"text","value":" function does:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"sleep"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"ms"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" future "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" Date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"now"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" ms\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"Date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"now"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":" future"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It's clear why this is causing an event loop delay."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The event loop is single-threaded: only one operation is processed at a time. Each\nrequest to this server queues a synchronous function on the event loop containing\na "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" loop which will repeatedly iterate for 30 milliseconds. Each of these blocks\nthe event loop: the single thread is busy iterating the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" loop, unable to process\nany other operations."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the pause was from an asynchronous timeout, like from "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"text","value":", the event loop\nwould not be blocked. The synchronous code containing "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"text","value":" would continue and\ncomplete, and then the callback function passed to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"text","value":" would be called in a\nseparate, future tick of the event loop."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"sleep"}]},{"type":"text","value":" function, however, is entirely synchronous. The event loop is blocked\nuntil it completes."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"curing-the-ailment","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#curing-the-ailment","ariaLabel":"curing the ailment permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Curing the ailment"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's reduce the duration of the loops, changing the arg passed to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"sleep"}]},{"type":"text","value":" to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"server"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"get"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'/'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"req"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" res"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" next"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"sleep"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"...save, and recreate the profile:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"sh"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-sh"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-sh"]},"children":[{"type":"text","value":"clinic doctor --on-port 'autocannon localhost:$PORT' -- node slow-event-loop"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The profile now detects no issues. Everything is blue, the graphs look healthy and Doctor's\nRecommendations Panel is cheerfully telling us that \"Everything looks good!\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/df6c29521ac94bc3fb55bf7b083af5e2/6edca/05-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.72727272727273%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABxUlEQVQoz5WQ227TQBCG/RpJEzu2N3te2+vDuvH6kBNN0kB6SKkUKhAqFRLPA7wvY1K44gbp06+Znd3Zf8bxQmnsRpslURVR9lXljMg+YMqKpOVxA+csqgGIqbKYZxMknBDHXGbBVEEXL2BewF2fTrCeIHXhYX+quMop157PQhwhHDORQoCZdgPmIGGEvYu6x6h9z7MFTxfCbKLmPm6P0AJaE3lJo4rFlkUA2JmxGNLKQ5EDN1g6xyInoiC9ZjSpMc+pNG6oJtOI6jnLVzxf82x5hoHm6wlOnQuPeCH3QjFw8XA8HbpkMAoHY/SbKVRhNvAPKVRfdYSA4Rg5AY64TCmVvk/8kPs+BqsBkiESIw/DzzKtsSgCokOa/gWxzAXbAdXJ1bO0t2q2F/lCltuoPcJIPK6gPA4E7IbQmLAEoKAQ07hfIVIOTzqz/5ZtXrLVp8QesvVHvTgps1HljsQdlaXStdR1r4mVulFpJ3QtdAOLdJb7z1fXT1V7KOuDqW8K+7aw70xzZ5rbsr0vu4eyO/7RYzl/LNdPPctTOX9w4Nmb3Wmz/1DPb4rLramue2a7M8Vse8b8C6f98mP19Wf38r1+/m9+AdeAi4jDP4atAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Doctor profile reporting no issue","title":"","src":"/static/df6c29521ac94bc3fb55bf7b083af5e2/99f37/05-B.png","srcSet":["/static/df6c29521ac94bc3fb55bf7b083af5e2/6b2ea/05-B.png 275w","/static/df6c29521ac94bc3fb55bf7b083af5e2/dd45a/05-B.png 550w","/static/df6c29521ac94bc3fb55bf7b083af5e2/99f37/05-B.png 1100w","/static/df6c29521ac94bc3fb55bf7b083af5e2/6edca/05-B.png 1351w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is a very simple example server. In a more complex application, we would normally\nneed to explore the Clinic.js Flame profile further to hone in on the cause or causes of the\nbottleneck. Detailed examples of how to do this are available in the\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/"},"children":[{"type":"text","value":"Clinic.js Flame documentation"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/06-fixing-io-problem/"},"children":[{"type":"text","value":"Fixing an I/O problem"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/05-fixing-event-loop-problem/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Fixing an event loop problem","priority":5}}}},{"title":"06 Fixing Io Problem","entry":{"id":"38216611-2dc3-52ff-ad9c-b4dd3c8adf4c","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"fixing-an-io-problem","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#fixing-an-io-problem","ariaLabel":"fixing an io problem permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Fixing an I/O problem"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/04-reading-a-profile/"},"children":[{"type":"text","value":"Reading A Profile"}]},{"type":"text","value":", we saw that the CPU Usage\ngraph can indicate problems with Node.js I/O (Input/Output) operations delegated to other processes,\nsuch as slow database queries or file writes delegated by "},{"type":"element","tagName":"a","properties":{"href":"https://libuv.org/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"libuv"}]},{"type":"text","value":").\nLet's look at that in more detail with an example."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"consulting-the-doctor","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#consulting-the-doctor","ariaLabel":"consulting the doctor permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Consulting the Doctor"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There is an example server for this problem in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples"}]},{"type":"text","value":", called "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"slow-io"}]},{"type":"text","value":".\nAssuming we have everything set up as described in\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/02-getting-ready/"},"children":[{"type":"text","value":"Getting Ready"}]},{"type":"text","value":" and\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/03-first-analysis/"},"children":[{"type":"text","value":"First Analysis"}]},{"type":"text","value":", let's\ncreate a Clinic.js Doctor profile from that server:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"sh"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-sh"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-sh"]},"children":[{"type":"text","value":"clinic doctor --on-port 'autocannon localhost:$PORT' -- node slow-io"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The output should look something like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/62113e7db45b2c219f16984d858856ab/ad00e/06-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABsUlEQVQoz22Q327TMBSH8xRbEzv+b8eOkzghcUa7dmWjrZAQGk+wcQE3PA6dJh6XE7MBF0ifPv2OHeWc46zb3bzdnXzYmDpWfv4fV4mXbOq5e7O7O91v333MhOn3t/fbu8/r/adp/SHEQz8f/wBlNx3CdOgj5GP4neejbSKVPhO621+f5nGv66j9rMB1fLGbbLvu42073mh/ZbtNHa6hLQRpe0SrTEiPiFkheYHEJZbABZI5lhgrOCm5w8wVtFqVJiemoA5RCwGlw8ybvuKeUiu5o8wy7hhzXjRRBckcM4HovlQdmOhAzVDqIeUB8zrjwjc6eEC1VjZOtU62kHsdBK+hM9ctrEdEDdBXUwlXNsPcCRu46ValhnnAC9RepgCfmmYmqi2YQ9wjXgMFS6YWXrtDRBelSkh4BiwaLDso81IR2UBZwLakgiVfvewM/8qEHbiLzE7MRlhJDu/VeOJ+w9xcymVgqhqYkAhHuFucSGPX2QrxHC9tMdFosYFBEFnKAsu8YAhzVAqEE+VfCsSzzdfnw/ef22/P08N5ejyPDz/GxWfw9Pg0fXkCj4npH4/p6hdIGnPhKZDNZgAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Doctor profile showing slow io","title":"","src":"/static/62113e7db45b2c219f16984d858856ab/99f37/06-A.png","srcSet":["/static/62113e7db45b2c219f16984d858856ab/6b2ea/06-A.png 275w","/static/62113e7db45b2c219f16984d858856ab/dd45a/06-A.png 550w","/static/62113e7db45b2c219f16984d858856ab/99f37/06-A.png 1100w","/static/62113e7db45b2c219f16984d858856ab/ad00e/06-A.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The CPU Usage graph is highlighted in red. It shows several spikes, but is mostly low.\nThere is less CPU activity than we'd expect from a busy server. The Recommendations Panel\nexplains that this is likely caused by slow "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"asynchronous"}]},{"type":"text","value":" operations: our application\nis waiting for external I/O to resolve promises or trigger callbacks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is a very different problem to the one we saw while\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/doctor/05-fixing-event-loop-problem/"},"children":[{"type":"text","value":"Fixing an event loop problem"}]},{"type":"text","value":".\nThe Recommendations Panel advises that we use another Clinic.js tool, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic bubbleprof"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"following-the-prescription","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#following-the-prescription","ariaLabel":"following the prescription permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Following the prescription"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can create a Bubbleprof profile with a command that is the same as for Doctor,\nbut swapping "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"bubbleprof"}]},{"type":"text","value":" in for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"doctor"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"sh"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-sh"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-sh"]},"children":[{"type":"text","value":"clinic bubbleprof --on-port 'autocannon localhost:$PORT' -- node slow-io"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Our output looks something like this:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/dc0157af64c0b7e67516f66208a7c5fc/ad00e/06-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABcUlEQVQoz3WRyU4CMQCGeQgTZ5gpnaV7O2WYQaADA2FxITFq0KsHLy6JF28+iYnGow9qB0HDYvKnadL/a7+2NVWcluPzwfBMaCObBZPd/1IVdFXomNnxfHF1c1tzIYtYhnkWkiYWuRfwvalDbmtE5EGsme5j1RuO5zUXYMdHdvxJvUHqDerbdjXZDGSIp5AqJyQHIOoNJrWthutjiFQkUtdHm0vUASgtLyeLl/LiycwfRieLXRiRrNNAcm2xcTKVXS77MT2CcVYMTyrYg3RFAgxCQbVxAdrVtjeHJImYxiKFsTDltIJhLEFYXfLQixBtcW4cP7ae21KAkrRDVS6SdkQSU85W2hYGIUM049KAQPoB+9VZB3uBEGbEdVs1uzHVqwezVbuGSK6bY/vOjr/HeQlzlOSEt5hqNyLRLcarky1fBTIvoMu9yL6vooxplbSUzhAWRX+0hitJvKP6h7leFMjB8PFj+vzZv39v371dv359A+WfZt6Mc0M0AAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Bubbleprof profile","title":"","src":"/static/dc0157af64c0b7e67516f66208a7c5fc/99f37/06-B.png","srcSet":["/static/dc0157af64c0b7e67516f66208a7c5fc/6b2ea/06-B.png 275w","/static/dc0157af64c0b7e67516f66208a7c5fc/dd45a/06-B.png 550w","/static/dc0157af64c0b7e67516f66208a7c5fc/99f37/06-B.png 1100w","/static/dc0157af64c0b7e67516f66208a7c5fc/ad00e/06-B.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples"}]},{"type":"text","value":" uses very simple example servers, so for now\nwe'll only need to look at the main diagram, not the more advanced features\ndetailed in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/"},"children":[{"type":"text","value":"Clinic.js Bubbleprof documentation walkthrough"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The main diagram shows a busy "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"http.connection"}]},{"type":"text","value":", calling a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"timeout"}]},{"type":"text","value":", which then calls\nmore "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"timeout"}]},{"type":"text","value":"s in parrallel. That first "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"timeout"}]},{"type":"text","value":" looks key - the rest of the application\nbranches off from it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It could be our bottleneck."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clicking on it opens it out to show two parts. Clicking on the longer part points us to some code:\na function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"async.series"}]},{"type":"text","value":", in our application, file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"./index.js"}]},{"type":"text","value":", line 9, column 16:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/3cf7340f5ac008ac9f925ee992d1fd79/0fb99/06-C.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 965px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 53.81818181818182%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAABHklEQVQoz43QYUvCQBgH8PsKSercbc7a6d1EC9KtW25rK7cud05IMixTBKEX0av6/nQsjZhzBD+O53ju/zxwoAJRSdarKjmGCDbaO8bO3zoLlCrKURlCjcj1llzHW9qWpKKa2vy9ZoA0c1ClpimacahbFIYavuhHqNmXVSSL/f8O4yrUW22zb47KcgPWRTI/jMWGDKVBqvC0Z0bYoJKipz+C9wFJQftEUj0h1/5Ugij3wQ9Azmyjm0oL0qXG+UCcPRrSQYLaJu7YuENzAfdmyibriK9Cvgzj1zu+GrI544tbNrecMXWTAoA6PIiXPt8EyVuQbPz7hTecOcGDGGp7iTWICwDqji/diR+vRy9fbP7JHt/Z04cXPVtXos2LfQN3BnE7SEyUIQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Bubbleprof profile","title":"","src":"/static/3cf7340f5ac008ac9f925ee992d1fd79/0fb99/06-C.png","srcSet":["/static/3cf7340f5ac008ac9f925ee992d1fd79/6b2ea/06-C.png 275w","/static/3cf7340f5ac008ac9f925ee992d1fd79/dd45a/06-C.png 550w","/static/3cf7340f5ac008ac9f925ee992d1fd79/0fb99/06-C.png 965w"],"sizes":["(max-width:","965px)","100vw,","965px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If we open "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node-clinic-doctor-examples/slow-io/index.js"}]},{"type":"text","value":" and find that line, we see:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"awaitData"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"callback"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  async"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"series"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done1"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done1"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done1"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":"\n        async"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"parallel"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Math"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"random"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1000"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          done1\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    callback\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is what Node.js is waiting on - chained timeouts."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the delay was an external process like a slow database query, the clues visible to\nus within Node.js would be the same. We can't see what exactly is happening within the external\noperation, but we can identify "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"which"}]},{"type":"text","value":" asynchronous operation Node.js is waiting for."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"curing-the-ailment","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#curing-the-ailment","ariaLabel":"curing the ailment permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Curing the ailment"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's reduce the duration of the timeouts, changing the second argument passed to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"text","value":" from "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1000"}]},{"type":"text","value":" to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":".\nThis simulates dramatically speeding up the external I/O:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"awaitData"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"callback"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  async"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"series"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done1"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done1"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done1"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":"\n        async"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"parallel"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"done2"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTimeout"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"done2"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          done1\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    callback\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We then save, and recreate the profile:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"sh"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-sh"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-sh"]},"children":[{"type":"text","value":"clinic doctor --on-port 'autocannon localhost:$PORT' -- node slow-io"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The profile now detects no issues. Everything is blue, the graphs look healthy,\nthe CPU is active, and Doctor's Recommendations Panel is cheerfully telling us\nthat \"Everything looks good!\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/3f07f6fec2bad9ab6c4cef3b164cbd62/ad00e/06-D.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 56.36363636363636%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAAB00lEQVQoz43Ry47TMBQG4DwFUks6SWMntmPHcZKOEzuXaVp67/Q2I0HphhVikJDYsOVV0CDEjnfE7YxghYT06dfvheVzZMuB0UBP48EQMYVYccm/SKSpqAgvTceRocO4xFy7ftS0cwsgHrLUg6HTxw6gTp+ci0ccL7RdDLGg/DogiQsZQMInKWYDSBKAYlWNLRTlyfyB13dMrWg2IqKicka4DtOhGcpcRkxiIyrOSSWi1yTKAUp0PbHcQLDywOp7qm6pnJubVK1pPg8HrxxfmPFQXGFR47gion6WNJAp3UytXh8DGPYB7thexwaX9Lo26PZApwevvNA8bubv9vzuVfDkpYNedL2ibC2zXoDjAAsPMi/gAGfn4keG7SA3iM20kGQAp3+YowuFbmaWAznJRpgXhKtQ1GF6gy9bkUjaLjFrI5IgHGOzPBGYiHMnAvqRbiYWzdqsfcP15pla82LJ1SpSy8D8EJVMlGdxSWPNRMXSxsBMtdOt1S5O49nbotpIo7yVT+Uib/Z5c5DNXtb7S+7y4X0+OhbjY1bf7V5/sPTNdrI6zdenari7VkupV1Iv/0ktjFwvUjndHt5Z40/fN19+zj7/qB8e/1Pz8VG9/3b8+us3ZtOO+yV5E1QAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Clinic.js Doctor profile, reporting no issue","title":"","src":"/static/3f07f6fec2bad9ab6c4cef3b164cbd62/99f37/06-D.png","srcSet":["/static/3f07f6fec2bad9ab6c4cef3b164cbd62/6b2ea/06-D.png 275w","/static/3f07f6fec2bad9ab6c4cef3b164cbd62/dd45a/06-D.png 550w","/static/3f07f6fec2bad9ab6c4cef3b164cbd62/99f37/06-D.png 1100w","/static/3f07f6fec2bad9ab6c4cef3b164cbd62/ad00e/06-D.png 1366w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is a very simple example server. In a more complex application, we would normally\nneed to explore the Clinic.js Bubbleprof profile deeper to hone in on the cause or causes of\nthe bottleneck. Detailed examples of how to do this are available in the\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/"},"children":[{"type":"text","value":"Clinic.js Bubbleprof documentation"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We're now familiar with how to use Doctor to identify the type of problem. The next step is learning\nmore about those tools we can use to hone in on specific code."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We're now ready to move on to the walkthrough documentation for:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/"},"children":[{"type":"text","value":"Clinic.js Flame"}]},{"type":"text","value":", for identifying slow synchronous code"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/bubbleprof/"},"children":[{"type":"text","value":"Clinic.js Bubbleprof"}]},{"type":"text","value":", for finding problems in asynchronous code"}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/doctor/06-fixing-io-problem/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Fixing an I/O problem","priority":6}}}}]},{"title":"Flame","entry":{"id":"d96cdea1-afcb-59c5-97fc-1cb7e10d6aac","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"flame","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flame","ariaLabel":"flame permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flame"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're looking to quickly get started with understanding\nflamegraphs and learning how to optimize Node.js code then this\nis a great place to start."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/01-setup/"},"children":[{"type":"text","value":"Setup"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/04-flamegraphs/"},"children":[{"type":"text","value":"Flamegraphs"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls/"},"children":[{"type":"text","value":"Controls"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/06-optimizing-a-hot-function/"},"children":[{"type":"text","value":"Optimizing a hot function"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/07-reducing-the-graph-size/"},"children":[{"type":"text","value":"Reducing the graph size"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/08-advanced-analysis/"},"children":[{"type":"text","value":"Advanced analysis"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/"},"children":[{"type":"text","value":"Advanced controls"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":2}}},"links":[{"title":"01 Setup","entry":{"id":"406166b5-f5e9-5ea2-b120-ac335f6d6d1d","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"setup","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#setup","ariaLabel":"setup permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Setup"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Flame is part of the Clinic.js suit of tools. To install Flame, simply install\nClinic.js like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After installing, we can check if Flame has been installed with running the\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" command with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--help"}]},{"type":"text","value":" flag."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It should print something similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Clinic.js Flame - v3.6.0 (0x v4.7.2)\n\nclinic flame helps you find synchronous bottlenecks\nby creating a flamegraph visualization that assists in identifying\nfunction calls that may be blocking the event loop.\n\nFor more information see the 0x readme, https://github.com/davidmarkclements/0x\n\nTo run clinic flame\n\n  clinic flame -- node server.js\n\nIf profiling on a server, it can be useful to only do data collection:\n\n  clinic flame --collect-only -- node server.js\n\nYou can then transfer the data and visualize it locally:\n\n  clinic flame --visualize-only PID.clinic.flame\n\nFlags\n-h | --help                Display Help\n-v | --version             Display Version\n--collect-only             Do not process data on termination\n--visualize-only datapath  Build or rebuild visualization from data"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/01-setup/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Setup","priority":1}}}},{"title":"02 Getting Ready","entry":{"id":"ae754da5-761f-53e0-b44d-3efc09582be9","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"getting-ready","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#getting-ready","ariaLabel":"getting ready permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Getting ready"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once we've installed "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic"}]},{"type":"text","value":" and verified that "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" is functioning\nwe can profile an application."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To try this out, let's clone and prepare the official Clinic.js Flame demo:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" clone https://github.com/clinicjs/node-clinic-flame-demo.git\n"},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" node-clinic-flame-demo\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"While npm downloads the dependencies, check the "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/clinicjs/node-clinic-flame-demo","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Readme"}]},{"type":"text","value":",\nthen we are ready to profile!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/02-getting-ready/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Getting ready","priority":2}}}},{"title":"03 First Analysis","entry":{"id":"50d8a357-34b7-5e32-a70e-cc6b36547b07","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"first-analysis","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#first-analysis","ariaLabel":"first analysis permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"First analysis"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now we're ready to profile the application."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's try with the first server in the repo, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1-server-with-slow-function.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It contains an HTTP server, built using Express with a root route ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":") that performs some work before rendering a landing page."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The server can be started with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node 1-server-with-slow-function.js"}]},{"type":"text","value":" and then accessed in the browser at "},{"type":"element","tagName":"a","properties":{"href":"http://localhost:3000/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"http://localhost:3000/"}]},{"type":"text","value":". If the landing page says\n\"Hello World\" then things are working!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's try and profile the server with Flame to see if we can find any bottlenecks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To do that we need a tool that can simulate sufficiently intense HTTP load."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We suggest "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" which is supported on Windows, Mac and Linux and is straightforward to use."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's install it from npm:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g autocannon"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To run the analysis we want to run the server with Flame and when the server is ready - i.e. starts listening on a port - we want to send a ton of requests to it using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All that can be performed with a single command, which can be copied and pasted as-is:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"-server-with-slow-function.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's break this command down:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" portion invokes the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"flame"}]},{"type":"text","value":"\ncommand tool."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" flag will execute the supplied script as soon as the server starts listening on a port."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$PORT"}]},{"type":"text","value":" variable in that script is set to the first port that the server began listening on."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Everything after the double-dash ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":") is the command which starts the server that we want to profile, in this case "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node 1-server-with-slow-function.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This one command runs three executables: the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic flame"}]},{"type":"text","value":" parent executable, the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" executable in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--on-port"}]},{"type":"text","value":" and the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" executable."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Upon running the command, the process will be load tested for 10 seconds (as per the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" default duration), then the results be compiled into a single HTML file that should automatically open in the browser."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The resulting HTML should look similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAAB7UlEQVQoz4WRa3OaQBSGFxYRQRsFlovAAiuIOhmtcTTaJl5IIs3YxLQdL82n5v//iR502k7aaTzz7OEse959YRd93z9n9+uP1+l0djebL+eLbDq/g/ow/cNhmi3Se2jIsocvX58XNyv0tP683Xx7efmx322f1qvVKttt89hsNrvD48h+v18/rm7S6adlOhkMPS+kPkOuH1tOSMMWizo+S/wwCViHBlC0HBrXveiIz1o0TOq04dGIxW3oDKM2spym5Sam0zTrTchWXsB2CbzMl6A4YNgRsSJix8QMzXpgu61u/wMaXY5Ho3Ge/2byu74cT6bTWZreLpfLq9kCvrTuxue9MXpXqZygXK5WazZlUbvb6Q6iTs/xmOM0zt9PEOJ4GG+COFwUVV/UmFD1C1Va1ALdjrr9CcIFieMwxwv/hcNCUZH1oGw2AIUwWfeJ3eiCMxblk2JcKIFYMaJcSUJZDzUQgzMviG8pj85SWSGhYsa53mAl3VetqD+8BmeJxyedpZLmKUYDPMG5pAeqxS5AzPEFGDwWjoANx+NXwKpQzP/ZSspmLBMmqX6NuIPRFaqcnYlFKT/zX0DvP2BelAVZLShazaLEZSqxehdD5PnUcR1NhyCQVVXFGPOvA27LMEgQBLZtVw1XNV3DMhzX/QnKBle/xFHKLwAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph screenshot","title":"","src":"/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png","srcSet":["/static/60ec54d4c38a25cb8c567ccf71a6c187/6b2ea/03.png 275w","/static/60ec54d4c38a25cb8c567ccf71a6c187/dd45a/03.png 550w","/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png 1100w","/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is known as a Flamegraph."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/04-flamegraphs"},"children":[{"type":"text","value":"Flamegraphs"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/03-first-analysis/","template":"src/templates/documentation.js"},"frontmatter":{"title":"First analysis","priority":3}}}},{"title":"04 Flamegraphs","entry":{"id":"98c2d423-63e4-5db6-9e01-5e68590bb89a","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"flamegraphs","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flamegraphs","ariaLabel":"flamegraphs permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flamegraphs"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look again at the flamegraph generated in the prior "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]},{"type":"text","value":" step."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAAB7UlEQVQoz4WRa3OaQBSGFxYRQRsFlovAAiuIOhmtcTTaJl5IIs3YxLQdL82n5v//iR502k7aaTzz7OEse959YRd93z9n9+uP1+l0djebL+eLbDq/g/ow/cNhmi3Se2jIsocvX58XNyv0tP683Xx7efmx322f1qvVKttt89hsNrvD48h+v18/rm7S6adlOhkMPS+kPkOuH1tOSMMWizo+S/wwCViHBlC0HBrXveiIz1o0TOq04dGIxW3oDKM2spym5Sam0zTrTchWXsB2CbzMl6A4YNgRsSJix8QMzXpgu61u/wMaXY5Ho3Ge/2byu74cT6bTWZreLpfLq9kCvrTuxue9MXpXqZygXK5WazZlUbvb6Q6iTs/xmOM0zt9PEOJ4GG+COFwUVV/UmFD1C1Va1ALdjrr9CcIFieMwxwv/hcNCUZH1oGw2AIUwWfeJ3eiCMxblk2JcKIFYMaJcSUJZDzUQgzMviG8pj85SWSGhYsa53mAl3VetqD+8BmeJxyedpZLmKUYDPMG5pAeqxS5AzPEFGDwWjoANx+NXwKpQzP/ZSspmLBMmqX6NuIPRFaqcnYlFKT/zX0DvP2BelAVZLShazaLEZSqxehdD5PnUcR1NhyCQVVXFGPOvA27LMEgQBLZtVw1XNV3DMhzX/QnKBle/xFHKLwAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example flamegraph from node-clinic-flame-demo","title":"","src":"/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png","srcSet":["/static/60ec54d4c38a25cb8c567ccf71a6c187/6b2ea/03.png 275w","/static/60ec54d4c38a25cb8c567ccf71a6c187/dd45a/03.png 550w","/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png 1100w","/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Ignoring the surrounding controls for the moment, let's focus in on understanding the visualization."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When generating a flamegraph we are asking three key questions:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"During the sampling period, which functions called each other?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"How much time was each function observed on-CPU?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"How much time was each function observed at the top of the stack?"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These three questions are answered visually."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"which-functions-called-each-other-the-stack","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#which-functions-called-each-other-the-stack","ariaLabel":"which functions called each other the stack permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Which functions called each other (the stack)"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each block represents the invocations of one function, aggregated by the call stack that led to it. When one block sits on top of another, it was called by the block below it, which was called by the block below it, and so on down the stack."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/c784a05011433eb4418ae85791697da8/5d6a0/04-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 20.363636363636363%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsSAAALEgHS3X78AAAAuklEQVQI1y2M227DIBAF4+IFlkswUCXGBhts5S7lof//cd2olebljDTncL0/x5RAIBqH1msXS87WWgCQqLnA05jWtq11q21f277tl2VtJeXL7X2wp8ql/gLBTRTHUQ6zGc6M9WRoEipkE4uOi45Zh6z89DFhvlKMsfbCMK64+ZYuCZe4PXcMyGAo9KVik2GRnshyyNLN3E3/sYoV0HcdY1wDuh6PoDwDpJ6+CKTmj2Gir4/0Rbnx8fr5BUPdEHoRAX/UAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example of how flamegraphs represent call stacks","title":"","src":"/static/c784a05011433eb4418ae85791697da8/99f37/04-A.png","srcSet":["/static/c784a05011433eb4418ae85791697da8/6b2ea/04-A.png 275w","/static/c784a05011433eb4418ae85791697da8/dd45a/04-A.png 550w","/static/c784a05011433eb4418ae85791697da8/99f37/04-A.png 1100w","/static/c784a05011433eb4418ae85791697da8/5d6a0/04-A.png 1580w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In Clinic.js Flame, the text and outline colours of each block help you navigate. White represents code in the application being profiled (i.e. code under your direct control). Blue represents your dependencies in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node_modules"}]},{"type":"text","value":", while grey represents code in Node.js core itself."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"how-long-in-aggregate-was-a-function-on-cpu-block-width","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#how-long-in-aggregate-was-a-function-on-cpu-block-width","ariaLabel":"how long in aggregate was a function on cpu block width permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"How long, in aggregate, was a function on-CPU (block width)"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The width of a block represents the amount of time it was on the CPU, out of the duration of the profile run. This does not necessarily mean the function was executing its own code: where there are blocks above it, it had called that function and was waiting for it to complete."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js Flame sorts the functions called by each function so that the widest blocks (the functions spending longest on the CPU) are shown first, on the left."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/cb5f24545b483df675c04a361af12edd/5d6a0/04-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 18.181818181818183%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsSAAALEgHS3X78AAAA00lEQVQI1yWKi26CMABFy8sIi84tYl+gW8fDR6lO0AqOUprs/39p1SXnntybXECSHJEMYbZCn5hmybqkafFvui6STZluSvuJ4QfEDJGv558tIUGUgba91438Pjecn66XdhhM32ul9NOjncb8KmWOp7q53OTt3nX9T68XqwRnNbjKsxBbUZWiKiqeH3aM7zMhdlW1Fce9LfyQd1IYLcdB6gftaFRMGIUpcPypDXAnDzseAI7jen608KZzL3y1uJMXN3z3omUwQ8EcBTPoR3H4RmLM/gCbCiDukAaulwAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example of how block width shows time on CPU","title":"","src":"/static/cb5f24545b483df675c04a361af12edd/99f37/04-B.png","srcSet":["/static/cb5f24545b483df675c04a361af12edd/6b2ea/04-B.png 275w","/static/cb5f24545b483df675c04a361af12edd/dd45a/04-B.png 550w","/static/cb5f24545b483df675c04a361af12edd/99f37/04-B.png 1100w","/static/cb5f24545b483df675c04a361af12edd/5d6a0/04-B.png 1580w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"how-often-was-a-function-at-the-top-of-stack-heat","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#how-often-was-a-function-at-the-top-of-stack-heat","ariaLabel":"how often was a function at the top of stack heat permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"How often was a function at the top of stack (\"heat\")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This can be rephrased as: \"For how long was a function blocking the Node.js event loop\".\nIf a function is frequently observed at the top of the stack, it means it\nis spending more time executing its own code than calling other functions\nor allowing function callbacks to trigger."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In Node.js, only one function can execute at any one time (ignoring possibilities like Worker threads). If a function takes a long time to execute,\nnothing else can happen, including the triggering of I/O callbacks. This is the essence of the phrase \"blocking the event loop\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The brightness of the bar along the exposed top of a block indicates the percentage of time a function was observed at the top of the stack. In other words, the hotter (or, brighter) a block, the more actual time it was taking to execute its own code, preventing any other code from executing."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/38f13a6ea48ca78ae269acf140dd128d/5d6a0/04-C.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 18.181818181818183%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsSAAALEgHS3X78AAAAz0lEQVQI1x2I7W6CMABFkQnELPGHsaUFoS2mLUu2TImLW5yI9AOE6Ps/jsXk5Oac64GYZkRQVqYZJ6zc5Nxl7qDSkeU8p8I9xCVx4lIizADaoIR5++rQdfpx7/9Pp/Fm6/psrbJGGXXtrGrbprN6uJn72I+D1eo69KaqDoslXEHi/R53XDAuC1kWXDK3DvFyMQmTH9uf4/58+VOmUfqidN3qZpXQAqUeWER4PkvCtzjwYeCjYIZCP4n8aV8Zh5PT9+gTAxGvvzD4TuEuhVuEnww3JGmdd1DAAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example of Clinic.js Flame using brightness of exposed tops to show ","heat\"\"":"","title":"","src":"/static/38f13a6ea48ca78ae269acf140dd128d/99f37/04-C.png","srcSet":["/static/38f13a6ea48ca78ae269acf140dd128d/6b2ea/04-C.png 275w","/static/38f13a6ea48ca78ae269acf140dd128d/dd45a/04-C.png 550w","/static/38f13a6ea48ca78ae269acf140dd128d/99f37/04-C.png 1100w","/static/38f13a6ea48ca78ae269acf140dd128d/5d6a0/04-C.png 1580w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When a function is blocking the event loop in higher proportion to other functions we call this a \"hot\" function. Looking for these \"hot\" functions is a good place to start looking for places to optimise your code. Clinic.js Flame by default selects the \"hottest\" frame, and gives controls to cycle through the next hottest."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls/"},"children":[{"type":"text","value":"Controls"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/04-flamegraphs/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Flamegraphs","priority":4}}}},{"title":"05 Controls","entry":{"id":"9bc0ee3d-3971-56f4-8f05-aa823b8f7bf8","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#controls","ariaLabel":"controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The Clinic.js Flame UI controls have three main sections:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Flamegraph controls"}]},{"type":"text","value":": Interacting with the flamegraph itself"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Info Panel"}]},{"type":"text","value":": Along the top, containing info about the block currently highlighted"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Options Menu"}]},{"type":"text","value":": More advanced controls expandable from the info panel"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"flamegraph-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flamegraph-controls","ariaLabel":"flamegraph controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flamegraph controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"interacting-with-a-flamegraph-block","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#interacting-with-a-flamegraph-block","ariaLabel":"interacting with a flamegraph block permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Interacting with a flamegraph block"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Hovering"}]},{"type":"text","value":" the mouse over a block will temporarily show info about that\nblock in the info panel at the top of the screen."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Clicking"}]},{"type":"text","value":" will select the block, so that the info panel reverts to that\nblock when you are no longer hovering over anything."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you find an interesting-looking block, it can be useful to click on it\nso you can hover around exploring its neighbours without losing it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-A.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"tooltip-buttons","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#tooltip-buttons","ariaLabel":"tooltip buttons permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Tooltip buttons"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After single-clicking on a block, or hovering over it for a moment, a tooltip appears,\nwith one or more buttons:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Expand"}]},{"type":"text","value":". "},{"type":"element","tagName":"a","properties":{"href":"#expanding"},"children":[{"type":"text","value":"See below"}]},{"type":"text","value":" for more about expanding a particular block."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Contract"}]},{"type":"text","value":". If this is the block that you have already expanded, it will show\n\"Contract\" instead of \"Expand\", which will take you back to the main view."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Copy path"}]},{"type":"text","value":". Copies to the clipboard the relative file path to the file\ncontaining the code this block represents. This only appears for blocks\nfrom the application being profiled (white) or its dependencies (blue)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Open in browser"}]},{"type":"text","value":". For Node.js core blocks only (grey). In a new browser tab,\nopens the GitHub page showing the source code for the Node.js function\nrepresented by this block. Exploring these can be a good way to learn\nmore about what Node.js is doing \"under the hood\"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-B.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"expanding","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#expanding","ariaLabel":"expanding permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Expanding"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When a block is double-clicked, or its tooltip \"Expand\" button is used,\nit will expand to fill the full width of the flamegraph.\nBlocks below will also expand and fill\nthe full width, while blocks above the clicked block will\nincrease in ratio to the block they sit on. Expanding a block\nessentially creates a new flamegraph which represents a particular\npartition of the main flamegraph."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The block that has been expanded is marked with a shadow underneath.\nEvery block below this 'shadow' is probably wider (longer on the CPU)\nthan the block that has expanded to fill the screen."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To get back to the main, non-expanded view, you can either click on the\nbackground, click \"Return to main view\" at the bottom of the screen,\ndouble-click on the expanded frame, or click on its \"Contract\" tooltip button."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-C.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"info-panel","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#info-panel","ariaLabel":"info panel permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Info panel"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are five main features in the Info Panel:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Stack bar"}]},{"type":"text","value":": A thin bar showing the \"hottest\" blocks in order"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Selection controls"}]},{"type":"text","value":": Flick to the next hottest, previous, etc"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Code info"}]},{"type":"text","value":": Where the function behind the currently highlighted block comes from"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Search box"}]},{"type":"text","value":": For finding functions by name or path"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Options Menu"}]},{"type":"text","value":": More advanced features. This "},{"type":"element","tagName":"a","properties":{"href":"#options-menu"},"children":[{"type":"text","value":"Options Menu has its own section below"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"stack-bar","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#stack-bar","ariaLabel":"stack bar permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Stack Bar"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We previously explained, in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/04-flamegraphs/"},"children":[{"type":"text","value":"Flamegraphs"}]},{"type":"text","value":" page,\nhow it is useful to consider how much time a function was at the top of the stack,\nmeaning the Node.js event loop was blocked as the CPU executes code within that\nfunction; and how this is represented by the brightness or \"heat\" of the colour\nof the exposed part of a block."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This bar shows you the heat of those exposed stack tops, of every block in the\nflamegraph, in order of heat i.e. in order of how long that block's function\nwas blocking the event loop."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can run the cursor along this bar from left to right to see where these\n\"hot\" functions are on the main flamegraph, with the same interaction as above:\nhover to see info, click to select and show tooltip, double click to expand."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The left-most (hottest) block is selected by default when a Clinic.js Flame profile\nis first opened."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-D.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"selection-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#selection-controls","ariaLabel":"selection controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Selection Controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These buttons allow you to easily jump from the currently selected block, to the\nblock that is one to the left or right of it in the hottness-ranking shown by\nthe Stack Bar."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A good place to start with a Clinic.js Flame flamegraph, is to cycle through\nusing the \"Next hottest\" button, and for each block it selects, think why that\nfunction might be spending so much time active. For example, it might be a slow\nfunction needing optimising, or it might be a function you know is fast, but\nwhen you look at what is below it in the flamegraph, you might discover\nthat it is being called too many times (for example, it might be in a nested loop)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-E.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"code-info","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-info","ariaLabel":"code info permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Code info"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This gives you more complete information about the code behind the block that is\ncurrently highlighted."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Function name (or equivalent) on the left. Anonymous functions are labelled\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"(anonymous)"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"File path (or equivalent) in the middle, including line and column number (if\napplicable)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Context. This tells you what category this block is (for example, dependency), and\nmay include additional information if certain\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/"},"children":[{"type":"text","value":"advanced controls"}]},{"type":"text","value":" are used."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/9778071079ffe9114265e1733a2ba6cc/db7be/05-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 8.363636363636363%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAIAAADXZGvcAAAACXBIWXMAAAsSAAALEgHS3X78AAAAbUlEQVQI1z3EQQ6DIBAAQL9RrcqyIKKepL0QI3hZwDatjf//S/ViMpnMu2Xb9s/3R0TeOWttTK8Q1hDPidIlprf3y/NhRmPCPCkQ2a1gjLfY9Cg7xtVBNAOgBuxqUGUtLyh7hm1R8fwOIDSX+g+kNBe52aSpQAAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Detail on flamegraph info box","title":"","src":"/static/9778071079ffe9114265e1733a2ba6cc/99f37/05-A.png","srcSet":["/static/9778071079ffe9114265e1733a2ba6cc/6b2ea/05-A.png 275w","/static/9778071079ffe9114265e1733a2ba6cc/dd45a/05-A.png 550w","/static/9778071079ffe9114265e1733a2ba6cc/99f37/05-A.png 1100w","/static/9778071079ffe9114265e1733a2ba6cc/db7be/05-A.png 1603w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"search-box","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#search-box","ariaLabel":"search box permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Search box"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If there is some particular file or function(s) you want to locate, you can type part\nof the function name, file path or equivalent here, and any matches will be highlighted,\nin the same colour used for text and outlines (white for code from the profiled\napplication, blue from a dependencies, grey from Node.js itself)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This can be useful if you've done such a good job optimizing an operation, you can\nno longer find it on the flamegraph!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/e229f0870153bec97169e482ebde3e6d/29007/05-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAAB7klEQVQoz43Qa2/aMBQGYIcQLgk3EciFQEicCyVNaaGBhQRoLrR0lKraErqu+7BRuqna//8B82CgSRtVjx5b77F0JNsgimIvnFuD8buhZzv+0A1Q2LL/sml9ZxQ6bnA9u/3w8dEPb4Bt234wnS/uwnDqOm6/P0CtH1whnj/dC8LZaDwxTdM67znnVqMhiyIE9abG12ETthXtWFKOJHgkK4YotyTYrjd1QdS2JMWQVUMQVVFSFd0QYUtW24AVNE7Q2Jq68ydzm/O9KgcZXuFqKMhFus4KrU7XAXEcIctlvIyRXd7YFvqU+/vl83q9Wn1brb5++vzojnxNNY2TAQhQheFrgmB6db2IvszuHqaLZXgTXS5iRT877gzAmwrDQZoGFA9IDmQZhGZhpzsERIZKEkSSSB2EFlnIs0qe035jlVwVVmtq58wGeIrCMBxLJA/CcJzIkBWJYjWKUcmqjNA8Gh6CBJFOJF+Fp4hskWKUHKfv5iHNa13LBRiGveHNGEGVMyUuXWCRVL5Sqgi9wRiI41Vz8iRdrA97kr3vMPwJ/RfZ+9GcPDe9F8Fwe/0h0C8eGtYtezLb407f/6tqhLQ+plsTyZrrbsRD0+ycAqZMVkrZfCZRyOJoz2Xw/168XCBrTKlSpLJUjqTIUjHH14RfV4t2eN/qGdYAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph with a search for frames that contain ","app\"\"":"","title":"","src":"/static/e229f0870153bec97169e482ebde3e6d/99f37/05-B.png","srcSet":["/static/e229f0870153bec97169e482ebde3e6d/6b2ea/05-B.png 275w","/static/e229f0870153bec97169e482ebde3e6d/dd45a/05-B.png 550w","/static/e229f0870153bec97169e482ebde3e6d/99f37/05-B.png 1100w","/static/e229f0870153bec97169e482ebde3e6d/29007/05-B.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If a function you know exists can't be found "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"anywhere"}]},{"type":"text","value":", even using search, it's possible\nit might have been inlined by V8: try searching again after turning off "},{"type":"element","tagName":"a","properties":{"href":"#advanced"},"children":[{"type":"text","value":"\"Merge\" in\nthe Options Menu"}]},{"type":"text","value":". For more on merging and inlined blocks, see the section\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/#merging-and-unmerging"},"children":[{"type":"text","value":"\"Merging and Unmerging\" in Advanced Controls"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If it is possible the function was so fast, or on the CPU for so little time, that it was\nnever on the CPU while a sample was being taken, it might appear if you create a new profile\nwith a "},{"type":"element","tagName":"a","properties":{"href":"https://www.npmjs.com/package/autocannon#usage","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"longer duration and/or more connections in Autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"options-menu","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#options-menu","ariaLabel":"options menu permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Options Menu"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clicking \"Options\" on the right side of the Info Panel opens a menu with\nmore advanced options."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"visibility-by-code-area","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#visibility-by-code-area","ariaLabel":"visibility by code area permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Visibility by code area"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These toggle buttons show (tick) or hide (untick) blocks based on where the\ncode is in the application or Node.js framework."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"[Application name]"}]},{"type":"text","value":": Code inside the main package being profiled. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Dependencies"}]},{"type":"text","value":": Code in a dependency in a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node_modules"}]},{"type":"text","value":" directory. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Node JS"}]},{"type":"text","value":": Code inside Node.js core. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"V8"}]},{"type":"text","value":": Functions inside the V8 JavaScript engine. Hidden by default, recommended for\nadvanced users only. "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/#v8"},"children":[{"type":"text","value":"More info"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"advanced","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#advanced","ariaLabel":"advanced permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Advanced"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Init"}]},{"type":"text","value":": Allows initialization functions to be shown that Flame hides by default.\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/#init"},"children":[{"type":"text","value":"More info"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Merge"}]},{"type":"text","value":": Allows different stacks to be shown for functions that V8 has optimised.\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls#merging-and-unmerging/"},"children":[{"type":"text","value":"More info"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"preferences","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#preferences","ariaLabel":"preferences permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Preferences"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Presentation mode"}]},{"type":"text","value":": Increases text sizes and colour contrasts, which can be useful\nif Clinic.js Flame is being presented under suboptimal conditions (e.g. on a projector in\na brightly lit room)."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Profiles can be set to show in Presentation Mode by default by\nsetting the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"PRESENTATION_MODE"}]},{"type":"text","value":" environment variable to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"TRUE"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/flame-docs-F.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/06-optimizing-a-hot-function/"},"children":[{"type":"text","value":"Optimizing a hot function"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/05-controls/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Controls","priority":5}}}},{"title":"06 Optimizing A Hot Function","entry":{"id":"d00d67f1-5fc1-51fc-bbfb-97cf561f75ce","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"optimizing-a-hot-function","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#optimizing-a-hot-function","ariaLabel":"optimizing a hot function permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Optimizing a hot function"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The Clinic.js Flame UI has pointed us towards the \"hottest\" functions. One clearly\nstands out: the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1-server-with-slow-function.js"}]},{"type":"text","value":", line 15."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can also see that this hot "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function is called by "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":" on line 8, column 14."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAAB7UlEQVQoz4WRa3OaQBSGFxYRQRsFlovAAiuIOhmtcTTaJl5IIs3YxLQdL82n5v//iR502k7aaTzz7OEse959YRd93z9n9+uP1+l0djebL+eLbDq/g/ow/cNhmi3Se2jIsocvX58XNyv0tP683Xx7efmx322f1qvVKttt89hsNrvD48h+v18/rm7S6adlOhkMPS+kPkOuH1tOSMMWizo+S/wwCViHBlC0HBrXveiIz1o0TOq04dGIxW3oDKM2spym5Sam0zTrTchWXsB2CbzMl6A4YNgRsSJix8QMzXpgu61u/wMaXY5Ho3Ge/2byu74cT6bTWZreLpfLq9kCvrTuxue9MXpXqZygXK5WazZlUbvb6Q6iTs/xmOM0zt9PEOJ4GG+COFwUVV/UmFD1C1Va1ALdjrr9CcIFieMwxwv/hcNCUZH1oGw2AIUwWfeJ3eiCMxblk2JcKIFYMaJcSUJZDzUQgzMviG8pj85SWSGhYsa53mAl3VetqD+8BmeJxyedpZLmKUYDPMG5pAeqxS5AzPEFGDwWjoANx+NXwKpQzP/ZSspmLBMmqX6NuIPRFaqcnYlFKT/zX0DvP2BelAVZLShazaLEZSqxehdD5PnUcR1NhyCQVVXFGPOvA27LMEgQBLZtVw1XNV3DMhzX/QnKBle/xFHKLwAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example flamegraph from node-clinic-flame-demo","title":"","src":"/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png","srcSet":["/static/60ec54d4c38a25cb8c567ccf71a6c187/6b2ea/03.png 275w","/static/60ec54d4c38a25cb8c567ccf71a6c187/dd45a/03.png 550w","/static/60ec54d4c38a25cb8c567ccf71a6c187/99f37/03.png 1100w","/static/60ec54d4c38a25cb8c567ccf71a6c187/29007/03.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look at the function starting at line 8:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"app"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"get"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'/'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"req"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" res"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  res"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"send"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"payload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The function is actually a fat arrow function, which is anonymous.\nIn the absence of a name, the Flame sampler names this function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":"\nbecause it's "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"passed"}]},{"type":"text","value":" to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":". The column number (14) makes it clear\nthat the function in question is the fat arrow function."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is the route handler for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":" which is called every time a request is made.\nIt's calling the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function (our bottleneck) and then passing it to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"res.send"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look at line 16:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"payload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since there's a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" statement there must be an outer function. Let's take a look\nat the whole thing, including the outer function which creates the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"initPayload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"idSize "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"20"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"payload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"let"}]},{"type":"text","value":" chars "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"let"}]},{"type":"text","value":" n "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" idSize\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" date "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" Date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"now"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" radix "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"36"}]},{"type":"text","value":"\n    n "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*="}]},{"type":"text","value":" n "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"*"}]},{"type":"text","value":" idSize\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"--"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" num "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" date "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" n\n      chars "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+="}]},{"type":"text","value":" num"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"toString"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"radix"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"toUpperCase"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" id "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" chars"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"slice"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"-"}]},{"type":"text","value":"idSize"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" id "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"initPayload"}]},{"type":"text","value":" scope there is a parameter, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":" with a default value of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"20"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function is returning an object with a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"date"}]},{"type":"text","value":" field and an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":"\nfield. The date is created with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Date.now()"}]},{"type":"text","value":" so it doesn't look like we can optimize\nmuch there. Let's focus on how the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":" is created."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The variable "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"n"}]},{"type":"text","value":" is set to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":", but then later multiplied by itself times\nthe "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":", which is essentially n³. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"n"}]},{"type":"text","value":" variable is then\ndecreased by one per each iteration of a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" loop. The body of the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"while"}]},{"type":"text","value":" loop\nis adding the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"date"}]},{"type":"text","value":" timestamp and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"n"}]},{"type":"text","value":" together and then calling "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"toString(36)"}]},{"type":"text","value":"\n(the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"radix"}]},{"type":"text","value":" constant is "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"36"}]},{"type":"text","value":") which will convert the number to an alphanumeric string (base36).\nThis base36 string is then upper cased and added to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"chars"}]},{"type":"text","value":" string. Finally the\na slice with a length corresponding to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":" is taken from the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"chars"}]},{"type":"text","value":" string\nto form the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"What an odd and over-engineered way to create an ID. Surely no\none would really write code like that? "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"(Narrator: \"They do.\")"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's improve the algorithm, but keep the same fundamental qualities of the id:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"It must be an alphanumeric string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"It must be configurable by "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"It will never be less than 6 characters long"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A more optimal version of the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"initPayload"}]},{"type":"text","value":" function looks like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"initPayload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"idSize "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"20"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"if"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"idSize "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"6"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"throw"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"Error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'idSize must be greater than 5'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" max "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"2147483647"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"var"}]},{"type":"text","value":" count "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"payload"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    count "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"count "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"%"}]},{"type":"text","value":" max\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" date "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" Date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"now"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" chars "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" count"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"toString"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"36"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"toUpperCase"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" id "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'0'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"repeat"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"idSize "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"-"}]},{"type":"text","value":" chars"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" chars\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" id "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"max"}]},{"type":"text","value":" number is the largest 32bit integer (2³¹ - 1) we use this\nto cycle count back round to 0 when it reaches 2³¹. This isn't strictly\nnecessary for speed in our case, but Node's JavaScript engine (V8) is\noptimized for the numbers in 32bit range (since most numbers in practice\ntend to be). Additionally, when converted to base36 is (2³¹ - 1) 6 characters,\nwhich means we don't have use a minimum length offset to enforce "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each time the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function is called, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"count"}]},{"type":"text","value":" is increase by one.\nWe turn "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"count"}]},{"type":"text","value":" into a base36 string, and upper case it. Then we pad\nthe beginning of the string with the necessary amount of zeros (which is valid base36)\nto create an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":" with a length corresponding to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"idSize"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"testing-the-optimized-function","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#testing-the-optimized-function","ariaLabel":"testing the optimized function permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Testing the optimized function"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The optimal "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function is in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"2-server-with-optimized-function.js"}]},{"type":"text","value":". Let's\nprofile this server with Flame to assess the result:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"2"}]},{"type":"text","value":"-server-with-optimized-function.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This should generate something like the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/de4a5813f3c6b55a8713462e117d7a7c/29007/06-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACPklEQVQoz22Ra2/aMBSGTQINLYQUSOxc7DixcyFAQ2GE3Ci0Rd3WtZOq7cu6//9D5tB26qYePfKxrPO+PvYBz7+eD3cPn7I6L/ZFdV1W+7yo81xQNWzeyKpisy2LqyLffr57/PHz983hATw9ff96/+X+2+Ph9lDXZbZe3FzlN7v8eptd1+tdvtpvVvtsud98yqbRhJgpp5vFpecyl3LgscRymB/Mwjjl0cwPpjxKPT73gjllM+xN/mK7IbR94sc8nrssYkECHHeCaSIQG8eNBTaJHCLWhubkZXVjfKwUZeLcwnG6rAByImSHphMiOzKdWGC7iUlExeSd3SsWjoT1y2a+KEBZVUVZb3e3ZVXn62m+jNaBOeeU0KixwxMfY5dwu7H7x+XisgC9/qmqnQ/HcAgddYQ0SIbIMzGdpRerTTlPL5FNTWRj+pG4dQwAQEsSIcsnpwNIDfFOlhCexFFEPaaNbdHCB2K50xUSWW5LDSJ3lN5QNejAClTEe4avjKgBrWkU/idOlyVoK32pJUtS+w256USSuxrqQd5HQR9yFfo8YOIXXkfQiMNVtgPySVcI3ombFoS6c6r1IGsw2JnuK+fYcgIxhUZJJmJGy+wKtNrK8ab2O4SX1D456xmeasZ9FKooOIOcYC9mAbRjThkhYbregYGmKd2ukL/S/NrRQuSOovRH3YEhUFRjDK2Uo0XCY44Dx8w2NXApxY6j67ph6PpYH41Gx4uP0QKNn9TMAiEYhAHxmOu5hu3YlsEo/gOQrmF/TYf56AAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph from node-clinic-demo/2-server-with-optimized-function.js","title":"","src":"/static/de4a5813f3c6b55a8713462e117d7a7c/99f37/06-A.png","srcSet":["/static/de4a5813f3c6b55a8713462e117d7a7c/6b2ea/06-A.png 275w","/static/de4a5813f3c6b55a8713462e117d7a7c/dd45a/06-A.png 550w","/static/de4a5813f3c6b55a8713462e117d7a7c/99f37/06-A.png 1100w","/static/de4a5813f3c6b55a8713462e117d7a7c/29007/06-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This immediately looks healthier - it's no longer dominated by just one function,\nand as a result we have a range of shades of yellow and orange."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function is nowhere to be seen. This is because the function\nwas inlined into its parent: the anonymous lamda function labelled as "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":".\nThere is more information on inlining and merging on the\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/#merging-and-unmerging"},"children":[{"type":"text","value":"Advanced Controls page"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" we can show that our optimization has lead to our server\nbeing over 50 times faster (220 req/s vs 11640 req/s)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/a140f7ccf8fcc653b51daefab7c9b17e/49ee2/06-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 76.72727272727272%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsSAAALEgHS3X78AAABrUlEQVQoz4WSXU/CMBSG221lo1s7V9yGYQUVRyJggv4JLrkDJzIn90gA+f++mx/hQrInzWl7es5p+7Zkv9/vdrvD4fBZgcHxeMQA/u12u9lsPs6AJTKZTMbj8Wg0gn1AO2E4HA4Gg7szpGlKirdiuVyuKl5XqzzPVz+8AnQv/7GsIPP5PMsyxMG+5TnC1+s1bFEU6/d3rC4Wi+cS9AvEZM8ZnLPZbDqdksCXLaUCpXizSQkxDAPWMkua8FDMzmN4wrQsxiyTc6RSx6FCUNv+TqLGD/SEX59B+vf3vetrpVTUSeTFhVStSOu402kwRmqB0IM0tW1bCqECXEJ6nGMAT32yECIMQ+zsCXFZgWlQJTNcxrIav8DzbcsBY6ZpkNvbG+yMZ9O6mySJTnSv1+t2u1rru34fpTnnrut6ritQXsB4AB6UJlwI1/OwbjtOJREtG8SotKk5tnd15SIfhBGOaEvZbLVs3+e+fxr2V4aeFn16fMLfxEniGBp3ojBsxzEkaLfbuHDNznGM4AjJjuMEgcIJfN8vLyclq30t/G+ogBwoyVgpJj5WOWWN2pf6Au41Y2GgsOreAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Output from autocannon before and after optimizing payload","title":"","src":"/static/a140f7ccf8fcc653b51daefab7c9b17e/99f37/06-B.png","srcSet":["/static/a140f7ccf8fcc653b51daefab7c9b17e/6b2ea/06-B.png 275w","/static/a140f7ccf8fcc653b51daefab7c9b17e/dd45a/06-B.png 550w","/static/a140f7ccf8fcc653b51daefab7c9b17e/99f37/06-B.png 1100w","/static/a140f7ccf8fcc653b51daefab7c9b17e/49ee2/06-B.png 1618w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/07-reducing-the-graph-size/"},"children":[{"type":"text","value":"Reducing the graph size"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/06-optimizing-a-hot-function/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Optimizing a hot function","priority":6}}}},{"title":"07 Reducing The Graph Size","entry":{"id":"16db4b22-589f-56d3-af65-dd91aa48c712","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"reducing-the-graph-size","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#reducing-the-graph-size","ariaLabel":"reducing the graph size permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Reducing the graph size"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"While Flamegraph's highlight bottlenecks primarily through visualizing\nthe top-of-stack metric, they can also be used to understand application\ncomplexity."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If a flamegraph has a lot of high rising stacks, this can\nalso be thought of as a distributed bottleneck. If we can find ways\nto reduce the graph size, perhaps by removing unnecessary layers,\nthis can also improve application performance."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One potentially low hanging fruit can be replacing libraries with\nsimpler or smarter alternatives that create and call less functions\nin the hottest paths."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look at the flamegraph we already generated for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"2-server-with-optimized-function.js"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/de4a5813f3c6b55a8713462e117d7a7c/29007/06-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACPklEQVQoz22Ra2/aMBSGTQINLYQUSOxc7DixcyFAQ2GE3Ci0Rd3WtZOq7cu6//9D5tB26qYePfKxrPO+PvYBz7+eD3cPn7I6L/ZFdV1W+7yo81xQNWzeyKpisy2LqyLffr57/PHz983hATw9ff96/+X+2+Ph9lDXZbZe3FzlN7v8eptd1+tdvtpvVvtsud98yqbRhJgpp5vFpecyl3LgscRymB/Mwjjl0cwPpjxKPT73gjllM+xN/mK7IbR94sc8nrssYkECHHeCaSIQG8eNBTaJHCLWhubkZXVjfKwUZeLcwnG6rAByImSHphMiOzKdWGC7iUlExeSd3SsWjoT1y2a+KEBZVUVZb3e3ZVXn62m+jNaBOeeU0KixwxMfY5dwu7H7x+XisgC9/qmqnQ/HcAgddYQ0SIbIMzGdpRerTTlPL5FNTWRj+pG4dQwAQEsSIcsnpwNIDfFOlhCexFFEPaaNbdHCB2K50xUSWW5LDSJ3lN5QNejAClTEe4avjKgBrWkU/idOlyVoK32pJUtS+w256USSuxrqQd5HQR9yFfo8YOIXXkfQiMNVtgPySVcI3ombFoS6c6r1IGsw2JnuK+fYcgIxhUZJJmJGy+wKtNrK8ab2O4SX1D456xmeasZ9FKooOIOcYC9mAbRjThkhYbregYGmKd2ukL/S/NrRQuSOovRH3YEhUFRjDK2Uo0XCY44Dx8w2NXApxY6j67ph6PpYH41Gx4uP0QKNn9TMAiEYhAHxmOu5hu3YlsEo/gOQrmF/TYf56AAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph from node-clinic-demo/2-server-with-optimized-function.js","title":"","src":"/static/de4a5813f3c6b55a8713462e117d7a7c/99f37/06-A.png","srcSet":["/static/de4a5813f3c6b55a8713462e117d7a7c/6b2ea/06-A.png 275w","/static/de4a5813f3c6b55a8713462e117d7a7c/dd45a/06-A.png 550w","/static/de4a5813f3c6b55a8713462e117d7a7c/99f37/06-A.png 1100w","/static/de4a5813f3c6b55a8713462e117d7a7c/29007/06-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"3-server-with-reduced-call-graph.js"}]},{"type":"text","value":" we change the web framework\nfrom Express to "},{"type":"element","tagName":"a","properties":{"href":"https://www.fastify.io/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Fastify"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's generate a flamegraph for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"3-server-with-reduced-call-graph.js"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"3"}]},{"type":"text","value":"-server-with-reduced-call-graph.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look at the resulting flamegraph:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/d81062495d5e738b07588125894b8263/29007/07-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAABuUlEQVQoz8WSXW/TMBSGTRkMtg6FZM3XsR0ncRw3Tb/i5qNd2zGmISHQJMouGJf9/z8Cp+0mBgiJK44eWe/FeXysI6P7b/cfPt5erN4v19dNs5zPV3W1OFAeqGYtdbVsqnVVrm5uPm++fr+6/oQ2X27v7jbb7VaHRZmpIX9XT68adVkVl7NirYqVKpaFRk2FiD1P0GCcjQIaURqjKMldiGgo4yQPeU5YyvggiDPMJA4PkB0+TVwIPRIRJghLIp4hn6Q46Gt00ACVD+EnSAumct+57xlNF+gX5+94WGh2IcnH9b/Jj7hY5JPmP8pag90m9mG/G3jSKv4oDydzZHuJ7XF99ty453KfSAdLG6SL27cAEYCjp3e1VzsgpuUaTcZqXNSqXKjyQqlqQLEMo4zzhDIX2t3atm+DcLB8mJl6egAkrYxpAODwJJb5MJGZZZ4zgHKUMgyziZgOI8O005Bzxl3Sjynvs5CQtIflRMtdw+x0nqPH6rxAR6/Ry7OjU/NV1zg+OTs+eRPjXkZ7pYAhx9Q1B9gW4CpVI0ywj8GyznVZlvXWMDrP0O/l6F8tOKX01IKu6Zim4YH/AzNmcJVKdwFbAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph from node-clinic-flame-demo/3-server-with-reduced-call-graph.js","title":"","src":"/static/d81062495d5e738b07588125894b8263/99f37/07-A.png","srcSet":["/static/d81062495d5e738b07588125894b8263/6b2ea/07-A.png 275w","/static/d81062495d5e738b07588125894b8263/dd45a/07-A.png 550w","/static/d81062495d5e738b07588125894b8263/99f37/07-A.png 1100w","/static/d81062495d5e738b07588125894b8263/29007/07-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is clearly simpler, and there's much less blue meaning less activity in dependencies.\nThere's a tall blue column on the right, but it's very thin: therefore there is complexity\nthere, but it is fast. There are, however, some hot frames under "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleRequest"}]},{"type":"text","value":", so\nthere may still be more we can do."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"First, however, we must confirm that performance really has improved. Reducing\nfunction calls and complexity doesn't always result in a faster application. We can\nmeasure the difference between "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"2-server-with-optimized-function.js"}]},{"type":"text","value":" and\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"3-server-with-reduced-call-graph.js"}]},{"type":"text","value":" using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/ebc8088576d457c97993adb80c628050/07108/07-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 76.72727272727272%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsSAAALEgHS3X78AAABsUlEQVQoz4WRbY+aQBDHF3laYNdFXB5O2bPWNKkP9bg3vQ9SGj1EsHhGP4FNox++w9JL7g3lx2Qyk50Zdv6L/khut9v9fm/8vYllCke/W7her+g5SVar1XK5XL2zXq+/vTOfz7+0g3a73WazyV5fM/gkWZZtt9smgKM0TX+2gPJ9XpZF9asqiuLt7Vgdj5fLpaqq0+l0Pp/zPC/2+0JSluXhcCglxb5I0x+IOsRlrN/vm4ahINTr9cCrvRpsWYoCWTuq42i6bhiGZtsIag0DmSYCr6pIzmpHRZ++zmMhPM/zY2ETwrjPgpBy7gUh6uT56WmxWJgYD1w3jmPf56MogkVGDw8wvKPZdV34bRiGhJDBwOszFgTBkHOXubqua5pmfMA0TbliHdSjJ5PJVDIajcdg4/EjIMDE5+mUUupICBghoKtj21QGMBc5tIYQijGGiygwD2QDzWvXdW2T+zrGFsY256puaISolIKZhHwsgxdTJP/SJvj+8pIkCWNMiEdYARYOwpBzLoRQ5Wv9jyiKGrUsywKdYJnh0INZICQI1tE8m80aSUBDqNalkrbtdHci9Bd1eWax6s2iCQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Output from autocannon before and after switching to Fastify","title":"","src":"/static/ebc8088576d457c97993adb80c628050/99f37/07-B.png","srcSet":["/static/ebc8088576d457c97993adb80c628050/6b2ea/07-B.png 275w","/static/ebc8088576d457c97993adb80c628050/dd45a/07-B.png 550w","/static/ebc8088576d457c97993adb80c628050/99f37/07-B.png 1100w","/static/ebc8088576d457c97993adb80c628050/07108/07-B.png 1619w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's a huge improvement. By swapping to a framework that focuses on\nreducing the function graph complexity, performance has significantly improved.\nIn fact, we can now serve close to double the amount of requests."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/08-advanced-analysis/"},"children":[{"type":"text","value":"Advanced analysis"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/07-reducing-the-graph-size/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Reducing the graph size","priority":7}}}},{"title":"08 Advanced Analysis","entry":{"id":"c0f13c95-4fea-5223-b069-0acd2f9a94c5","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"advanced-analysis","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#advanced-analysis","ariaLabel":"advanced analysis permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Advanced analysis"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We still have some hot blocks in our latest flamegraph:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/d81062495d5e738b07588125894b8263/29007/07-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAABuUlEQVQoz8WSXW/TMBSGTRkMtg6FZM3XsR0ncRw3Tb/i5qNd2zGmISHQJMouGJf9/z8Cp+0mBgiJK44eWe/FeXysI6P7b/cfPt5erN4v19dNs5zPV3W1OFAeqGYtdbVsqnVVrm5uPm++fr+6/oQ2X27v7jbb7VaHRZmpIX9XT68adVkVl7NirYqVKpaFRk2FiD1P0GCcjQIaURqjKMldiGgo4yQPeU5YyvggiDPMJA4PkB0+TVwIPRIRJghLIp4hn6Q46Gt00ACVD+EnSAumct+57xlNF+gX5+94WGh2IcnH9b/Jj7hY5JPmP8pag90m9mG/G3jSKv4oDydzZHuJ7XF99ty453KfSAdLG6SL27cAEYCjp3e1VzsgpuUaTcZqXNSqXKjyQqlqQLEMo4zzhDIX2t3atm+DcLB8mJl6egAkrYxpAODwJJb5MJGZZZ4zgHKUMgyziZgOI8O005Bzxl3Sjynvs5CQtIflRMtdw+x0nqPH6rxAR6/Ry7OjU/NV1zg+OTs+eRPjXkZ7pYAhx9Q1B9gW4CpVI0ywj8GyznVZlvXWMDrP0O/l6F8tOKX01IKu6Zim4YH/AzNmcJVKdwFbAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph from node-clinic-flame-demo/3-server-with-reduced-call-graph.js","title":"","src":"/static/d81062495d5e738b07588125894b8263/99f37/07-A.png","srcSet":["/static/d81062495d5e738b07588125894b8263/6b2ea/07-A.png 275w","/static/d81062495d5e738b07588125894b8263/dd45a/07-A.png 550w","/static/d81062495d5e738b07588125894b8263/99f37/07-A.png 1100w","/static/d81062495d5e738b07588125894b8263/29007/07-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"None of the hottest blocks refer to any of our code,\nbut let's take a minute to think through what's happening."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The hottest is "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clearBuffer"}]},{"type":"text","value":" in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"_stream_writable.js"}]},{"type":"text","value":".\nThis is part of Node core. Since the goal here isn't to begin\noptimizing Node core, let's look at the next hottest block:\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleRequest"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can expand the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleRequest"}]},{"type":"text","value":" block to look\nsomething like the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/c387182660b3c2dd9e81143b5f5554ef/29007/08-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 61.45454545454545%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsSAAALEgHS3X78AAABXUlEQVQoz8WRbU/CMBCAy2AbrBsMg2vXt22d7RU2QIhKxP//v+xQE9DoVy/PNe3lnkvaoqbdNA+dUEZWVtVO1VA1rtZrWTtRg6hAKCuqL5SVNajG+dWu96gU4GHSXYBruHL8c++u4QoIM932BX0TbuXf6o5ws+mf/1H2t+K/y/xvuRCOCKDc/KQUlkpHLw85DFJQyoFBZg/d7oSeoOrbVptde4uvgO38v2mp/XcUzBXcKWm4tITDirab/SvSWtPi3oFZO/hkDfvH3eF42O4fNWMVoZ3W5x2c+kYzYhq97XsH9nx+Q3dlneWrMIzGk/CDySQKwxjj7L4oCZOzLJ9n6SrPVsvMdxaEWiPbhp1OR5RleL6YpymOLhFH3gwRQn5G6qs4CUYjfxwFQRxP4zgOxtE4SuJpQhhHSYIXQ+TL5TLPc58Y46F75PsDn+gi+4mEEEppOs8ns0WC8XQ2fQdYcU6ocl86bAAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph expanding Fastify's handleRequest function","title":"","src":"/static/c387182660b3c2dd9e81143b5f5554ef/99f37/08-A.png","srcSet":["/static/c387182660b3c2dd9e81143b5f5554ef/6b2ea/08-A.png 275w","/static/c387182660b3c2dd9e81143b5f5554ef/dd45a/08-A.png 550w","/static/c387182660b3c2dd9e81143b5f5554ef/99f37/08-A.png 1100w","/static/c387182660b3c2dd9e81143b5f5554ef/29007/08-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Looking at the three hottest functions in this sub-view:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Node.js's "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clearBuffer"}]},{"type":"text","value":" is first and accounts for most of the time spent\ninside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onSendEnd"}]},{"type":"text","value":". As discussed, optimizing that will probably be difficult."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Second hottest is the Fastify function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleRequest"}]},{"type":"text","value":", which has many children\nso is clearly quite complex."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Third is in our own "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" function - but we've already optimized that."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, why are we spending a long time inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleRequest"}]},{"type":"text","value":"? If we click copy path\nto look at the Fastify code, there's nothing obviously wrong, and we know\nFastify is quite well optimized for performance."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Maybe something is missing? Let's open the Options menu and tick the\nunticked \"V8\" button, showing operations inside the V8 JavaScript\nengine that are normally hidden:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/86862789c949579d6b975ee4a5642c54/29007/08-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACDElEQVQoz5WRa3OTQBSGF4QESIBw34VlgWBg00Au3JJok2qdjtXq6DQf/f//wyVpqx+cUd95Zudwds8c3nPA4+Pp+P6+bq+73c12/26/PbTNvq6eqNhZv6nO1PXbprlm3N19OZ1+3H54AMfj8fPD12/fTx/vPx0Ph66kh6beVx1jV227dbcpqnVPPZ9dxTiakmkxL2Mcx1EKMrq8KqrlqitXbUbLjK4Wq5YuqsWyKfpgE8YZSXKS0CCMcIiRH0iyAjheGakA4QwGswt+mDNePhnoOYnJ3LSgjYiL8HA4BABomgbYRUAYlJ2Xd+f4F5ekTyjyiYeQZdlMjutAiMDT3d8IyNx1/YmmDQYDSZJUTXUc91+L/bDvzNpKzLGiyLJiGOZ/dDZMR1XV8Xg8Go0lWTbMvjg7c3H+4v83t8+eIcSObYuiyHHgPDAd4JDi/h2FQeadcdHMRa8ZCPdliM0f54jMHRj7YYrwVDehqrvpbAEy345cL40StuSirBbFZrlu1ptutWlzEkUQJmGSktk0nKZxHgdxEoRJGEV+1OxuwUBSeJ4bDgemoXuu5dim73sYI5LEpovksaHrpm87SQBpnqcz6ngsqbNkW3VAUXVBEMGfxXH8K8DgeBYCXuAFWRjIimbI6oQuSgARZDJN6yK2AL4Xp4wUtkxRFM7TAWxUhBDP84aqNZo4FvvBIPgJt25g2gxZFbkAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph showing V8 functions in Fastify's handleRequest","title":"","src":"/static/86862789c949579d6b975ee4a5642c54/99f37/08-B.png","srcSet":["/static/86862789c949579d6b975ee4a5642c54/6b2ea/08-B.png 275w","/static/86862789c949579d6b975ee4a5642c54/dd45a/08-B.png 550w","/static/86862789c949579d6b975ee4a5642c54/99f37/08-B.png 1100w","/static/86862789c949579d6b975ee4a5642c54/29007/08-B.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The gap almost completely disappears, and a new block appears (selected in the\nabove screenshot), starting "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"T v8::internal::Builtin_JsonStringify"}]},{"type":"text","value":". This means\nit refers to a C++ function inside V8, named "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Builtin_JsonStringify"}]},{"type":"text","value":". Clearly,\nthis is related to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.stringify()"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It's worth knowing that the JavaScript wrappers "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.stringify()"}]},{"type":"text","value":" and\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.parse()"}]},{"type":"text","value":" that we are familiar with are not sampled directly by V8, which\ninstead skips straight to the underlying C++ implementation."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Expand that, and we see V8 needs to do many, many steps when trying to\nstringify some JSON."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/3ba323f173ed19f21f7ed89568f36154/29007/08-C.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAABvklEQVQoz8WPWW+bUBCFL1CSJrbDVuy7sxgDXmIWg/dYVZ23VM1D3vL/f0gHkJ206nuvPo3OzJkzAvT68ut4OOfZelXuq+oAlOUOKIqGVu87VtWxrp+q6un5+efb2/uP8wsqp7NTvT0fvx/Kahmns3G8KTdVVtf5us5BrPN5CRSLVRzGZIg95mXzLJC+741RMi/mWZ2tdstym8zyZJ4vi026KBdZ/ZivQYggkWEKcG9CWMBkFExmMoyDaIoIjzGbjGiEaQS6axs4rDaaiqSDSchPuZc2LU+WxR6108aAel26rH4MO7rrnVhkW/TZ+4vuyj+B8GP+P8MMli5cvLij/eH4E3+El8UOYZFi3iJSItoqp7SFeTMqoU3pB52VEp4U9QlFcjzxIqiRjEIxDngoiS+IL2kgqM9BN+JKM+E0oMSvNicUUBwyHAkaMuJT7FFMXIcN3aFl8tHQNQyr3+9wDNMxbduwXMfFhJXVBt0/GOqNjq5PUZCmKYCq3d7dqV90pCpI1cBAioa0G1W/7ZtWz7DSRYYYo4RS27Ydx4FqmZYCD6Fe777/MNB1HUJw03VdT0o8Gn0dfBvY8GEuE+I3B21ojcvvqgwAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph expanded on V8's Builtin_JsonStringify","title":"","src":"/static/3ba323f173ed19f21f7ed89568f36154/99f37/08-C.png","srcSet":["/static/3ba323f173ed19f21f7ed89568f36154/6b2ea/08-C.png 275w","/static/3ba323f173ed19f21f7ed89568f36154/dd45a/08-C.png 550w","/static/3ba323f173ed19f21f7ed89568f36154/99f37/08-C.png 1100w","/static/3ba323f173ed19f21f7ed89568f36154/29007/08-C.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is a case where instead of focussing on one \"hot\" function, we need to focus\non an inefficient parent function that is calling many micro-tasks. Each one looks\npretty fast - the problem is, they add up to a lot of time."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Why is JSON stringification happening here? It's because we send an object, and both\nExpress and Fastify will automatically serialize an object passed to their "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"send"}]},{"type":"text","value":" method."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This bottleneck becomes a lot clearer when we turn off inlining."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's run the following command:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":" clinic flame --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" --no-turbo-inlining "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"3"}]},{"type":"text","value":"-server-with-reduced-call-graph.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will produce a flamegraph similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/b7fcc18a00ca422e08241f7ee7aec38c/4c7dc/08-D.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACIUlEQVQoz4WRWW/aQBCAba8dsIFwGa+9l+9dm2AuswRIaKuQPvR4SvNUqf//b3QNaapWUTv6NJqV5hvNarSnp+cPp0+H/f6wv7vd3u2293JzeKFu2PxCbu6323dSHj8+fn369v3h9EXb7fcPD6cfz4+fT3K3LNciO9b1sZaHZX232uwW6+18LRWLeppxCoOUxav5KmIJY4kWJQWiGU2qTCxSUcX5TV4uUzGPspuEz8K0pHHBzuAwh1hZIisqFvM4KzWIckR4zNKACkQFpiIgvClYcXn+hhUkLFUOmh4xXx00Pl3mfFYlVLAIU34Z8Sr/xXkuPxf5bHGrrddVOVUOjgI3xCFlBWMcs7flV3zCq+VOsx3Hsqzrfp/GYYwRgwENyEVW+T9yp+M4ju1Bz0coCDx30MeTcUwTn5YQq6Z/ylarqxu6boB2bzzw436QdlzColguhZwlU5G/6b/IV/Y1ABYAJgBAzWj3JjCc4nTGsmlxU4ksI1gdovjTFB7KV/KotfvQMC0DgAtWu9MZ4d4k7sHM8fLOiBIUJSw7H6JgJKFU7cIhTuvte601QLphGuAFtb/CHpGuL7o+t73U9ShxxwyxPEx9L4gQVgfzfCblvdbrdVutlt78uwlDqcC0ruyGlt3tD10IPTiJkJcGY0YwdIcEIdvp1rXUWBRigseuionKo9FIrW/omq5rRoNumsA0TRqGeVFkaTKAbOgFY3eIKfkJKwBkUaseLGQAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph of Fastify demo without inlining","title":"","src":"/static/b7fcc18a00ca422e08241f7ee7aec38c/99f37/08-D.png","srcSet":["/static/b7fcc18a00ca422e08241f7ee7aec38c/6b2ea/08-D.png 275w","/static/b7fcc18a00ca422e08241f7ee7aec38c/dd45a/08-D.png 550w","/static/b7fcc18a00ca422e08241f7ee7aec38c/99f37/08-D.png 1100w","/static/b7fcc18a00ca422e08241f7ee7aec38c/4c7dc/08-D.png 1599w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We have a new second-hottest function (after the Node core one) - "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"serialize"}]},{"type":"text","value":".\nThis was previously hidden due to being inlined by V8."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With none of the functions inlining, it becomes a lot more apparent that\nthe "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"serialize"}]},{"type":"text","value":" function is a bottleneck. Whereas "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"with"}]},{"type":"text","value":" inlining the hot\nblocks were seen more on the top of the stack "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"because"}]},{"type":"text","value":" they represent\nseveral other functions that have also been inlined into them."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"4-server-with-manual-serialization.js"}]},{"type":"text","value":" alters the line 23 in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":"\nfunction from "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"return {date, id}"}]},{"type":"text","value":" to:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","template-string"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"{\"date\": "}]},{"type":"element","tagName":"span","properties":{"className":["token","interpolation"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"${"}]},{"type":"text","value":"date"},{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":", \"id\": \""}]},{"type":"element","tagName":"span","properties":{"className":["token","interpolation"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"${"}]},{"type":"text","value":"id"},{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It should be noted here that this technique may be inappropriate in many cases,\nfor instance where escaping inputs is crucial to security. An alternative to\nmanual serialization which is still faster than using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.stringify"}]},{"type":"text","value":" is\nschema-based serialization using "},{"type":"element","tagName":"a","properties":{"href":"http://npm.im/fast-json-stringify","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"fast-json-stringify"}]},{"type":"text","value":". The Fastify web framework also supports schema-based serialization by default,\nsee "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md#serialization","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Fastify's Serialization\nDocumentation"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's run Clinic.js Flame to create a flamegraph for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"4-server-with-manual-serialization.js"}]},{"type":"text","value":":"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic flame --on-port "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'autocannon localhost:$PORT'"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"4"}]},{"type":"text","value":"-server-with-manual-serialization.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This should give something like:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/caff578ccade06aca99efed3c1a45dff/29007/08-E.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAAByklEQVQoz52Ra2/aMBhGHVppqFo3SkJuviSOLwmBhCSQBEKhVFU7TZsqre2H0X1Y//+vmBegqzRt1WYd2Zb1nNc3sP26/fDxdnl+ebG5WS4383o5r5q6PDBrqpZS9eV5Xa2rcnV9/fnL/ePl1Sdwf3f78HD39PT98dv2alUVkbepi001XRfFqmWZF01WLLJpKiS1HYa9NE4JpoQwEPCR7VKPRpTHPhtiP/TZyAti5Ic7MN0DCbchdVBAqMA+D/gQuDhE3hCS6Bm1ooC/gUikkruwCqR5A/bRg/N3HCQV7USMJ/W/yc/YSCbZ/D9lC8rxa7J8RYat+fLNfoWQ+KOMwiRbANMVpsMtVwxs9hOHOzhy1JOoHrHd5vCFBg9yUV2AJB7FyWyUzJKsSvMqSXKJCMbSx9yxMYbExpGFot1vqYoWjtpji6JcA0IDxqgQbDzJ8roZF5Wpm9OQ5dK3BrZ+ZggvCIgwUeRCKZHHPHWXoe7KbLYGb3t9TdPAvmlAOz4+6XXfm913RvdUf3NqUGingZtxEnMaeFBYZyFGruXOygZgjBBGA8MwBwND1/v9XqejarRoWkfVVcPREfPcxYT7lJ4Y0NR1aPYwgj8AI6dxabfPYKsAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph of Fastify demo with manual inlining","title":"","src":"/static/caff578ccade06aca99efed3c1a45dff/99f37/08-E.png","srcSet":["/static/caff578ccade06aca99efed3c1a45dff/6b2ea/08-E.png 275w","/static/caff578ccade06aca99efed3c1a45dff/dd45a/08-E.png 550w","/static/caff578ccade06aca99efed3c1a45dff/99f37/08-E.png 1100w","/static/caff578ccade06aca99efed3c1a45dff/29007/08-E.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We can see the the hottest block is a Node core function, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Socket._writeGeneric"}]},{"type":"text","value":",\nwhich is called by "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clearBuffer"}]},{"type":"text","value":". It's same Node core bottleneck as before, it's just that\nin this sampling period the V8 engine "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"didn't"}]},{"type":"text","value":" inline "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Socket._writeGeneric"}]},{"type":"text","value":" into\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clearBuffer"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" to determine the effect this has had on server performance:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/c12e04a80202e977607f373c110ff2d6/0d292/08-F.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 76.72727272727272%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsSAAALEgHS3X78AAABtUlEQVQoz4WS227iMBCGnYMPJE5ichSFpBSx0nJY2lxt3wMQlEICEQiegFIB776TpHR7sd18lv7xOHY8+sfoveB8Pl8ul3PB9XotJ7ByOp2Ox+Pbv4B1FD/Fw+FwMBgMP/g1Go3ykMdRr9f78T1o+fo6m80WLy8LGKCLXEvm8zmkU2AymU7LOPlUAK1WqyRNsk2WJOl2u82y7HA4gO52u/1+v1wukxtpmm7WG9ifJul6vR6Px8jQubAs0zQpIRJCsiSBKrIsKwpjrMi+R+FcxZhSomoakmWJUokyRGn5Vf4fCmr/7LXC0Lbt4P7esCzhB6bv+2FICEGVPD0+9vt9Sqlj21EYBp7vOQ4o/K76sOO6+bVBoHPuum7dtj3fzyeijjFWVZXcgAvIF1QVym63Hwru7polURSFUEMYdTodbnBd0wGu66YBCYwPwE6k3RIKCUKSnPsNinKRK8pmnk8Y02o1zfMUQjA3sBDYtIjOv26Djn227W//fj8/x3EshCirbjQazVbTdb1WK1QVpeJm2A1uQdk1xhzHtoQF/llWrmBYxeFut6sXgJc4fy2UUaZpOvhc2ak/xgFm/AfvEZQAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Output from autocannon before and after using manual serialization","title":"","src":"/static/c12e04a80202e977607f373c110ff2d6/99f37/08-F.png","srcSet":["/static/c12e04a80202e977607f373c110ff2d6/6b2ea/08-F.png 275w","/static/c12e04a80202e977607f373c110ff2d6/dd45a/08-F.png 550w","/static/c12e04a80202e977607f373c110ff2d6/99f37/08-F.png 1100w","/static/c12e04a80202e977607f373c110ff2d6/0d292/08-F.png 1620w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We've achieved roughly another 10% improvement."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"At this point further optimization of the application becomes increasingly challenging,\nsince functions in Node core have become the primary bottleneck. A few more percent could\nbe squeezed out here and there, especially if we were willing to change the constraints\nof the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":" field."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"However, for the most part, our work here is done."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"The walkthrough is complete."}]},{"type":"text","value":" Congratulations! You should now be able to use\nClinic.js Flame to solve common performance problems."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You may also choose to continue to read about Flame's\nmore "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/09-advanced-controls/"},"children":[{"type":"text","value":"advanced controls"}]},{"type":"text","value":"."}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/08-advanced-analysis/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Advanced analysis","priority":8}}}},{"title":"09 Advanced Controls","entry":{"id":"7d33863d-9a4a-5b08-9103-0d281c0aa176","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"advanced-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#advanced-controls","ariaLabel":"advanced controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Advanced controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This section provides further reference information on some of Clinic.js Flame's advanced features."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"init","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#init","ariaLabel":"init permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Init"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clinic.js Flame by default hides various initializaton functions. Filtering out these frames\nreduces generally redundant initialization noise."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"They include:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Internal module system functions which are repeated frequently as the dependency tree\nis loaded (such as "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"require()"}]},{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Functions relating to Clinic.js Flame's own data capture"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Other initialization functions"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"An option in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls/#advanced"},"children":[{"type":"text","value":"\"Advanced\" section of the Options Menu"}]},{"type":"text","value":"\nallows these to be shown."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When shown, Init blocks are presented like all other blocks, and will be shown or hidden\naccording to the options selected in \"Visibility by code area\". The only differences is\nthat when shown in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls/#info-panel"},"children":[{"type":"text","value":"Info Panel"}]},{"type":"text","value":", the\ncontext section on the right states "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"\"In initialization process\""}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"merging-and-unmerging","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#merging-and-unmerging","ariaLabel":"merging and unmerging permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Merging and unmerging"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"V8 may apply automatic optimizations to some frequently-run code, creating\noptimized versions of those functions. At an internal JavaScript engine level,\noptimized and unoptimized functions are separate entities."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"optimized-and-unoptimized-code","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#optimized-and-unoptimized-code","ariaLabel":"optimized and unoptimized code permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Optimized and unoptimized code"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default, Clinic.js Flame merges all Optimized and Unoptimized functions, and\nrepresents them as single blocks. It also merges all inlinable functions in to\nthe calling functions that they are later inlined into. This creates a simplified\ngraph where stacks only diverge based code logic."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Unticking \"Merge\" in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls#advanced"},"children":[{"type":"text","value":"\"Advanced\" section of the Options Menu"}]},{"type":"text","value":"\nseparates Optimized and Unoptimized functions, showing them as seperate blocks and seperate stacks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is the unmerged view of the flamegraph we created for\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/06-optimizing-a-hot-function/#testing-the-optimized-function"},"children":[{"type":"text","value":"Optimizing A Hot Function"}]},{"type":"text","value":".\nNote how "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":" (among others) forks into two stacks. One is the\noriginal unoptimized function, the other is the optimized version."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/733c5355fcfddb79cdf8bcf1cfb6dd80/29007/09-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACjElEQVQoz02R247bNhCGqYMtWRJ1PlDiQQdSpmzvxgtbshTbaTe7CJCmuUpy1/d/j9ItCnTwXQwG888/5IAfP369vv0xTrd5vi/Lffn4aZ6vl8t1uVzn6cFlvE7n66gYb9P0SfHly/efv/56e/8TLPP8+e3927evn3+br9PT+CJf79Prcn5fxtfLeD+dbqfz7TxeT9PL/tCzpm/4h/0zow1jHNBmi6loxUHID13/pBDy2IgnRc0PpJG1OPDhKHZHUneE0Koi9sYBmu64EGA20HrATJZkW1GJqazoI/kXVVcVQjgmfZygHDeoYhvbBgAEQQAQ7hFRTXtM1YihJBKRoVL5A1lSSekWlQxVPEkLz/ddD3qeByGMohhc5mU6H6aByLrOKrkf+uux2TWNqHlftyXbKRkM8xyxKMpN01CemqatrXUURcCLEUwrN65K2p6mj7QVq5UZJUXNWBgVdS0LzB0YwbjEuMnz3HGUra+8kyQFQZyRdsu6gbSSb/dcPjtBZm6gBRM3yEssikrYXqjEeUE4F13HMSZZliNUAWNlm4ZhqjCM1XrjZS1EvZdzN2s2MeMtp0ysndD1s7KkRZFblq3WVsv7QQhMy9U1XdcNhaZrjz6lLLhX8E3WFrRjrDVtX4lR2eYlhWESRDkM0q7fA2Nt64ZSmgpNM8y146bNQ593btZaEUsRt7xIQZqnOGem7ZVMXXEYl9+BZlqacjbMf1Cr207CvKL3CuHmwkmbouJOVLqu3zUyRmLlBDVmFREv4w2EUWjb6hn6f2jmylI+tp/ZfmrBdANjGKZJEh+3dLfbpgUqs7ijeF7ugFCKMU7Ux6eqI1Gn1x8TwP9RUWE87OTzgQcZgSmqyrRm5G88CVdyE+ItaQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph from Optimizing A Hot Function with ","merge\"":"","disabled\"":"","title":"","src":"/static/733c5355fcfddb79cdf8bcf1cfb6dd80/99f37/09-A.png","srcSet":["/static/733c5355fcfddb79cdf8bcf1cfb6dd80/6b2ea/09-A.png 275w","/static/733c5355fcfddb79cdf8bcf1cfb6dd80/dd45a/09-A.png 550w","/static/733c5355fcfddb79cdf8bcf1cfb6dd80/99f37/09-A.png 1100w","/static/733c5355fcfddb79cdf8bcf1cfb6dd80/29007/09-A.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/controls/#info-panel"},"children":[{"type":"text","value":"Info Panel"}]},{"type":"text","value":" shows the highlighted block's\noptimization status, in the context section on the right. For all JavaScript blocks,\nthis will say either "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"\"Unoptimized\""}]},{"type":"text","value":" or "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"\"Optimized\""}]},{"type":"text","value":". If the block is inlined by V8,\nit will also say "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"\"Inlinable\""}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/7606095a95eb1e8cbc323c28d06d8224/4c7dc/09-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 33.81818181818182%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsSAAALEgHS3X78AAABRElEQVQY0z2Oa0/CQBBFm2gCSqtQoNt9P6bd7ROhBeqLGMAPRv///3GJhmQ+nJnkzL3BMAyn8/nn++v8sX3bV/uNPR22p5fuuN98PvfHXXfou/eue91sm8xqTKyCpqhJyiiVgVCOMJC6ArvSWePHg4RGQi2gVnljXGvcCmyrskqYQkMBtlFQ5q4NmCy5LCh3mDvCHRWeLb2yKDwwBoRlVJSIAqKG8st93b8FKc1T6i67F4Rv4VJ2YT/Mr7zgPEcpR0QzWc0T8Tgnfx+futeg3+36ddlZaoVG1NVF/txKpzRIAGGIT8MmmibLRHg5TkQ0S32FfzmMUTjH42mKqFz3AxX65vYmXiSM0zhGWpcJNnfhzAdy5WU+eViQa/LoLsLcMJVhAdLkWdGGM3Q7DkdRPJkmTNgEw2gyfZxjrup4ye6j+Cr/AnqNNzVLO7SXAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Detail of info panel highlighting unoptimized, inlinable block","title":"","src":"/static/7606095a95eb1e8cbc323c28d06d8224/99f37/09-B.png","srcSet":["/static/7606095a95eb1e8cbc323c28d06d8224/6b2ea/09-B.png 275w","/static/7606095a95eb1e8cbc323c28d06d8224/dd45a/09-B.png 550w","/static/7606095a95eb1e8cbc323c28d06d8224/99f37/09-B.png 1100w","/static/7606095a95eb1e8cbc323c28d06d8224/4c7dc/09-B.png 1599w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"show-optimization-status","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#show-optimization-status","ariaLabel":"show optimization status permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Show optimization status"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With \"Merge\" unticked, there is another way to see which blocks are Optimized or\nUnoptimized. Another option, \"Show optimization status\", becomes available when \"Merge\" is\nunticked. If this is ticked, the text and outline colours of blocks are changed,\nalong with the key at the bottom right of the flamegraph, to show:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Unoptimized blocks in white"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Optimized blocks in grey"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Blocks where optimization is not relevant because they don't represent JavaScript in blue"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Inlinable functions can be found by typing \"inlinable\" into the search box\nwhile \"Merge\" is unticked."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/775047b810f4faaa69c0987ca20a9859/29007/09-C.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 67.63636363636364%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAACe0lEQVQozz1Sa1OjMBTFWjujrVZrX5CUkBDyoAi0EJ7WtdWZ9fFpnf3i/g/39+9FnWUOmZsM555zD7He3n7fH55z05blbVXdVvWuLJuyaEoDa1vkjQFkTd6hNWZXmN3j4+uvt/f94cWqqmp/eHh5ftrflY2J8lTet2ZfZ/dFdqjMD5PvsrzN8nqTmzgNiOe7tNgaESjfl5brSbTilK+5jFkQMR5xmVAeeZ+gQeSr2FcJVzGTEeXKDzRXkcegWFuYaEyUs5JfQB3Ed+12WxsFjCriqSWS2BWcK+QqG4t4U1tzmy8QfAR8hV3lYLnE/3sJeyU9quN1REiAXO1gf+VS0APyTVpZTXtb5lGpV4rQyTKItGwSUkTrtVhvw2iJ5dxmDhgQQACNgDHxpdyRlRKC05tI71vzeDjUhdGSEbQwcRCHIWMh5TdN3YIgIqGN2NVk2s3yRfZ933WJFDIIZBJHm+RGSL1cLBFytILjZOFwj3hhGNudOTjppvsma63Pzs76x8e9Xm80GqXppixKePIsT+I40RJhNpvNFwuns+1yvHIhyO/A0iS5uDgH7mBwAqvj2BXckrquq6ooCvjnnPHx+Mp2MIS3IoL5HAMZiW3xA2ZWw+HwpN//Il+Ox9l2C8rQIs/zTbqRYr207cur6QIJlwhKGSZygbipgSzl6ekpeB4MBv1+fzQagtu27bRBPcu2TWE+Pv6+Pj85Sxro7P39T7HJbZua6s4KQ42Rcz4awdh9eI97o+EZxoiBhEcpIS5G0O7l6eehTDdxdHh4vG/rNfd3u32X9mfg7mw2m15PryeT3tHRkWV9A8pu11Xcp1mqx5eXk+l8PpsjB/8DCH97DV67m8QAAAAASUVORK5CYII='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph with ","merge\"":"","disabled":true,"and":"","\"show":"","optimization":"","status\"":"","enabled\"":"","title":"","src":"/static/775047b810f4faaa69c0987ca20a9859/99f37/09-C.png","srcSet":["/static/775047b810f4faaa69c0987ca20a9859/6b2ea/09-C.png 275w","/static/775047b810f4faaa69c0987ca20a9859/dd45a/09-C.png 550w","/static/775047b810f4faaa69c0987ca20a9859/99f37/09-C.png 1100w","/static/775047b810f4faaa69c0987ca20a9859/29007/09-C.png 1600w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For example, in the above flamegraph (the one we generated while\n"},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/06-optimizing-a-hot-function/#testing-the-optimized-function"},"children":[{"type":"text","value":"Optimizing A Hot Function"}]},{"type":"text","value":"),\nwe can see more easily that "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":" forks into an optimized and unoptimized branch, and in\nthe optimized branch, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"payload"}]},{"type":"text","value":" (selected) is flagged as \"Inlinable\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is why, when we looked at that flamegraph in the default merged view, it\nwas absent. It was inlined into its parent function, the optimized version\nof "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.get"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"v8","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#v8","ariaLabel":"v8 permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"V8"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"id":"controls-v8","dataOffset":""},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In addition to showing functions from the Node.js framework, Clinic.js Flame can be set\nto show functions from within the V8 JavaScript engine, by ticking the \"V8\" checkbox\nin the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/flame/05-controls/#visibility-by-code-area"},"children":[{"type":"text","value":"\"Visibility by code area\" section of the Options Menu"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This often adds a significant amount of complexity to the flamegraph, much of which\nmay not be wanted. Flame therefore allows users to expand the V8 options and filter\nspecific types of V8 function:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"v8-native","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#v8-native","ariaLabel":"v8 native permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"V8 Native"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"id":"controls-v8-native","dataOffset":""},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These are native JavaScript functions that are compiled into V8."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This would include any native prototype methods ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Array.prototype.join"}]},{"type":"text","value":" for instance),\nand any functions that aren't publicly exposed but are used internally by V8\n("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"InnerArrayJoin"}]},{"type":"text","value":" for instance)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In addition, evaluated functions (either code run with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"eval"}]},{"type":"text","value":" or created with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Function"}]},{"type":"text","value":")\nwill also appear as native frames, with the file path shown as "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[eval]"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"v8-runtime","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#v8-runtime","ariaLabel":"v8 runtime permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"V8 Runtime"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"id":"controls-v8-runtime","dataOffset":""},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These are C++ frames pertaining to the runtime operations of V8's implementation\nof JavaScript. Examples include (depending on V8 version) "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"StringEqual"}]},{"type":"text","value":"\nand "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"ObjectSetPrototypeOf"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Tags can include "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:LoadGlobalIC]"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:Handler]"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:CallIC]"}]},{"type":"text","value":",\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:LoadIC]"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:StoreIC]"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:Builtin]"}]},{"type":"text","value":" ,\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:BytecodeHandler]"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:Builtin]"}]},{"type":"text","value":" , "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:Stub]"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"v8-c","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#v8-c","ariaLabel":"v8 c permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"V8 C++"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"id":"controls-v8-cpp","dataOffset":""},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These are C++ frames that are called by the V8 layer, not including C++ frames\nthat may be called in Node, Libuv or third party modules."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These frames can include the tags "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CPP]"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[SHARED_LIB]"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"regexp","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#regexp","ariaLabel":"regexp permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"RegExp"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"id":"controls-regexp","dataOffset":""},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"RegExp stands for Regular Expressions. These are also captured as \"frames\".\nIn this case the regular expression notation fills in as the \"function name\" portion\nof the block label. This can be useful in identifying slow regular expressions\n(in particular "},{"type":"element","tagName":"a","properties":{"href":"https://perlgeek.de/blog-en.cgi/perl-tips/in-search-of-an-exponetial-regexp.html","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"exponential time regular expressions"}]},{"type":"text","value":")."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These will have the tag "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"[CODE:RegExp]"}]},{"type":"text","value":"."}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/flame/09-advanced-controls/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Advanced controls","priority":9}}}}]},{"title":"Heapprofiler","entry":{"id":"76924df8-20b7-51f2-8d5c-57aede8a9c6f","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"heap-profiler","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#heap-profiler","ariaLabel":"heap profiler permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Heap Profiler"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're looking to quickly get started with understanding\nmemory profiling and learning how to optimize Node.js code then this\nis a great place to start."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/01-setup/"},"children":[{"type":"text","value":"Setup"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/04-flamegraphs/"},"children":[{"type":"text","value":"Flamegraphs"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/05-controls/"},"children":[{"type":"text","value":"Controls"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/06-optimizing-a-hot-function/"},"children":[{"type":"text","value":"Optimizing a hot function"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/","template":"src/templates/documentation.js"},"frontmatter":{"title":"","priority":5}}},"links":[{"title":"01 Setup","entry":{"id":"5c82d017-accd-5d67-9751-e04f68b478ed","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"setup","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#setup","ariaLabel":"setup permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Setup"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Heap Profiler is part of the Clinic.js suit of tools. To install Heap Profiler, simply install\nClinic.js like so:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g clinic"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After installing, we can check if HeapProfiler has been installed with running the\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic heapprofiler"}]},{"type":"text","value":" command with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--help"}]},{"type":"text","value":" flag."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic heapprofiler --help"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It should print something similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Clinic.js Heap Profiler - v3.0.0\n\nclinic heapprofiler helps you find memory leaks\nby creating a flamegraph visualization that assists in identifying\nfunction calls that may be leaking memory.\n\nTo run clinic heapprofiler\n\n  clinic heapprofiler -- node server.js\n\nOnce you exit (Ctrl-C) the process, your report will open in a browser window. You can disable this behavior:\n\n  clinic heapprofiler --open=false -- node server.js\n\nIf profiling on a server, it can be useful to only do data collection:\n\n  clinic heapprofiler --collect-only -- node server.js\n\nYou can then transfer the data and visualize it locally:\n\n  clinic heapprofiler --visualize-only PID.clinic.heapprofile\n\nYou can use the --autocannon flag to simulate load on your server.\n--autocannon accepts configuration for autocannon using \"subarg\" syntax:\n\n  clinic heapprofiler --autocannon [ -m POST /api/example ] -- node server.js\n\nWhen configuring --autocannon, the $PORT environment variable contains the\nport your server is listening on:\n\n  clinic heapprofiler --autocannon [ -m POST 'http://localhost:$PORT/?\\$page=1' ] -- node server.js\n\nNote that dollar signs ($) appearing in the URL must be escaped, else they\nwill be treated as environment variables as well.\n\nFlags\n-h | --help                Display Help\n-v | --version             Display Version\n--collect-only             Do not process data on termination\n--visualize-only datapath  Build or rebuild visualization from data\n--on-port                  Run a script when the server starts listening on a port.\n--autocannon               Run the autocannon benchmarking tool when the server starts listening on a port.\n--open                     Boolean to enable or disable your report opening in your web browser.\n--dest                     Destination for the collected data (default .clinic/)."}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/02-getting-ready/"},"children":[{"type":"text","value":"Getting ready"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/01-setup/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Setup","priority":1}}}},{"title":"02 Getting Ready","entry":{"id":"edde3cfc-b9ba-5177-8754-f65ccc345edf","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"getting-ready","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#getting-ready","ariaLabel":"getting ready permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Getting ready"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once we've installed "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic"}]},{"type":"text","value":" and verified that "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic heapprofiler"}]},{"type":"text","value":" is functioning\nwe can profile an application."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To try this out, let's clone and prepare the official Clinic.js Heap Profiler demo:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"git"}]},{"type":"text","value":" clone https://github.com/clinicjs/node-clinic-heap-profiler-demo.git\n"},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" node-clinic-heap-profiler-demo\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"While npm downloads the dependencies, check the "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/clinicjs/node-clinic-heap-profiler-demo","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Readme"}]},{"type":"text","value":",\nthen we are ready to profile!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/02-getting-ready/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Getting ready","priority":2}}}},{"title":"03 First Analysis","entry":{"id":"2dddab72-46de-5749-b766-0f3841864a4c","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"first-analysis","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#first-analysis","ariaLabel":"first analysis permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"First analysis"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now we're ready to profile the application."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's try with the first server in the repository, "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"1-server-with-many-allocations.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It contains an HTTP server, built using Fastify with a root route ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":") that adds an integer to a global array in each request received."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The server can be started with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node 1-server-with-many-allocations.js"}]},{"type":"text","value":" and then accessed in the browser at "},{"type":"element","tagName":"a","properties":{"href":"http://localhost:3000/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"http://localhost:3000/"}]},{"type":"text","value":". If the landing page says\n\"Hello World\" then things are working!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's try and profile the server with Flame to see if we can find any bottlenecks."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To do that we need a tool that can simulate sufficiently intense HTTP load."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We suggest "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" which is supported on Windows, Mac and Linux and is straightforward to use."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's install it from npm:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g autocannon"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To run the analysis we want to run the server with HeapProfiler and when the server is ready, we want to send a ton of requests to it using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All that can be performed with a single command, which can be copied and pasted as-is:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"clinic heapprofiler --autocannon "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":" / --method GET -d "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"120"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" -- "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":"-server-with-many-allocations.js"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's break this command down:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic heapprofiler"}]},{"type":"text","value":" portion invokes the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"heapprofiler"}]},{"type":"text","value":"\ncommand tool."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--autocannon"}]},{"type":"text","value":" flag will execute the tool as soon as the server starts listening on a port sending tons of requests."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Everything after the double-dash ("},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"--"}]},{"type":"text","value":") is the command which starts the server that we want to profile, in this case "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node 1-server-with-many-allocations.js"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This one command runs three executables: the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"clinic heapprofiler"}]},{"type":"text","value":" parent executable, the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"autocannon"}]},{"type":"text","value":" executable, and the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" executable."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Upon running the command, the process will be load tested for 120 seconds (as per the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"-d 120"}]},{"type":"text","value":" parameter), then the results be compiled into a single HTML file that should automatically open in the browser."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The resulting HTML should look similar to the following:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/2929425c4edff1461f860c3a5a22694b/2ed34/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 53.090909090909086%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAAB4ElEQVQoz22Q6Y7aMBSFTaYzCQyEhGzEjp3Vjp2EJOxQlelMKwotaqsK9f1fpR6gy49Kn6yrc8/xkQ0+fzufvv7cvRy3mw/b+ctx9/30/sfz9rjbfHq6cXidt4dXNod36/3Hp9Npf/6yPwMh6rpZlpNZkrAkZrNmI2nqVT1ZSibVoqrmZTErxFRSlfO2XTfNqiymSZwDEucwSCHOcJSTmCOSSYKQXkGE3hSS+Tj1bysm/ZaLAMQ5IjLD5XCZ/wuHhDd0vmBLEgpI8kASChD8Y/IDemWMMnn+1TH1MEUwNHUDBrKcX3XwxwQxS2jNxIyJKS8XlE8RvulpWldiEwXj0VD1UOITHlzKQcuW8BbOBc9ZGmdpOilYW/HftawV7a5aUGRDZ7CkzVrMIaZjTIEtH365HkUFdIYPCgCgoynAGajyC6XJJwJ6pt4Fyl1HrqxHJXH1PK5F2gLDtH0iC5t1/paRyNA1U++bxhCNPRRxljVb8TSJ42Gvoyidrqr0u8qjdp/YcBGGALpIxoq47Pd6o5E1smzLsjzPJQFZ56si5KZhjF3HGA409UG9v9PUN92uZpi66xogSXNJmvEkpQHGSeCMbT2KQkxIlmYQIh8GJMoyWsRJjsNsZLmDge44HibRL+o/V7DAEdiNAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph screenshot","title":"","src":"/static/2929425c4edff1461f860c3a5a22694b/99f37/03.png","srcSet":["/static/2929425c4edff1461f860c3a5a22694b/6b2ea/03.png 275w","/static/2929425c4edff1461f860c3a5a22694b/dd45a/03.png 550w","/static/2929425c4edff1461f860c3a5a22694b/99f37/03.png 1100w","/static/2929425c4edff1461f860c3a5a22694b/573d3/03.png 1650w","/static/2929425c4edff1461f860c3a5a22694b/2ed34/03.png 1776w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is known as a Flamegraph."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/04-flamegraphs"},"children":[{"type":"text","value":"Flamegraphs"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/03-first-analysis/","template":"src/templates/documentation.js"},"frontmatter":{"title":"First analysis","priority":3}}}},{"title":"04 Flamegraphs","entry":{"id":"3707564f-ecf3-559a-a8a4-5d1eb1b7e2b9","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"flamegraphs","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flamegraphs","ariaLabel":"flamegraphs permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flamegraphs"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a look again at the flamegraph generated in the prior "},{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/03-first-analysis/"},"children":[{"type":"text","value":"First analysis"}]},{"type":"text","value":" step."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/2929425c4edff1461f860c3a5a22694b/2ed34/03.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 53.090909090909086%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsSAAALEgHS3X78AAAB4ElEQVQoz22Q6Y7aMBSFTaYzCQyEhGzEjp3Vjp2EJOxQlelMKwotaqsK9f1fpR6gy49Kn6yrc8/xkQ0+fzufvv7cvRy3mw/b+ctx9/30/sfz9rjbfHq6cXidt4dXNod36/3Hp9Npf/6yPwMh6rpZlpNZkrAkZrNmI2nqVT1ZSibVoqrmZTErxFRSlfO2XTfNqiymSZwDEucwSCHOcJSTmCOSSYKQXkGE3hSS+Tj1bysm/ZaLAMQ5IjLD5XCZ/wuHhDd0vmBLEgpI8kASChD8Y/IDemWMMnn+1TH1MEUwNHUDBrKcX3XwxwQxS2jNxIyJKS8XlE8RvulpWldiEwXj0VD1UOITHlzKQcuW8BbOBc9ZGmdpOilYW/HftawV7a5aUGRDZ7CkzVrMIaZjTIEtH365HkUFdIYPCgCgoynAGajyC6XJJwJ6pt4Fyl1HrqxHJXH1PK5F2gLDtH0iC5t1/paRyNA1U++bxhCNPRRxljVb8TSJ42Gvoyidrqr0u8qjdp/YcBGGALpIxoq47Pd6o5E1smzLsjzPJQFZ56si5KZhjF3HGA409UG9v9PUN92uZpi66xogSXNJmvEkpQHGSeCMbT2KQkxIlmYQIh8GJMoyWsRJjsNsZLmDge44HibRL+o/V7DAEdiNAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example flamegraph from node-clinic-heap-profiler-demo","title":"","src":"/static/2929425c4edff1461f860c3a5a22694b/99f37/03.png","srcSet":["/static/2929425c4edff1461f860c3a5a22694b/6b2ea/03.png 275w","/static/2929425c4edff1461f860c3a5a22694b/dd45a/03.png 550w","/static/2929425c4edff1461f860c3a5a22694b/99f37/03.png 1100w","/static/2929425c4edff1461f860c3a5a22694b/573d3/03.png 1650w","/static/2929425c4edff1461f860c3a5a22694b/2ed34/03.png 1776w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Ignoring the surrounding controls for the moment, let's focus in on understanding the visualization."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When generating a flamegraph we are asking three key questions:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"During the sampling period, which functions called each other?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"How much memory was allocated by each function observed?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"What are the functions that allocate more memory on the heap?"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These three questions are answered visually."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"which-functions-called-each-other-the-stack","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#which-functions-called-each-other-the-stack","ariaLabel":"which functions called each other the stack permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Which functions called each other (the stack)"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each block represents the invocations of one function, aggregated by the call stack that led to it. When one block sits on top of another, it was called by the block below it, which was called by the block below it, and so on down the stack."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/e70d01dff1c6435874bd7105fe887f90/4b701/04-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 17.09090909090909%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAIAAAAcOLh5AAAACXBIWXMAAAsSAAALEgHS3X78AAAAt0lEQVQI1w3H3QqCMBgA0JWu1M+t3NBs5Mwif6guirAY9kdQ0EWE3QRq9P5PUefuoPvxWV7ej9Prvi8Pq6tanNVyl4ZD6RHBsNfDzO6Enn5bFPW2qnbvRtWNqr7Fp8xfaBJJGfihFJxxQh2gnPY9zv514+k4nUXccQiYwuEh95NRtImzPMm26XydzFEW0Fh0J76RjkC6XRuIDT3LtMGihDBKGUDfMEwdtzW91dKQ4NpU4PGgLQfWD3OpFxsfHsY3AAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example of how flamegraphs represent call stacks","title":"","src":"/static/e70d01dff1c6435874bd7105fe887f90/99f37/04-A.png","srcSet":["/static/e70d01dff1c6435874bd7105fe887f90/6b2ea/04-A.png 275w","/static/e70d01dff1c6435874bd7105fe887f90/dd45a/04-A.png 550w","/static/e70d01dff1c6435874bd7105fe887f90/99f37/04-A.png 1100w","/static/e70d01dff1c6435874bd7105fe887f90/4b701/04-A.png 1587w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"how-much-memory-was-allocated-by-each-function-observed","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#how-much-memory-was-allocated-by-each-function-observed","ariaLabel":"how much memory was allocated by each function observed permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"How much memory was allocated by each function observed?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The width of a block represents the amount of memory that the function allocated. In the box at top-right contain the allocation info of the selected function."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/01639db41bc7e31ea61fff8cafeddbb9/1cfc2/04-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 900px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 48%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsSAAALEgHS3X78AAABw0lEQVQoz03Qa28SURCA4d2K1kjBhb2dnXPd+x72UqhAgdQSm2rTxhYUKKJCUjX6//+BW4jU5MlkvrzJZBQH2B4Ax/84wH0kCut9weYFmUh0m5PpMfscGlfk1QhXz8MXhSK8ZMf1EixCxD1HBA4PbOFHTLp4ZdFfiP0g3h/i/q4bq5e12WF1WjmaQfVCITwpUS4RDYfZeNL7dNud3PWm152P4/gc2/OGvTHRGvOfDnkw0AaRhyNtcVi/p/UPCmbxDtA49tMQXCliz2K4iRIU+vYMWV+xtWKw5nhdTkE2SF9or2dSv36KMUswFU2joR6oiqo2zSZnboyLaCuEPNoql5gUAcqG2VuFPt68Iyn3HYBarVapVHTDIMx3eOTwcOtpARFZxGt1BoqBfQN7JR37hFJDqwpGAcCxDVd4hEnCki259Xhj+SOEg7w9VAZydCpH5Ry2xqnA3FS02sGz56qtqRw3bBrYxN1B1AMe7eOsjL/1vyxP5jfh1SW7OONFy4TUYp5GgwYa+915e7k4Wd6/Wa1632+yuwBS4P/FfZ53SSs1Q7fuS10eW3mfdU95L7eywswzPe9C513QK53xQQpth0X7+C+xeFeXH/qC6QAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example how to check how much memory was allocated by a function","title":"","src":"/static/01639db41bc7e31ea61fff8cafeddbb9/1cfc2/04-B.png","srcSet":["/static/01639db41bc7e31ea61fff8cafeddbb9/6b2ea/04-B.png 275w","/static/01639db41bc7e31ea61fff8cafeddbb9/dd45a/04-B.png 550w","/static/01639db41bc7e31ea61fff8cafeddbb9/1cfc2/04-B.png 900w"],"sizes":["(max-width:","900px)","100vw,","900px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"what-are-the-functions-that-allocate-more-memory-on-the-heap","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#what-are-the-functions-that-allocate-more-memory-on-the-heap","ariaLabel":"what are the functions that allocate more memory on the heap permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"What are the functions that allocate more memory on the heap?"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The \"hottest\" function in the profile is selected by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here, we can see the function name and file location (or equivalent), so we can inspect the underlying code and decide if this function is something we can and should optimize."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/8ab70b957721158d6182100c41e7cd02/e1250/04-C.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 8.363636363636363%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAIAAADXZGvcAAAACXBIWXMAAAsSAAALEgHS3X78AAAASElEQVQI12PwDwwPi4jz8Qs20TEzUDO2M3WxN3W1NXEBMvAjezNXBikZBWkZJUlpBTlFFRkFJTklVTlFVRl5ZfxIWl5JQUUdADYdFipGsCuzAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example first biggest","title":"","src":"/static/8ab70b957721158d6182100c41e7cd02/99f37/04-C.png","srcSet":["/static/8ab70b957721158d6182100c41e7cd02/6b2ea/04-C.png 275w","/static/8ab70b957721158d6182100c41e7cd02/dd45a/04-C.png 550w","/static/8ab70b957721158d6182100c41e7cd02/99f37/04-C.png 1100w","/static/8ab70b957721158d6182100c41e7cd02/573d3/04-C.png 1650w","/static/8ab70b957721158d6182100c41e7cd02/e1250/04-C.png 1786w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The example above shows an Node.js function as the most hottest, you can click in \"Next biggest\" until reach an application function."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/1ce0673ceb8173d70ed07ea8cc8fc06f/c6e28/04-D.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 28.72727272727273%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAA60lEQVQY033Q30vDMBAH8D77oExwtpfLJVt+tU1ibbdu7UQG0xd9G/4J/v//gykVpgjCh3Ac+eaOZNrWoembsAls77j3sQ0PWx83szp0SeWTtvKPrTs29iPaczRnR2/ZWntABVyJlZbrkqTjwpJM3FwjGUYGuclRYh4FvAr2QnC6vz1kBRrgLinQTrgF/uuE79pUqtuVoxSmQAl8hUJl8OPGf8gJ0nCXA2hG1Tzvb3jq5miTy1hUCWPs5vpqsYQl6rRI6l/COTMhdn2/6/v9eHgehidG00PpR7by9O4/B/LFImtVO9ZHEmXKfwHvbjIdoTuOfQAAAABJRU5ErkJggg=='); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Example application biggest","title":"","src":"/static/1ce0673ceb8173d70ed07ea8cc8fc06f/99f37/04-D.png","srcSet":["/static/1ce0673ceb8173d70ed07ea8cc8fc06f/6b2ea/04-D.png 275w","/static/1ce0673ceb8173d70ed07ea8cc8fc06f/dd45a/04-D.png 550w","/static/1ce0673ceb8173d70ed07ea8cc8fc06f/99f37/04-D.png 1100w","/static/1ce0673ceb8173d70ed07ea8cc8fc06f/573d3/04-D.png 1650w","/static/1ce0673ceb8173d70ed07ea8cc8fc06f/c6e28/04-D.png 1777w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the next chapter, we will see how to manage the UI to visualize only the meaningful data to the provided demo."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h5","properties":{"id":"up-next","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#up-next","ariaLabel":"up next permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Up next"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/05-controls/"},"children":[{"type":"text","value":"Controls"}]}]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/04-flamegraphs/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Flamegraphs","priority":4}}}},{"title":"05 Controls","entry":{"id":"9dff1c0c-4994-5aa1-a04d-3bc6928de619","childMarkdownRemark":{"htmlAst":{"type":"root","children":[{"type":"element","tagName":"h1","properties":{"id":"controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#controls","ariaLabel":"controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The Clinic.js HeapProfiler UI controls have three main sections:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Flamegraph controls"}]},{"type":"text","value":": Interacting with the flamegraph itself"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Allocation Info"}]},{"type":"text","value":": Along the top, containing info about the block currently highlighted"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Options Menu"}]},{"type":"text","value":": More advanced controls expandable from the info panel"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"flamegraph-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#flamegraph-controls","ariaLabel":"flamegraph controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Flamegraph controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"interacting-with-a-flamegraph-block","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#interacting-with-a-flamegraph-block","ariaLabel":"interacting with a flamegraph block permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Interacting with a flamegraph block"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Hovering"}]},{"type":"text","value":" the mouse over a block will temporarily show info about that\nblock in the info panel at the top of the screen."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Clicking"}]},{"type":"text","value":" will select the block, so that the info panel reverts to that\nblock when you are no longer hovering over anything."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you find an interesting-looking block, it can be useful to click on it\nso you can hover around exploring its neighbours without losing it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/heap-docs-A.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"tooltip-buttons","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#tooltip-buttons","ariaLabel":"tooltip buttons permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Tooltip buttons"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After single-clicking on a block, or hovering over it for a moment, a tooltip appears,\nwith one or more buttons:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Expand"}]},{"type":"text","value":". "},{"type":"element","tagName":"a","properties":{"href":"#expanding"},"children":[{"type":"text","value":"See below"}]},{"type":"text","value":" for more about expanding a particular block."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Contract"}]},{"type":"text","value":". If this is the block that you have already expanded, it will show\n\"Contract\" instead of \"Expand\", which will take you back to the main view."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"expanding","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#expanding","ariaLabel":"expanding permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Expanding"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When a block is double-clicked, or its tooltip \"Expand\" button is used,\nit will expand to fill the full width of the flamegraph.\nBlocks below will also expand and fill\nthe full width, while blocks above the clicked block will\nincrease in ratio to the block they sit on. Expanding a block\nessentially creates a new flamegraph which represents a particular\npartition of the main flamegraph."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The block that has been expanded is marked with a shadow underneath.\nEvery block below this 'shadow' is probably wider (more memory allocated on the heap)\nthan the block that has expanded to fill the screen."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To get back to the main, non-expanded view, you can either click on the\nbackground, click \"Return to main view\" at the bottom of the screen,\ndouble-click on the expanded frame, or click on its \"Contract\" tooltip button."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/heap-docs-B.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"allocation-info","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#allocation-info","ariaLabel":"allocation info permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Allocation Info"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are five main features in the Allocation Info panel:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Stack bar"}]},{"type":"text","value":": A thin bar showing the \"hottest\" blocks in order"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Selection controls"}]},{"type":"text","value":": Flick to the next hottest, previous, etc"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Code info"}]},{"type":"text","value":": Where the function behind the currently highlighted block comes from"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Search box"}]},{"type":"text","value":": For finding functions by name or path"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Options Menu"}]},{"type":"text","value":": More advanced features. This "},{"type":"element","tagName":"a","properties":{"href":"#options-menu"},"children":[{"type":"text","value":"Options Menu has its own section below"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"stack-bar","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#stack-bar","ariaLabel":"stack bar permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Stack Bar"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We previously explained, in the "},{"type":"element","tagName":"a","properties":{"href":"/documentation/heapprofiler/04-flamegraphs/"},"children":[{"type":"text","value":"Flamegraphs"}]},{"type":"text","value":" page,\nhow it is useful to consider how much memory a function allocated at the top of the stack,\nmeaning the V8 allocated memory in the heap from that function; and how this is represented by the brightness or \"heat\" of the colour of the exposed part of a block."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This bar shows you the heat of those exposed stack tops, of every block in the\nflamegraph, in order of heat i.e. in order of how long that block's function\nwas blocking the event loop."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can run the cursor along this bar from left to right to see where these\n\"hot\" functions are on the main flamegraph, with the same interaction as above:\nhover to see info, click to select and show tooltip, double click to expand."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The left-most (hottest) block is selected by default when a Clinic.js Heap profile\nis first opened."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/heap-docs-C.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"selection-controls","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#selection-controls","ariaLabel":"selection controls permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Selection Controls"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These buttons allow you to easily jump from the currently selected block, to the\nblock that is one to the left or right of it in the hottness-ranking shown by\nthe Stack Bar."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A good place to start with a Clinic.js Heap flamegraph, is to cycle through\nusing the \"Next hottest\" button, and for each block it selects, think why that\nfunction are allocating too much memory. For example, it might be a\nfunction wasting unnecessary resources, or it might be a function you know that is expensive, but\nwhen you look at what is below it in the flamegraph, you might discover\nthat it is being called too many times (for example, it might be in a nested loop)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/heap-docs-D.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"code-info","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#code-info","ariaLabel":"code info permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Code info"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This gives you more complete information about the code behind the block that is\ncurrently highlighted."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Function name (or equivalent) on the left. Anonymous functions are labelled\n"},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"(anonymous)"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"File path (or equivalent) in the middle, including line and column number (if\napplicable)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Context. This tells you what category this block is (for example, dependency), and\nmay include additional information if certain\n"},{"type":"element","tagName":"a","properties":{"href":"#visibility-by-code-area"},"children":[{"type":"text","value":"function labels"}]},{"type":"text","value":" are used."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"search-box","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#search-box","ariaLabel":"search box permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Search box"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If there is some particular file or function(s) you want to locate, you can type part\nof the function name, file path or equivalent here, and any matches will be highlighted,\nin the same colour used for text and outlines."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This can be useful if you've done such a good job optimizing an operation, you can\nno longer find it on the flamegraph!"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/fd9dca87b5294f2e12df74ad241f7d97/72372/05-B.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 4%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAIAAABR8BlyAAAACXBIWXMAAAsSAAALEgHS3X78AAAARUlEQVQI12Mw1NczVJdUkRXSVJbW0VDR0zNUVFLR1NIxNjZTUVXX0tZTVdXQ1TcxMbPXN7N21naxFvEwF3fX53O0FLAGACtnCl/9IKFQAAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Flamegraph with a search for frames that contain ","functionname\"\"":"","title":"","src":"/static/fd9dca87b5294f2e12df74ad241f7d97/99f37/05-B.png","srcSet":["/static/fd9dca87b5294f2e12df74ad241f7d97/6b2ea/05-B.png 275w","/static/fd9dca87b5294f2e12df74ad241f7d97/dd45a/05-B.png 550w","/static/fd9dca87b5294f2e12df74ad241f7d97/99f37/05-B.png 1100w","/static/fd9dca87b5294f2e12df74ad241f7d97/72372/05-B.png 1149w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If it is possible the function do not allocated too much memory in a given time, it might appear if you create a new profile\nwith a "},{"type":"element","tagName":"a","properties":{"href":"https://www.npmjs.com/package/autocannon#usage","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"longer duration and/or more connections in Autocannon"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"options-menu","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#options-menu","ariaLabel":"options menu permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Options Menu"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Clicking \"Options\" on the right side of the Info Panel opens a menu with\nmore advanced options."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"visibility-by-code-area","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#visibility-by-code-area","ariaLabel":"visibility by code area permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Visibility by code area"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tagName":"a","properties":{"className":["gatsby-resp-image-link"],"href":"/static/97ab64157c191b4b2243114de6c5ef62/b7936/05-A.png","style":"display: block","target":"_blank","rel":["noopener"]},"children":[{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-wrapper"],"style":"position: relative; display: block;  max-width: 1100px; margin-left: auto; margin-right: auto;"},"children":[{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["gatsby-resp-image-background-image"],"style":"padding-bottom: 5.454545454545455%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAIAAABR8BlyAAAACXBIWXMAAAsSAAALEgHS3X78AAAAQklEQVQI12PQN7LS0tZX1dDR11ZWVRBXVZbX1dVTUtVU19LV0jUEiqtr6mrpGOkb2egbWcvIKQuJSACRpLS8kqoGACapCSlhOnC9AAAAAElFTkSuQmCC'); background-size: cover; display: block;"},"children":[{"type":"text","value":"\n      "},{"type":"element","tagName":"img","properties":{"className":["gatsby-resp-image-image"],"style":"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;","alt":"Function labels","title":"","src":"/static/97ab64157c191b4b2243114de6c5ef62/99f37/05-A.png","srcSet":["/static/97ab64157c191b4b2243114de6c5ef62/6b2ea/05-A.png 275w","/static/97ab64157c191b4b2243114de6c5ef62/dd45a/05-A.png 550w","/static/97ab64157c191b4b2243114de6c5ef62/99f37/05-A.png 1100w","/static/97ab64157c191b4b2243114de6c5ef62/b7936/05-A.png 1155w"],"sizes":["(max-width:","1100px)","100vw,","1100px"]},"children":[]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n  "}]},{"type":"text","value":"\n  \n  "}]},{"type":"text","value":"\n    "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These toggle buttons show (tick) or hide (untick) blocks based on where the\ncode is in the application or Node.js framework."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"[Application name]"}]},{"type":"text","value":": Code inside the main package being profiled. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Dependencies"}]},{"type":"text","value":": Code in a dependency in a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"node_modules"}]},{"type":"text","value":" directory. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Node JS"}]},{"type":"text","value":": Code inside Node.js core. Visible by default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"V8"}]},{"type":"text","value":": Functions inside the V8 JavaScript engine. Hidden by default."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{"id":"preferences","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#preferences","ariaLabel":"preferences permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Preferences"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Presentation mode"}]},{"type":"text","value":": Increases text sizes and colour contrasts, which can be useful\nif Clinic.js Heap is being presented under suboptimal conditions (e.g. on a projector in\na brightly lit room)."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Profiles can be set to show in Presentation Mode by default by\nsetting the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"PRESENTATION_MODE"}]},{"type":"text","value":" environment variable to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"TRUE"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"video","properties":{"src":"/assets/videos/heap-docs-E.mp4","playsInline":true,"loop":true,"autoPlay":true,"muted":true},"children":[]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"hr","properties":{},"children":[]}],"data":{"quirksMode":false}},"fields":{"slug":"/documentation/heapprofiler/05-controls/","template":"src/templates/documentation.js"},"frontmatter":{"title":"Controls","priority":5}}}}]}]}},"pageContext":{"slug":"/documentation/heapprofiler/"}},"staticQueryHashes":[]}