Skip to content

Commit

Permalink
Deploying to deploy from @ 126d633 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
doyougnu committed Jun 24, 2022
1 parent 2f0477e commit fe1a311
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: d8862bc609545a59cb0d75fc5dbd55e6
config: 658c1c056ff9c095d520e8ee5f5c269f
tags: 645f666f9bcd5a90fca523b33c5a78b7
6 changes: 6 additions & 0 deletions _sources/contents.rst.txt
Expand Up @@ -22,3 +22,9 @@ Indices and tables
* :ref:`genindex`
* :ref:`search`
* :ref:`glossary`


Bibliography
============

.. bibliography::
37 changes: 32 additions & 5 deletions _sources/src/Preliminaries/what_makes_fast_hs.rst.txt
Expand Up @@ -142,10 +142,21 @@ Excessive Pointer Chasing
What is Excessive Pointer Chasing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Excessive pointer chasing is the enemy of any high performance Haskell program,
and presents itself in various forms; most of which Haskeller's are familiar
with to some degree. These include memory leaks during folds (strict and lazy),
for example [#]_:
Excessive pointer chasing is a form of superfluous computation; our program is
doing more work than it needs in order to compute the result. It occurs anytime
our programs dereference a pointer to retrieve a value instead of just
referencing the value itself, thereby creating an extra layer of unnecessary
indirection. In Haskell programs this most often occurs when we write programs
without thinking about their memory representation; and especially around
laziness. As such, most of these instances are well known and have floated
around the community for some time.


How does excessive pointer chasing slow down runtime performance?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The classic example of excessive pointer chasing is memory leaks that result
from folds that are overly lazy, for example [#]_:

.. code-block:: haskell
:caption: mean, calculated with a lazy left fold
Expand Down Expand Up @@ -219,16 +230,32 @@ that each ``Counter`` holds a pointer to an ``Int`` on the heap *not* a pointer
to an ``Int`` directly. We can instruct GHC remove the heap indirection with the
`unpack
<https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/pragmas.html?highlight=unpack#unpack-pragma>`_
pragma and a bang pattern:

.. code-block:: haskell
data Counter = Counter {-# UNPACK -#} !Int

This pragma instructs GHC to store the contents of ``Int`` directly in the
``Counter`` constructor, rather than storing a pointer to an ``Int`` on the heap
in the constructor. We'll return to these fixes in the :ref:`Excessive Pointer
Chasing` section.

.. _canonical-closure-alloc:

Excessive Closure Allocation
----------------------------

What is Excessive Closure Allocation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xcessive :term:`Closure` allocation is :cite:p:`GHCInliner` and :cite:t:`GHCInliner`



How does Excessive Closure Allocation slow down runtime performance
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. _canonical-domain-modeling:

Poor Domain Modeling
Expand Down
8 changes: 4 additions & 4 deletions _sources/src/glossary.rst.txt
Expand Up @@ -16,20 +16,20 @@ Glossary
<https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form>`_
for more.

Boxed Value
Boxed : Levity
A Boxed value is a value that is represented by a pointer to the heap.

Unboxed Value
Unboxed : Levity
An UnBoxed value is a value that is represented by the value itself.
UnBoxed values therefore cannot be lazy, like boxed values.

Lifted Type
Lifted : Levity
A Lifted type is a type that contains the value :math:`\bot`;
which represents non-terminating computation. For example, the ``Bool``
type is a set with three values: ``True``, ``False``, and :math:`\bot`.
Therefore ``Bool`` is a Lifted type.

Unlifted Type
Unlifted : Levity
An Unlifted type is a type where :math:`\bot` *is not* an element of that type.

Thunk
Expand Down
17 changes: 16 additions & 1 deletion contents.html
Expand Up @@ -204,9 +204,14 @@ <h1>Welcome to Haskell Optimization Handbook<a class="headerlink" href="#welcome
</li>
<li class="toctree-l2"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#excessive-pointer-chasing">Excessive Pointer Chasing</a><ul>
<li class="toctree-l3"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#what-is-excessive-pointer-chasing">What is Excessive Pointer Chasing</a></li>
<li class="toctree-l3"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#how-does-excessive-pointer-chasing-slow-down-runtime-performance">How does excessive pointer chasing slow down runtime performance?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#excessive-closure-allocation">Excessive Closure Allocation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#what-is-excessive-closure-allocation">What is Excessive Closure Allocation</a></li>
<li class="toctree-l3"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#how-does-excessive-closure-allocation-slow-down-runtime-performance">How does Excessive Closure Allocation slow down runtime performance</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#excessive-closure-allocation">Excessive Closure Allocation</a></li>
<li class="toctree-l2"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#poor-domain-modeling">Poor Domain Modeling</a></li>
<li class="toctree-l2"><a class="reference internal" href="src/Preliminaries/what_makes_fast_hs.html#references">References</a></li>
</ul>
Expand All @@ -221,6 +226,16 @@ <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Pe
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
<li><p><a class="reference internal" href="src/glossary.html#glossary"><span class="std std-ref">Glossary</span></a></p></li>
</ul>
</section>
<section id="bibliography">
<h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to this headline"></a></h1>
<div class="docutils container" id="id1">
<div class="citation" id="id2" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<p>Simon Peyton Jones and Simon Marlow. Secrets of the glasgow haskell compiler inliner. <em>J. Funct. Program.</em>, 12(5):393–434, jul 2002. URL: <a class="reference external" href="https://doi.org/10.1017/S0956796802004331">https://doi.org/10.1017/S0956796802004331</a>, <a class="reference external" href="https://doi.org/10.1017/S0956796802004331">doi:10.1017/S0956796802004331</a>.</p>
</div>
</div>
</div>
</section>


Expand Down
36 changes: 11 additions & 25 deletions genindex.html
Expand Up @@ -180,34 +180,32 @@
<h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#B"><strong>B</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#L"><strong>L</strong></a>
<a href="#C"><strong>C</strong></a>
| <a href="#Levity"><strong>Levity</strong></a>
| <a href="#Normal Forms"><strong>Normal Forms</strong></a>
| <a href="#T"><strong>T</strong></a>
| <a href="#U"><strong>U</strong></a>

</div>
<h2 id="B">B</h2>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="src/glossary.html#term-Boxed-Value"><strong>Boxed Value</strong></a>
<li><a href="src/glossary.html#term-Closure"><strong>Closure</strong></a>
</li>
</ul></td>
</tr></table>

<h2 id="C">C</h2>
<h2 id="Levity">Levity</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="src/glossary.html#term-Closure"><strong>Closure</strong></a>
<li><a href="src/glossary.html#term-Boxed"><strong>Boxed</strong></a>
</li>
<li><a href="src/glossary.html#term-Lifted"><strong>Lifted</strong></a>
</li>
</ul></td>
</tr></table>

<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="src/glossary.html#term-Lifted-Type"><strong>Lifted Type</strong></a>
<li><a href="src/glossary.html#term-Unboxed"><strong>Unboxed</strong></a>
</li>
<li><a href="src/glossary.html#term-Unlifted"><strong>Unlifted</strong></a>
</li>
</ul></td>
</tr></table>
Expand All @@ -228,18 +226,6 @@ <h2 id="T">T</h2>
</ul></td>
</tr></table>

<h2 id="U">U</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="src/glossary.html#term-Unboxed-Value"><strong>Unboxed Value</strong></a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="src/glossary.html#term-Unlifted-Type"><strong>Unlifted Type</strong></a>
</li>
</ul></td>
</tr></table>



</div>
Expand Down
Binary file modified objects.inv
Binary file not shown.

0 comments on commit fe1a311

Please sign in to comment.