{"id":7408,"date":"2018-08-13T12:50:53","date_gmt":"2018-08-13T16:50:53","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=7408"},"modified":"2018-08-13T12:50:53","modified_gmt":"2018-08-13T16:50:53","slug":"use-the-profiler","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=7408","title":{"rendered":"Use The Profiler!"},"content":{"rendered":"<p>\nFor the last year, Matus Goljer (fuco1) has been working on a static analyzer for Elisp. Although still in its early stages, the project is promising and I&rsquo;ve been following it with interest. Goljer has made good progress and can now analyze the main file in the <a href=\"https:\/\/github.com\/Fuco1\/smartparens\">smartparens<\/a> code base. There was a problem, however.\n<\/p>\n<p>\nIt was slow. Very slow. Analyzing smartparens took about 42 seconds even though the <code>smartparens.el<\/code> file is only about 9500 lines. Goljer was expecting it to be a bit slow because he used EIEIO and CL generics. While they&rsquo;re a natural fit for the problem, they have notorious performance issues. What to do? Goljer did what we all do: he assumed the problem was with EIEIO and generics and started changing his code. That turned out to be a mess so he did what we all promise ourselves we&rsquo;re going to do in situations like this but rarely actually do: he fired up the profiler to see were all the time was going.\n<\/p>\n<p>\nThe answer was surprising. The problem turned out to be in a function that he would never have thought would cause difficulties. I won&rsquo;t spoil the surprise by telling you what it was; you&rsquo;ll have to read his <a href=\"https:\/\/fuco1.github.io\/2018-08-12-WAR-STORY:-When-turning-to-the-profiler-turns-out-to-be-a-good-call.html\">post<\/a> to see. In any event, he replaced the problem function with some code that accomplished the same end and reduced the running time to 5 seconds.\n<\/p>\n<p>\nThe moral here is what it always is: don&rsquo;t assume you know where all the cycles are being spent. You&rsquo;re probably wrong. Almost every environment has a profiler and they&rsquo;re the go-to method for determining where your application is spending its time.\n<\/p>\n<p>\nBe sure to take a look at Goljer&rsquo;s post. It&rsquo;s an interesting story and a nice illustration of the power of profilers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the last year, Matus Goljer (fuco1) has been working on a static analyzer for Elisp. Although still in its early stages, the project is promising and I&rsquo;ve been following it with interest. Goljer has made good progress and can &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=7408\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-7408","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7408"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7408\/revisions"}],"predecessor-version":[{"id":7409,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7408\/revisions\/7409"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}