Skip to content

Draft: use OsPath in ModLocation

Torsten Schmits requested to merge wip/torsten.schmits/modlocation-ospath into master

Reproducer:

#!/usr/bin/env bash

cd $(dirname $0)

mod_count=3000

if [[ ! -f leak-string-concat/Mod$mod_count.hs ]]
then
  echo -n 'Creating test modules...'
  mkdir -p leak-string-concat
  for i in $(seq 1 $mod_count)
  do
    echo "module Mod$i where
fun$i = ()
" > leak-string-concat/Mod$i.hs
  done
  echo ' done.'
fi

# With the long path, `++` allocates about 90MB when loading 3000 modules on the command line.
# With the short path, it's about 16MB.
outdir=/out
outdir=/paaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaath

echo "Path length: ${#outdir}"

cd leak-string-concat

ghc --interactive \
  -odir $outdir \
  -hidir $outdir \
  -hiedir $outdir \
  +RTS -l -hc -RTS \
  $(for i in $(seq 1 $mod_count); do echo -n "Mod${i} "; done) \
  <<< ':quit'

eventlog2html ghc.eventlog -o leak.html

echo "Graph: $PWD/leak.html"

Before:

image.png

After:

image.png

Edited by Torsten Schmits

Merge request reports