MasterMastic
MasterMastic

Reputation: 21306

Could dynamic linking hurt inlining thus performance in GHC?

It's no secret that inlining is what's enabling a lot of the sophisticated optimizations GHC can carry out. If I link a library dynamically (and get an actual dll/so file out of it), could GHC still inline where it would have, as if the link was static, and depend on the dll for the rest? or do I actually get less optimizations?

Upvotes: 3

Views: 166

Answers (1)

liyang
liyang

Reputation: 550

When a function is marked as either {-# INLINE #-} or {-# INLINEABLE #-}—or if GHC considers it Cheap Enough™—the entire unmangled RHS is included in the interface .hi file alongside the compiled .o object. As far as I'm aware.

So no, I'm pretty sure it wouldn't hurt inlining. Dynamic linking would affect code locality though, but that's microöptimisation compared to the inlining aspect you're concerned about.

Caveat: I have not actually benchmarked anything.

Upvotes: 3

Related Questions