Skip to content

Manual eta expansion leads to orders of magnitude less allocations

While working on deterministic free variable computation I run into some performance issues. I narrowed it down to code that when eta expanded performed less allocations.

I ended up writing a benchmark and for large examples the eta expanded versions performs orders of magnitude less allocations.

The results of my test:

EtaExpanded test3
      50,450,112 bytes allocated in the heap
real 0.89

EtaReduced test3
   3,661,740,240 bytes allocated in the heap
real 3.66

The whole source is here: https://github.com/niteria/deterministic-fvs, I'm also attaching the two interesting implementations.

I experimented with it a little and GHC eta-expanded when I didn't have mutually recursive bindings.

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information