RE: [Haskell-cafe] Re: Non-technical Haskell question

On 06 December 2004 14:39, John Goerzen wrote:
On 2004-12-06, Keith Wansbrough
wrote: The static vs dynamic linking question has been discussed many times. The summary is: GHC is a highly-optimising compiler, and the binary interface _necessarily_ changes with every minor revision (even patchlevel revision) of the compiler and each library. So you can't
We already have a way to deal with that using sonames. It's not that hard, and is routinely used.
BTW, is this a problem even if no -O options are given when building a library?
Certainly it's possible to get a more stable library ABI by not compiling with -O. The question is, do you want to? You certainly don't want to do this for the Prelude and other essential libraries. For example, GHC wouldn't be able to see the definition of 'instance Num Int', and hence (x + 1 :: Int) would be compiled as (+) dNumInt x (I# 1) instead of (after inlining (+) and dNumInt): case x of I# x# -> I# (x# +# 1#) which can then be further optimised: the compiler can see that it is strict in x, so might be able to unbox x, and so on. This is pretty essential to get any kind of reasonable performance, but it might be less important for higher-level libraries, as long as you don't have any important monads that need to be inlined, for example. Dynamic linking is (almost) a separate issue. GHC 6.4 will have some support for dynamic linking in the native code generator thanks to Wolfgang Thaller, but it needs someone to push it the final mile on x86/Linux and Windows. Dynamically linked libraries will work (albeit slightly slower than statically linked ones), but you still have the versioning issue. Since libraries are getting really big nowadays (eg. wxHaskell) making dynamic linking work even without worrying about versioning seems like it would be worthwhile. Cheers, Simon

Simon Marlow wrote:
Dynamic linking is (almost) a separate issue. GHC 6.4 will have some support for dynamic linking in the native code generator thanks to Wolfgang Thaller, but it needs someone to push it the final mile on x86/Linux and Windows. Dynamically linked libraries will work (albeit slightly slower than statically linked ones), but you still have the versioning issue. Yay! :) Dynamically linked libraries are slower than statically linked ones in just about every implementation I know of. I don't care.
-- Lennart

On Tue, Dec 07, 2004 at 12:43:27PM +0100, Lennart Augustsson wrote:
slightly slower than statically linked ones), but you still have the versioning issue. Yay! :) Dynamically linked libraries are slower than statically linked ones in just about every implementation I know of. I don't care.
From memory, an additional register is consumed when using dynamic
My understanding was that this was mostly limited to x86 platforms. libraries on that platform, and due to its already limited number of registers, that can mean a hit. AFAIK, these problems are negligible on many other platforms. This is just folk knowledge from a few years ago, so please correct me if I'm wrong. -- John

John Goerzen wrote:
On Tue, Dec 07, 2004 at 12:43:27PM +0100, Lennart Augustsson wrote:
slightly slower than statically linked ones), but you still have the versioning issue.
Yay! :) Dynamically linked libraries are slower than statically linked ones in just about every implementation I know of. I don't care.
From memory, an additional register is consumed when using dynamic
My understanding was that this was mostly limited to x86 platforms. libraries on that platform, and due to its already limited number of registers, that can mean a hit.
AFAIK, these problems are negligible on many other platforms.
This is just folk knowledge from a few years ago, so please correct me if I'm wrong.
If your data is position independent then you need more complex address calculations (i.e., an extra addition of the base register). Sometimes this is available as an addressing mode, but sometimes not. So it has some impact in addition to using an extra register. Furthermore, every function call to a dynamically linked function (typically) uses an indirection, so you get a small hit there as well. But it only adds up to a few percent, so no sweat. :) -- Lennart

John Goerzen wrote:
On Tue, Dec 07, 2004 at 12:43:27PM +0100, Lennart Augustsson wrote:
Yay! :) Dynamically linked libraries are slower than statically linked ones in just about every implementation I know of. I don't care.
My understanding was that this was mostly limited to x86 platforms. From memory, an additional register is consumed when using dynamic libraries on that platform, and due to its already limited number of registers, that can mean a hit.
I'm not sure what this would be unless it's the frame pointer (ebp). I don't know of any reason you can't omit the frame pointer in dynamically linked applications, though, unless one of the DLLs you're linking with wants to unwind your stack, in which case you'd have the same problem linking statically. Dynamic linking has other costs. If the library is relocated, you have to use a jump table (slows down every call) or patch all calls directly (interferes with demand paging). Code cache locality is reduced because the linker can't discard unused library functions. And there are problems with inlining. :-) -- Ben
participants (4)
-
Ben Rudiak-Gould
-
John Goerzen
-
Lennart Augustsson
-
Simon Marlow