[Haskell] Profiling Feedback to Optimize Memoization Caching

Tom Hawkins tomahawkins at gmail.com
Fri Feb 23 15:00:41 EST 2007


After programming in Haskell for about a year now, I have found it
allows we to quickly develop initial programs; thanks to the
expressiveness of the language and type system.  But due to
performance concerns, I typically have to restructure the initial
program, guided by profiling, to reduce time or memory consumption.
Many times, this refactoring process helps illuminate a better
strategic approach to the program.  But very often, only a few
inefficient functions need to be equipped with memoization.

I can certainly speed up these functions with explicit memoization,
usually by threading a Map or Set through the recursive decent.  But
doing so always degrades the legibility of the original function.  Are
there any tools to automate this process, so as not to clutter the
code with "Have-I-been-here-before?" tests and supporting data
structures?  To what extent do Haskell compilers use memoization?  Is
there any way to guide automatic memoization?

Also, do any compilers use profiling data to enable or re-adjust
memoization caches of the worst offenders?  In ECAD, we would call
this an in-place optimization (IPO).

-Tom


More information about the Haskell mailing list