Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how to use section #99

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# SOURCE_DATE_EPOCH = $(shell git log -1 --format=%ct)
SOURCE_DATE_EPOCH = $(shell git log -1 --format=%ct)

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
4 changes: 4 additions & 0 deletions hoh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pkgs.stdenv.mkDerivation {
src = ./.;
propagatedBuildInputs = pythonInputs ++ nonPythonInputs;

preBuild = ''
SOURCE_DATE_EPOCH="$(${pkgs.coreutils}/bin/date '+%s')"
'';

buildPhase = ''
runHook preBuild
make ${target} SPHINXOPTS="-W"
Expand Down
4 changes: 3 additions & 1 deletion src/Measurement_Observation/Heap_Third/cachegrind.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.. _Cachegrind:
.. _Cachegrind Chapter:

:lightgrey:`Using Cachegrind`
=============================

`TODO <https://github.com/haskellfoundation/hs-opt-handbook.github.io/issues/10>`_
2 changes: 1 addition & 1 deletion src/Measurement_Observation/Measurement_Libs/weigh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ useful to confirm that a data structure or function has the memory performance
you anticipate it to have at *runtime*. ``Weigh`` is easy to setup and
non-invasive; requiring no changes to source code. Thus, it is a good *initial*
tool to use before trying more advanced methods with higher setup costs, such as
:ref:`Cachegrind <Cachegrind>`.
:ref:`Cachegrind <Cachegrind Chapter>`.


Requirements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. Perf
.. _Perf Chapter:

:lightgrey:`The perf utility`
=============================
Expand Down
32 changes: 19 additions & 13 deletions src/Preliminaries/how_to_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Purpose
-------

This book is written as a handbook for the intrepid Haskell developer. It
attempts to make clear aspects of the GHC-based Haskell so that performance
attempts to make clear aspects of GHC-based Haskell so that performance
optimizations and recommendations are actionable, rather than mysterious
invocations whispered around the internet.

Expand All @@ -17,7 +17,7 @@ Intended Audience
The Haskell Optimization Handbook is intended for developers using Haskell in
their day to day life for money or pleasure. It assumes the audience is
proficient with pure functional programming concepts, such as recursion, purity,
higher-ordered functions functors, applicative functors, monads et cetera., and
higher-ordered functions, functors, applicative functors, monads et cetera., and
the basics of the Haskell ecosystem, such as using cabal or stack to compile and
run a project.

Expand Down Expand Up @@ -65,18 +65,20 @@ handbook. Thus, the book is not meant to be read in a linear order. Instead, one
should pick and choose which chapter to read next based on their needs because
*the book assumes you have a problem that needs solving*.

There are two general sections; both are ordered from the least time consuming
to most time consuming topics. The first section, Part 1, aids the developer in
identifying performance issues in their own code. Part 1 is primarily concerned
with measurement, observation, repeatability and testing, but also includes
methods of *direct observation* such as inspecting and understanding the
``Core`` and ``Stg`` languages.
There are two parts: Part 1, focuses on measurement, profiling and observation
of Haskell programs. This part is ordered from the bottom-up; it begins with
tools and probes that are language agnostic and close to the machine, such as
:ref:`Perf <Perf Chapter>` and :ref:`Cachegrind <Cachegrind Chapter>`, then
proceeds through each `intermediate representation
<https://en.wikipedia.org/wiki/Intermediate_representation#:~:text=An%20intermediate%20representation%20(IR)%20is,such%20as%20optimization%20and%20translation.>`_
(IR) describing the tools, probes, and information available at each IR.

The second section, Part 2, aids the developer in optimizing their code. It is
Part 2, provides an ordered sequence of techniques to optimize code. It is
ordered from the easiest methods, such as choosing the right libraries; to the
hardest methods, such as exploiting ``backpack`` for fine-grained
:term:`Unboxed` data types or exploiting :term:`Levity Polymorphism` to control
the runtime representation of a data type.
hardest and more invasive methods, such as exploiting :ref:`Backpack <Backpack
Chapter>` for fine-grained :term:`Unboxed` data types or exploiting
:term:`Levity Polymorphism` to control the runtime representation of a data
type.


Goals
Expand Down Expand Up @@ -111,6 +113,10 @@ HOH does not have:
a given platform.
#. Descriptions, analyses and explanations of functional algorithms or data
structures. Content will instead be "Try unordered-containers if you have
foo, bar, baz", rather than "This is what a bankers queue or HAMT is ...".
this or that set of constraints", rather than "This is what a banker's queue
[#]_ or `HAMT <https://en.wikipedia.org/wiki/Hash_array_mapped_trie>`_ is
...".
#. A monad or monad transformer tutorial. This is assumed knowledge in the
audience.

.. [#] See :cite:t:`okasaki`, page 23.