Hi Edward,
This is possibly unrelated, but the setup seems almost identical to a very similar problem we had in some code, i.e. very long compile times (6+ minutes for 1 module) and excessive memory usage when compiling generic serialization instances for some data structures.
In our case, I also thought that INLINE functions were the cause of the problem, but it turns out they were not. We had a nested data structure, e.g.
> data Foo { fooBar :: !Bar, ... }
with Bar very large (~150 records).
even when we explicitly NOINLINE'd the function that serialized Bar, GHC still created a very large helper function of the form:
> serialize_foo :: Int# -> Int# -> ...
where the arguments were the unboxed fields of the Bar structure, along with the other fields within Foo. It appears that even though the serialization function was NOINLINE'd, it simply created a Builder, and while combining the Builder's ghc saw the full structure. Our serializer uses blaze, but perhaps Binary's builder is similar enough the same thing could happen.
Anyway, in our case the fix was to simply remove the bang pattern from the 'fooBar' record field. Then the serialize_foo function takes a Bar as an argument and serializes that. I'm not entirely sure why compilation takes so much longer otherwise. I've tried dumping the output of each simplifier phase and it clearly gets stuck at a certain point, but I didn't really debug in much detail so I don't recall the details.
If you think this is related, I can investigate more thoroughly.
Cheers,
John L.