Demo programs of the presentation
Abstract
The external STG interpreter is a from scratch implementation of the STG machine in Haskell.
Currently it supports almost all GHC primops and RTS features.
It can run real world Haskell programs that were compiled with GHC Whole Program Compiler (GHC-WPC).
GHC-WPC is a GHC fork that exports the whole program STG IR.
The external STG interpreter is an excellent tool to study the runtime behaviour of Haskell programs, i.e. it can run/interpret GHC or Pandoc.
The implementation of the interpreter is in plain simple Haskell, so it makes compiler backend and tooling development approachable for everyone.
It already has a programmable debugger which supports step-by-step evaluation, breakpoints and execution region based inspection.
It also can export the whole program memory state and call-graphs to files for further investigation.
These features make it easy to find a memory leak or to identify a performance bottleneck in a large real world Haskell application.
youtube video
youtube video with fullscreen view
slides
You'll need 15GB of free space in total
- Watch the presentation
- Clone this repository:
git clone --recursive [email protected]:grin-compiler/ext-stg-interpreter-presentation-demos.git
- Install External STG Interpreter
see: https://github.com/grin-compiler/ghc-whole-program-compiler-project/tree/master/external-stg-interpreter#example-usage
cd ghc-whole-program-compiler-project/external-stg-interpreter stack install
- Install GHC-WPC
see: https://github.com/grin-compiler/ghc-whole-program-compiler-project#usage
cd ghc-whole-program-compiler-project (cd mod-pak ; stack install) cd ghc-wpc ./boot ./configure hadrian/build-stack -j
- Fix paths in the build scripts and stack.yaml files.
i.e. indemo-02-minigame/stack.yaml
fix this path to point to your ghc-wpc:# use local GHC (for development) system-ghc: true extra-path: - /home/csaba/haskell/grin-compiler/ghc-whole-program-compiler-project/ghc-wpc/_build/stage1/bin
- Compile
unzip
with zstd support (optional)
You'll need this to browse the content of.modpak
and.fullpak
files manually.cd unzip-zstd make -f unix/Makefile generic_zstd cp unzip $HOME/.local/bin
- Reproduce the demo part of the presentation
https://youtu.be/wt6iCgYmVGA?t=2054
If you have questions or if you have issues with the build steps please open an issue in this repo.
You'll need 15GB of free space in total
This is an option if you're familiar with docker and don't want to build a compiler.
The container comes with ghc-wpc and ext-stg-interpreter build and the demo files are
available in /root/
.
- Watch the presentation
- (optional) disable access control for X,
this allows you to run X applications from within the container,
but keep in mind this makes your system slightly less secure.
xhost +
- Run the container, it'll fetch it from dockerhub if not found:
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -it jappie/ext-stg-demo
- Reproduce the demo part of the presentation https://youtu.be/wt6iCgYmVGA?t=2054
-
Watch the presentation
-
Clone this repository:
git clone --recursive [email protected]:grin-compiler/ext-stg-interpreter-presentation-demos.git
-
cd ext-stg-interpreter-presentation-demos git submodule update --init --recursive docker build . xhost + docker run -v /tmp/.X11-unix:/tmp/.X11-unix -it whateverhash bash
-
Reproduce the demo part of the presentation
https://youtu.be/wt6iCgYmVGA?t=2054
- note that the compiler lives in /root/ghc-whole-program-compiler-project/ghc-wpc/_build/stage1/bin/ghc
- you can install additional programs with apt