Skip to content

Commit

Permalink
build based on d803b4e
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Dec 10, 2024
1 parent b9cfdfb commit f96aaf8
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 150 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-24T16:07:42","documenter_version":"1.8.0"}}
{"documenter":{"julia_version":"1.11.2","generation_timestamp":"2024-12-10T11:35:43","documenter_version":"1.8.0"}}
2 changes: 1 addition & 1 deletion dev/explanations/basic/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/explanations/fixing_inference/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
return getfield(d, :maker)::Union{String,Symbol}
end
return getfield(d, name)
end</code></pre><p>Julia&#39;s <a href="https://en.wikipedia.org/wiki/Constant_folding">constant propagation</a> will ensure that most accesses of those fields will be determined at compile-time, so this simple change robustly fixes many inference problems.</p><h2 id="Fixing-Core.Box"><a class="docs-heading-anchor" href="#Fixing-Core.Box">Fixing <code>Core.Box</code></a><a id="Fixing-Core.Box-1"></a><a class="docs-heading-anchor-permalink" href="#Fixing-Core.Box" title="Permalink"></a></h2><p><a href="https://github.com/JuliaLang/julia/issues/15276">Julia issue 15276</a> is one of the more surprising forms of inference failure; it is the most common cause of a <code>Core.Box</code> annotation. If other variables depend on the <code>Box</code>ed variable, then a single <code>Core.Box</code> can lead to widespread inference problems. For this reason, these are also among the first inference problems you should tackle.</p><p>Read <a href="https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-captured">this explanation of why this happens and what you can do to fix it</a>. If you are directed to find <code>Core.Box</code> inference triggers via <a href="../../reference/#SnoopCompile.suggest"><code>suggest</code></a>, you may need to explore around the call site a bit– the inference trigger may be in the closure itself, but the fix needs to go in the method that creates the closure.</p><p>Use of <code>ascend</code> is highly recommended for fixing <code>Core.Box</code> inference failures.</p><h2 id="Handling-edge-cases"><a class="docs-heading-anchor" href="#Handling-edge-cases">Handling edge cases</a><a id="Handling-edge-cases-1"></a><a class="docs-heading-anchor-permalink" href="#Handling-edge-cases" title="Permalink"></a></h2><p>You can sometimes get invalidations from failing to handle &quot;formal&quot; possibilities. For example, operations with regular expressions might return a <code>Union{Nothing, RegexMatch}</code>. You can sometimes get poor type inference by writing code that fails to take account of the possibility that <code>nothing</code> might be returned. For example, a comprehension</p><pre><code class="language-julia hljs">ms = [m.match for m in match.((rex,), my_strings)]</code></pre><p>might be replaced with</p><pre><code class="language-julia hljs">ms = [m.match for m in match.((rex,), my_strings) if m !== nothing]</code></pre><p>and return a better-typed result.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../gotchas/">« Precompilation &quot;gotcha&quot;s</a><a class="docs-footer-nextpage" href="../../reference/">Reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Sunday 24 November 2024 16:07">Sunday 24 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre><p>Julia&#39;s <a href="https://en.wikipedia.org/wiki/Constant_folding">constant propagation</a> will ensure that most accesses of those fields will be determined at compile-time, so this simple change robustly fixes many inference problems.</p><h2 id="Fixing-Core.Box"><a class="docs-heading-anchor" href="#Fixing-Core.Box">Fixing <code>Core.Box</code></a><a id="Fixing-Core.Box-1"></a><a class="docs-heading-anchor-permalink" href="#Fixing-Core.Box" title="Permalink"></a></h2><p><a href="https://github.com/JuliaLang/julia/issues/15276">Julia issue 15276</a> is one of the more surprising forms of inference failure; it is the most common cause of a <code>Core.Box</code> annotation. If other variables depend on the <code>Box</code>ed variable, then a single <code>Core.Box</code> can lead to widespread inference problems. For this reason, these are also among the first inference problems you should tackle.</p><p>Read <a href="https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-captured">this explanation of why this happens and what you can do to fix it</a>. If you are directed to find <code>Core.Box</code> inference triggers via <a href="../../reference/#SnoopCompile.suggest"><code>suggest</code></a>, you may need to explore around the call site a bit– the inference trigger may be in the closure itself, but the fix needs to go in the method that creates the closure.</p><p>Use of <code>ascend</code> is highly recommended for fixing <code>Core.Box</code> inference failures.</p><h2 id="Handling-edge-cases"><a class="docs-heading-anchor" href="#Handling-edge-cases">Handling edge cases</a><a id="Handling-edge-cases-1"></a><a class="docs-heading-anchor-permalink" href="#Handling-edge-cases" title="Permalink"></a></h2><p>You can sometimes get invalidations from failing to handle &quot;formal&quot; possibilities. For example, operations with regular expressions might return a <code>Union{Nothing, RegexMatch}</code>. You can sometimes get poor type inference by writing code that fails to take account of the possibility that <code>nothing</code> might be returned. For example, a comprehension</p><pre><code class="language-julia hljs">ms = [m.match for m in match.((rex,), my_strings)]</code></pre><p>might be replaced with</p><pre><code class="language-julia hljs">ms = [m.match for m in match.((rex,), my_strings) if m !== nothing]</code></pre><p>and return a better-typed result.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../gotchas/">« Precompilation &quot;gotcha&quot;s</a><a class="docs-footer-nextpage" href="../../reference/">Reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Tuesday 10 December 2024 11:35">Tuesday 10 December 2024</span>. Using Julia version 1.11.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion dev/explanations/gotchas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Precompilation &quot;gotcha&quot;s · SnoopCompile</title><meta name="title" content="Precompilation &quot;gotcha&quot;s · SnoopCompile"/><meta property="og:title" content="Precompilation &quot;gotcha&quot;s · SnoopCompile"/><meta property="twitter:title" content="Precompilation &quot;gotcha&quot;s · SnoopCompile"/><meta name="description" content="Documentation for SnoopCompile."/><meta property="og:description" content="Documentation for SnoopCompile."/><meta property="twitter:description" content="Documentation for SnoopCompile."/><script data-outdated-warner src="../../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../search_index.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../../">SnoopCompile</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../../">SnoopCompile.jl</a></li><li><span class="tocitem">Basic tutorials</span><ul><li><a class="tocitem" href="../../tutorials/invalidations/">Tutorial on <code>@snoop_invalidations</code></a></li><li><a class="tocitem" href="../../tutorials/snoop_inference/">Tutorial on <code>@snoop_inference</code></a></li><li><a class="tocitem" href="../../tutorials/snoop_llvm/">Tutorial on <code>@snoop_llvm</code></a></li><li><a class="tocitem" href="../../tutorials/pgdsgui/">Profile-guided despecialization</a></li><li><a class="tocitem" href="../../tutorials/jet/">Tutorial on JET integration</a></li></ul></li><li><span class="tocitem">Advanced tutorials</span><ul><li><a class="tocitem" href="../../tutorials/snoop_inference_analysis/">Using <code>@snoop_inference</code> results to improve inferrability</a></li><li><a class="tocitem" href="../../tutorials/snoop_inference_parcel/">Using <code>@snoop_inference</code> to emit manual precompile directives</a></li></ul></li><li><span class="tocitem">Explanations</span><ul><li><a class="tocitem" href="../tools/">Package roles and alternatives</a></li><li class="is-active"><a class="tocitem" href>Precompilation &quot;gotcha&quot;s</a><ul class="internal"><li><a class="tocitem" href="#running-during-pc"><span>Running code during module definition</span></a></li></ul></li><li><a class="tocitem" href="../fixing_inference/">Techniques for fixing inference problems</a></li></ul></li><li><a class="tocitem" href="../../reference/">Reference</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Explanations</a></li><li class="is-active"><a href>Precompilation &quot;gotcha&quot;s</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Precompilation &quot;gotcha&quot;s</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/timholy/SnoopCompile.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/timholy/SnoopCompile.jl/blob/master/docs/src/explanations/gotchas.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="Precompilation-&quot;gotcha&quot;s"><a class="docs-heading-anchor" href="#Precompilation-&quot;gotcha&quot;s">Precompilation &quot;gotcha&quot;s</a><a id="Precompilation-&quot;gotcha&quot;s-1"></a><a class="docs-heading-anchor-permalink" href="#Precompilation-&quot;gotcha&quot;s" title="Permalink"></a></h1><h2 id="running-during-pc"><a class="docs-heading-anchor" href="#running-during-pc">Running code during module definition</a><a id="running-during-pc-1"></a><a class="docs-heading-anchor-permalink" href="#running-during-pc" title="Permalink"></a></h2><p>Suppose you&#39;re working on an astronomy package and your source code has a line</p><pre><code class="nohighlight hljs">const planets = map(makeplanet, [&quot;Mercury&quot;, ...])</code></pre><p>Julia will dutifully create <code>planets</code> and store it in the package&#39;s precompile cache file. This also runs <code>makeplanet</code>, and if this is the first time it gets run, it will compile <code>makeplanet</code>. Assuming that <code>makeplanet</code> is a method defined in the package, the compiled code for <code>makeplanet</code> will be stored in the cache file.</p><p>However, two circumstances can lead to puzzling omissions from the cache files:</p><ul><li>if <code>makeplanet</code> is a method defined in a dependency of your package, it will <em>not</em> be cached in your package. You&#39;d want to add precompilation of <code>makeplanet</code> to the package that creates that method.</li><li>if <code>makeplanet</code> is poorly-infered and uses runtime dispatch, any such callees that are not owned by your package will not be cached. For example, suppose <code>makeplanet</code> ends up calling methods in Base Julia or its standard libraries that are not precompiled into Julia itself: the compiled code for those methods will not be added to the cache file.</li></ul><p>One option to ensure this dependent code gets cached is to create <code>planets</code> inside <code>PrecompileTools.@compile_workload</code>:</p><pre><code class="nohighlight hljs">@compile_workload begin
global planets
const planet = map(makeplanet, [&quot;Mercury&quot;, ...])
end</code></pre><p>Note that your package definition can have multiple <code>@compile_workload</code> blocks.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../tools/">« Package roles and alternatives</a><a class="docs-footer-nextpage" href="../fixing_inference/">Techniques for fixing inference problems »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Sunday 24 November 2024 16:07">Sunday 24 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre><p>Note that your package definition can have multiple <code>@compile_workload</code> blocks.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../tools/">« Package roles and alternatives</a><a class="docs-footer-nextpage" href="../fixing_inference/">Techniques for fixing inference problems »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Tuesday 10 December 2024 11:35">Tuesday 10 December 2024</span>. Using Julia version 1.11.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit f96aaf8

Please sign in to comment.