28 Aug 2012 18:44
A first glimps on the {-# NOUPDATE #-} pragma
Joachim Breitner <breitner <at> kit.edu>
2012-08-28 16:44:29 GMT
2012-08-28 16:44:29 GMT
Dear GHC users, I am experimenting with ways to /prevent/ sharing in Haskell, e.g. to avoid space leaks or to speed up evaluation. A first attempt was to duplicate closures on the heap to preserve the original one, see http://arxiv.org/abs/1207.2017 for a detailed description and information on the prototype implementation; no GHC patching required for that. Currently I am trying a different angle: Simply avoid generating the code that will update a closure after its evaluation; hence the closure stays a thunk and will happily re-evaluate the next time it is used. Here is a classical example. Take this function (it is basically [f..t] but with a fixed type and no risk of existing rules firing): myenum :: Int -> Int -> [Int] myenum f t = if f <= t then f : myenum (f + 1) t else [] and this example where sharing hurts performance badly: upd_upd n = let l = myenum 0 n in last l + head l The problem is that during the evaluation of "last l", the list is live and needs to be kept in memory, although in this case, re-evaluating l for "head l" would be cheaper. If n is 50000000, then this takes 3845ms(Continue reading)
RSS Feed