Skip to content

Instantly share code, notes, and snippets.

View jberryman's full-sized avatar

Brandon Simmons jberryman

View GitHub Profile
@jberryman
jberryman / ghc_pointer_compression.md
Last active January 11, 2023 22:50
An analysis of potential to save memory residency in ghc RTS using pointer compression

Pointer compression in GHC?

Can compiled Haskell programs benefit from any pointer compression schemes? The goal would be to lower memory residency significantly, while hopefully seeing an improvement in other runtime metrics. V8 Successfully implemented a pointer compression scheme; it seems the challenge for them was recovering the lost performance after the change; After optimizing they did observe single-digit improvements to CPU time.

In the analysis below I'm using

``
$ cmake -B build && cmake --build build --parallel
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/Downloads/graphia/build
gmake[1]: Entering directory '/home/me/Downloads/graphia/build'
gmake[2]: Entering directory '/home/me/Downloads/graphia/build'
gmake[2]: Entering directory '/home/me/Downloads/graphia/build'
gmake[2]: Entering directory '/home/me/Downloads/graphia/build'
gmake[2]: Leaving directory '/home/me/Downloads/graphia/build'
@jberryman
jberryman / hasktags-gutentags-shim.sh
Created July 8, 2019 14:20
Using hasktags with vim-gutentags for Haskell ctags
#!/bin/bash
set -euo pipefail
#
# A hack to get hasktags working with vim-gutentags
#
# In vimrc:
#
# let g:gutentags_project_info = []
# call add(g:gutentags_project_info, {'type': 'haskell', 'file': 'stack.yaml'})
# call add(g:gutentags_project_info, {'type': 'haskell', 'glob': '*.cabal'})
@jberryman
jberryman / repack.zsh
Created May 23, 2019 23:14
Unpack and repack a library archive file, allowing mapping a script over each contained object
#!/usr/bin/zsh
# Not portable, sorry...
set -e
set -o pipefail
# set -x
# Change to your command. Below we assume that this:
# - deletes (or replaces) the original file
# - the new/replacement object file must be in the same directory as the source file (need not be same name though)
COMMAND="ls -l"
@jberryman
jberryman / canvas2png.js
Created April 30, 2012 19:19
A jQuery one-liner for converting all html5 canvas elements in the DOM to PNGs
$('canvas').each(function(i,e){ var img = e.toDataURL("image/png"); $(e).replaceWith( $('<img src="'+img+'"/>').attr({width: $(e).attr("width"), height: $(e).attr("height"), style: $(e).attr("style") }) ) });
@jberryman
jberryman / med.hs
Created March 21, 2012 16:03
an optimized haskell Levenshtein distance, using the vector library
-- an optimized minimum edit distance function, using the 'vector' library.
-- By making careful use of the stream-fusing functions in Vector, we can
-- write an implementation that looks like idiomatic list-processing code
-- but runs like tight mutable array code.
import qualified Data.Vector.Unboxed.Safe as V
-- we use suffixes _W, _SW, etc. to indicate the cell to the west, southwest,
-- and so on in the more traditional matrix-based approach.
med :: String -> String -> Int