Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: GHC-generated executables size (Henk-Jan van Tuyl)
2. Re: GHC-generated executables size (Daniel Fischer)
3. Re: GHC-generated executables size (.)
4. Re: GHC-generated executables size (Daniel Fischer)
5. Re: Newbie performance question (Daniel Fischer)
6. Re: A problem with a simple csv file parser (Andy Elvey)
7. Re: GHC-generated executables size (.)
8. Re: GHC-generated executables size (Daniel Fischer)
9. GHC-generated executables size (Christian Gosch)
----------------------------------------------------------------------
Message: 1
Date: Sat, 16 Oct 2010 20:44:38 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: [email protected], "." <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Sat, 16 Oct 2010 12:26:00 +0200, . <[email protected]> wrote:
> Hi,
> I was playing around with ghc again, and I was wondering what makes
> the executables so large and how I could make them smaller (strip works,
> but is there anything more I can do?)
UPX [0] compresses executables and DLLs quite well (use it after "strip"
for the best results).
Regards,
Henk-Jan van Tuyl
[0] http://upx.sourceforge.net/
--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--
------------------------------
Message: 2
Date: Sat, 16 Oct 2010 21:09:56 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: "." <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Saturday 16 October 2010 15:03:52, . wrote:
> Hi Daniel,
> thanks for the explanations.
> I have tried reinstalling with
> cabal --reinstall gtk,
> having set
> split-objs: True
> in ~/.cabal/config before.
>
> However, the compile yielded a single .o file again,
Yes, there's the single .o file for the package, the question is, what's in
the archive (libHSxxx.a). Rule of thumb, if it's more than twice as large
as the HSxxx.o, it contains the split object files (you can verify by
looking at it with nm).
> and recompiling and re-linking my little program does not change
> its size ...
Possibly the packages have been built with -spilt-objs originally, or your
GHC doesn't support split-objs, in either case, sorry for the inconvenience
:-/
gtk contains apparently hundreds of thousands of modules, so it may be the
module-initialisation functions. Quick test:
$ nm yourexecutable | grep stginit | wc -l
> Any other idea what I might be doing wrong?
Nothing, probably.
What ghc version are you using, on which platform (OS, arch), which
packages does your executable need?
> Also, I saw in the ghc documentatio about -split-objs that one should
> only use it "if you know exactly what you're doing".
> Do you know what the caveats are?
Doesn't work on all platforms (Sparc seems to have some problems iirc),
slower compile times. That's what I'm aware of.
>
> Thanks again,
> Christian
------------------------------
Message: 3
Date: Sat, 16 Oct 2010 21:32:27 +0200
From: "." <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <1287257547.9018.29.ca...@eddy>
Content-Type: text/plain; charset="UTF-8"
On Sat, 2010-10-16 at 21:09 +0200, Daniel Fischer wrote:
> On Saturday 16 October 2010 15:03:52, . wrote:
> > Hi Daniel,
> > thanks for the explanations.
> > I have tried reinstalling with
> > cabal --reinstall gtk,
> > having set
> > split-objs: True
> > in ~/.cabal/config before.
> >
> > However, the compile yielded a single .o file again,
>
> Yes, there's the single .o file for the package, the question is, what's in
> the archive (libHSxxx.a). Rule of thumb, if it's more than twice as large
> as the HSxxx.o, it contains the split object files (you can verify by
> looking at it with nm).
Ah .. ok, stupid me ;) the archive is more than twice the size, and ar
tells me about a lot of object files inside it. So compiling with
-split-objs appears to have worked out.
I have seen, however, that I have 2 versions of gtk (0.11.2 and 0.11.0)
on the system. I will try to find out which one was actually used when I
called "ghc --make guiMain"; how would I go about that?
> > and recompiling and re-linking my little program does not change
> > its size ...
>
> Possibly the packages have been built with -spilt-objs originally, or your
> GHC doesn't support split-objs, in either case, sorry for the inconvenience
> :-/
>
> gtk contains apparently hundreds of thousands of modules, so it may be the
> module-initialisation functions. Quick test:
>
> $ nm yourexecutable | grep stginit | wc -l
I tried that, there are almost 900 matches.
> > Any other idea what I might be doing wrong?
>
> Nothing, probably.
>
> What ghc version are you using, on which platform (OS, arch), which
> packages does your executable need?
I am using Ubuntu 10.10, ghc 6.12.1, on a 4-core AMD Phenom.
The program I am compiling needs these packages:
gtk, Text.Parsec, Time, Database.HDBC.Sqlite3, Locale,
Data.ByteString.Lazy.
--Christian
------------------------------
Message: 4
Date: Sat, 16 Oct 2010 22:18:06 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: "." <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Saturday 16 October 2010 21:32:27, . wrote:
> I have seen, however, that I have 2 versions of gtk (0.11.2 and 0.11.0)
> on the system. I will try to find out which one was actually used when I
> called "ghc --make guiMain"; how would I go about that?
>
Normally, ghc picks the later version. When compiling, you can see which
version is used by giving the appropriate verbosity flag (-v2 or greater).
After the fact, the only way I know is
$ nm executable | grep stginit_gtk | more (or less)
and then you'll see the z-encoded package version, lines like
080ca5dc T __stginit_gtkzm0zi11zi2_Stuff
for gtk-0.11.2.
> > > and recompiling and re-linking my little program does not change
> > > its size ...
> >
> > Possibly the packages have been built with -spilt-objs originally, or
> > your GHC doesn't support split-objs, in either case, sorry for the
> > inconvenience
> >
> > :-/
> >
> > gtk contains apparently hundreds of thousands of modules, so it may be
> > the module-initialisation functions. Quick test:
> >
> > $ nm yourexecutable | grep stginit | wc -l
>
> I tried that, there are almost 900 matches.
>
Hm, shouldn't nearly take you to 20M.
> > > Any other idea what I might be doing wrong?
> >
> > Nothing, probably.
> >
> > What ghc version are you using, on which platform (OS, arch), which
> > packages does your executable need?
>
> I am using Ubuntu 10.10, ghc 6.12.1, on a 4-core AMD Phenom.
> The program I am compiling needs these packages:
> gtk, Text.Parsec, Time, Database.HDBC.Sqlite3, Locale,
> Data.ByteString.Lazy.
>
No obvious suspect.
Depending on how curious you are, you could split off small sub-programmes
to see what's taking a lot of space. But that's going to be tedious.
You could ask on IRC (#haskell) whether anybody knows about huge
executables with gtk, or on haskell-cafe, on the gtk2hs mailing list, or
you could open a ticket at http://hackage.haskell.org/trac/gtk2hs/ or
http://hackage.haskell.org/trac/ghc/newticket?type=bug whichever you
consider more likely to be responsible (you needn't create an account for
either bug-tracker, both have guest accounts with the guest password in
plain view - though you may need to look for it a bit). But first ask
elsewhere.
>
> --Christian
------------------------------
Message: 5
Date: Sat, 16 Oct 2010 22:44:33 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Newbie performance question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Saturday 16 October 2010 08:18:39, Jordan Ellis wrote:
> I have a quick follow-up question: With optimization enabled, will a
> value be shared between recursive function calls? For example, in the
> following:
> myRecursiveFunction 0 m = []
> myRecursiveFunction n m = m : myRecursiveFunction (n - 1) m
> ...will 'm' be calculated 'n' times, or just once? Thanks.
Here, you don't have two equal expressions, the m refers to the same entity
in both appearances on the RHS. It's not guaranteed by the language
definition, but every decent implementation will evaluate m only once (all
occurrences are pointers to the same heap object, so you get n pointers,
but only one pointed-to value).
With or without optimisation.
That's of course bad if m is large and you need a large part of it once at
the beginning but only small parts afterwards, e.g.
mapM_ (print . length) $ zipWith take (iterate (`quot` 2) 20000000) $
myRec n [1 .. k]
To prevent that, if you don't want it, you have to jump through a couple of
hoops.
------------------------------
Message: 6
Date: Sun, 17 Oct 2010 11:58:30 +1300
From: Andy Elvey <[email protected]>
Subject: Re: [Haskell-beginners] A problem with a simple csv file
parser
To: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Hi again all -
Thanks very much for that Daniel (and thanks too to Aleksandar!). Your
replies have been very helpful!
Everything's now working with the parser!
Parsec is truly a great library to use. It really does make parsing a
joy..... :)
Bye for now, and thanks again -
- Andy
Daniel Fischer wrote:
> On Saturday 16 October 2010 10:59:10, Aleksandar Dimitrov wrote:
>
>> . GHC (the compiler itself) on the other hand, will
>> just not produce a binary as long as your module name isn't "Main."
>>
>
> If your module name isn't Main, you have to tell GHC what to regard as the
> main module by passing the "-main-is" flag on the command line
>
> $ ghc -O2 --make -main-is Test -o Test Test.hs
>
> works. And your main function may also have a different name, e.g.
>
> $ ghc -O2 --make -main-is MultiMain.main2 -o main2 MultiMain.hs
>
> with
>
> module MultiMain where
>
> main1 :: IO ()
> main1 = putStrLn "main1"
>
> main2 :: IO ()
> main2 = putStrLn "You chose main two."
>
>
>
------------------------------
Message: 7
Date: Sun, 17 Oct 2010 13:10:32 +0200
From: "." <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <1287313832.3188.1.ca...@eddy>
Content-Type: text/plain; charset="UTF-8"
Ok, after recompiling gtk again and hiding gtk-0.11.0 (which was still
monolithic), it worked. The executable is now, after stripping, a mere
2.7MB in size (which is still large for what it does, but much better).
Thanks to all who answered for your help!
Christian
On Sat, 2010-10-16 at 22:18 +0200, Daniel Fischer wrote:
> On Saturday 16 October 2010 21:32:27, . wrote:
> > I have seen, however, that I have 2 versions of gtk (0.11.2 and 0.11.0)
> > on the system. I will try to find out which one was actually used when I
> > called "ghc --make guiMain"; how would I go about that?
> >
>
> Normally, ghc picks the later version. When compiling, you can see which
> version is used by giving the appropriate verbosity flag (-v2 or greater).
> After the fact, the only way I know is
>
> $ nm executable | grep stginit_gtk | more (or less)
>
> and then you'll see the z-encoded package version, lines like
>
> 080ca5dc T __stginit_gtkzm0zi11zi2_Stuff
>
> for gtk-0.11.2.
>
> > > > and recompiling and re-linking my little program does not change
> > > > its size ...
> > >
> > > Possibly the packages have been built with -spilt-objs originally, or
> > > your GHC doesn't support split-objs, in either case, sorry for the
> > > inconvenience
> > >
> > > :-/
> > >
> > > gtk contains apparently hundreds of thousands of modules, so it may be
> > > the module-initialisation functions. Quick test:
> > >
> > > $ nm yourexecutable | grep stginit | wc -l
> >
> > I tried that, there are almost 900 matches.
> >
>
> Hm, shouldn't nearly take you to 20M.
>
> > > > Any other idea what I might be doing wrong?
> > >
> > > Nothing, probably.
> > >
> > > What ghc version are you using, on which platform (OS, arch), which
> > > packages does your executable need?
> >
> > I am using Ubuntu 10.10, ghc 6.12.1, on a 4-core AMD Phenom.
> > The program I am compiling needs these packages:
> > gtk, Text.Parsec, Time, Database.HDBC.Sqlite3, Locale,
> > Data.ByteString.Lazy.
> >
>
> No obvious suspect.
> Depending on how curious you are, you could split off small sub-programmes
> to see what's taking a lot of space. But that's going to be tedious.
>
> You could ask on IRC (#haskell) whether anybody knows about huge
> executables with gtk, or on haskell-cafe, on the gtk2hs mailing list, or
> you could open a ticket at http://hackage.haskell.org/trac/gtk2hs/ or
> http://hackage.haskell.org/trac/ghc/newticket?type=bug whichever you
> consider more likely to be responsible (you needn't create an account for
> either bug-tracker, both have guest accounts with the guest password in
> plain view - though you may need to look for it a bit). But first ask
> elsewhere.
>
> >
> > --Christian
>
------------------------------
Message: 8
Date: Sun, 17 Oct 2010 13:58:48 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] GHC-generated executables size
To: "." <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Sunday 17 October 2010 13:10:32, . wrote:
> Ok, after recompiling gtk again and hiding gtk-0.11.0 (which was still
> monolithic), it worked.
Good.
> The executable is now, after stripping, a mere
> 2.7MB in size (which is still large for what it does, but much better).
Well, the executable contains the runtime, so it's naturally much larger
than a small C programme. Compare with
$ cat helloWorld.hs
module Main (main) where
main :: IO ()
main = putStrLn "Hello, World!"
$ ghc --make helloWorld.hs
[1 of 1] Compiling Main ( helloWorld.hs, helloWorld.o )
Linking helloWorld ...
$ ls -l helloWorld
-rwxr-xr-x 1 dafis users 618581 17. Okt 13:53 helloWorld
I suppose on a 64-bit system, you get about twice the numbers, so 2.7MB for
a programme using gtk isn't exorbitant.
> Thanks to all who answered for your help!
>
> Christian
Cheers,
Daniel
------------------------------
Message: 9
Date: Fri, 15 Oct 2010 22:37:45 +0200
From: Christian Gosch <[email protected]>
Subject: [Haskell-beginners] GHC-generated executables size
To: [email protected]
Message-ID: <1287175065.9018.4.ca...@eddy>
Content-Type: text/plain; charset="UTF-8"
Hi,
I was playing around with ghc again, and I was wondering what makes
the executables so large and how I could make them smaller (strip works,
but is there anything more I can do?)
More specifically, I am compiling a program that uses the GTK+ bindings,
HDBC, and some things from Prelude.
The program simply displays a window, and reads and writes values
from/into a data base file. Not much, really.
Anyway, the program size is 20MB without stripping, and 10MB after
stripping ...
Any hints?
Thanks and good night for now ..
Christian
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 28, Issue 27
*****************************************