Yhc: A second impression

Hello Yhc'ers, With the correction of bug #18 http://code.google.com/p/yhc/issues/detail?q=&can=2&id=18 I have been able to use Yhc to run a number of my "serious" toy programs, solving important problems like SuDoku puzzles or finding prime factors of large integers. Congratulations, this is most satisfactory. I have a simple benchmark that I have run many times, mostly to compare the performance of different machines. The benchmark consists of running a single program t3 compiled using GHC and measure its CPU usage. This program performs some rather long-winding computations involving large (35-70 decimal digit) numbers that conclude in discovering the second-largest prime factor 1963506722254397 of the "repunit" R[43] = (10^43-1)/9 = 111...(total of 43 1's)...1. On a slow machine that I have used a lot, this takes about 3.5 minutes. On a fast machine, it takes less than 3 seconds. But t3 can, of course, also be used to compare different Haskell implementations on the same machine. So, I have run the following script on my PPC Mac OS X 10.4: #!/bin/sh # t3timing1.sh: Timing t3.hs using GHC, Hugs, Yhc # 2007-Feb-13 19.11 / TN do_ghc () { echo $0: GHC $* time ghc-inplace --make t3.hs $* time ./t3 rm *.hi *.o t3 } ghc-inplace --version time echo :q | ghc-inplace --interactive t3 time echo main | ghc-inplace --interactive t3 do_ghc -O0 do_ghc -O1 do_ghc -O2 time echo :q | hugs t3 time echo main | hugs t3 time yhc t3 time yhi Main rm *.hi *.hbc Essentially, this runs t3 using 4 variants of GHC-support (interpreted and -O0..2) and a single variant of each of Hugs and Yhc. The output, with some non-essentials left out, is: The Glorious Glasgow Haskell Compilation System, version 6.7.20070209 ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.7.20070209, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. [ 1 of 47] Compiling FtdBase ( FtdBase.hs, interpreted ) ... [47 of 47] Compiling Main ( t3.hs, interpreted ) Ok, modules loaded: ... *Main> Leaving GHCi. real 0m25.956s user 0m20.449s sys 0m1.029s ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.7.20070209, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. [ 1 of 47] Compiling FtdBase ( FtdBase.hs, interpreted ) ... [47 of 47] Compiling Main ( t3.hs, interpreted ) Ok, modules loaded: ... *Main> Loading package haskell98 ... linking ... done. t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") *Main> Leaving GHCi. real 2m4.864s user 1m55.500s sys 0m2.099s t3_timing1.sh: GHC -O0 [ 1 of 47] Compiling FtdBase ( FtdBase.hs, FtdBase.o ) ... [47 of 47] Compiling Main ( t3.hs, t3.o ) Linking t3 ... real 1m7.438s user 0m52.395s sys 0m4.777s t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") real 0m22.225s user 0m21.242s sys 0m0.348s t3_timing1.sh: GHC -O1 [ 1 of 47] Compiling FtdBase ( FtdBase.hs, FtdBase.o ) ... [47 of 47] Compiling Main ( t3.hs, t3.o ) Linking t3 ... real 1m30.559s user 1m15.897s sys 0m5.035s t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") real 0m20.557s user 0m19.279s sys 0m0.283s t3_timing1.sh: GHC -O2 [ 1 of 47] Compiling FtdBase ( FtdBase.hs, FtdBase.o ) ... [47 of 47] Compiling Main ( t3.hs, t3.o ) Linking t3 ... real 1m35.578s user 1m20.963s sys 0m5.178s t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") real 0m20.122s user 0m19.182s sys 0m0.306s __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: 20070105 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Main> [Leaving Hugs] real 0m3.336s user 0m1.609s sys 0m0.924s __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: 20070105 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Main> t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") Main> [Leaving Hugs] real 5m45.012s user 5m37.656s sys 0m3.116s Nothing derived for Id 424 at nopos Nothing derived for Id 451 at nopos Nothing derived for Id 335 at nopos Compiling IntMath ( IntMath.hs ) ... Compiling Main ( t3.hs ) real 1m5.848s user 1m0.264s sys 0m1.894s t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297, [(77,ECUndefined{ecd=1963506722254397})])") real 5m36.540s user 5m29.788s sys 0m2.544s From this, -O2 GHC execution is about 19 seconds, Hugs execution is 5 minutes and 41 seconds (341 seconds) (including compilation, about 3 seconds), and Yhi execution is 5 minutes and 31 seconds (331 seconds). Overall: For this program (t3), Hugs and Yhc execution times are comparable. Compiled GHC -O2 is 17 times faster. Best regards Thorkil

Hi Thorkil
I have been able to use Yhc to run a number of my "serious" toy programs, solving important problems like SuDoku puzzles or finding prime factors of large integers.
Good good, thanks for having the patience to stick around til everything was fixed.
From this, -O2 GHC execution is about 19 seconds, Hugs execution is 5 minutes and 41 seconds (341 seconds) (including compilation, about 3 seconds), and Yhi execution is 5 minutes and 31 seconds (331 seconds).
Overall: For this program (t3), Hugs and Yhc execution times are comparable. Compiled GHC -O2 is 17 times faster.
Yhc should be faster than Hugs, I would guess twice as fast as Hugs normally. If your particular test is spending all its time in libgmp with big integers then that might explain it - otherwise I'd be curious why Yhc doesn't do better. Andrew: Does Yhi get built by default with -O ? Thanks Neil

Hello Niel, On Tuesday 13 February 2007 23:49, Neil Mitchell wrote:
... Andrew: Does Yhi get built by default with -O ? ...
In the output from the Yhc build, I cannot find traces that -O is being used, neither for the ghc compiled nor the gcc compiles. But then I tried to add -O using the CCFLAGS and GHCFLAGS environment variables that were mentioned recently. First, however, I did a scons clean, output was this: scons: Reading SConscript files ... Building version 0.7.0-20070207134437-custom. Checking for architecture... (cached) ppc Checking for operating system... (cached) darwin Checking for Subversion binary... (cached) "svn" Checking for Subversion version... (cached) Found version 1.4.0. Checking for C header file gmp.h... (cached) yes Checking for mpz_t integ; mpz_init (integ) in C library gmp... (cached) yes Checking for libgmp version... (cached) scons: done reading SConscript files. scons: Building targets ... scons: Nothing to be done for `clean'. scons: done building targets. "Nothing"? Hm ... At this point, I believe that I observed that bin/yhc still existed, so I decided to scons fullclean: scons: Reading SConscript files ... Building version 0.7.0-20070207134437-custom. Checking for architecture... (cached) ppc Checking for operating system... (cached) darwin Checking for Subversion binary... (cached) "svn" Checking for Subversion version... (cached) Found version 1.4.0. Checking for C header file gmp.h... (cached) yes Checking for mpz_t integ; mpz_init (integ) in C library gmp... (cached) yes Checking for libgmp version... (cached) scons: done reading SConscript files. scons: Building targets ... scons: Nothing to be done for `fullclean'. scons: done building targets. Again "Nothing". But now bin/yhc had disappeared. So "scons". But: scons: Reading SConscript files ... Building version 0.7.0-20070213181100-custom. Checking for architecture... (cached) ppc Checking for operating system... (cached) darwin Checking for architecture... (cached) ppc Checking for operating system... (cached) darwin Checking for Subversion binary... (cached) "svn" Checking for Subversion version... (cached) Found version 1.4.0. Checking for GHC binary... (cached) "ghc" Checking for GHC version 6.4.1 or later... (cached) Found version 6.4.1. Checking for C header file gmp.h... (cached) yes Checking for mpz_t integ; mpz_init (integ) in C library gmp... (cached) yes Checking for libgmp version... (cached) Checking for Python version 2.3 or later... (cached) Found version 2.4.3 final (0). Checking for Scons binary... (cached) "scons" Checking for Scons version... (cached) Found version 0.96.92.D002. Checking for Darcs binary... (cached) "darcs" Checking for Darcs version... (cached) Found version 1.0.8 (release). Checking for Haddock binary... (cached) Not found Error. Haddock not found, you won't be able to build the documentation. Checking whether byte ordering is bigendian... (cached) no Checking size of char... (cached) no Checking size of short... (cached) no Checking size of int... (cached) no Checking size of long... (cached) no Checking size of long long... (cached) no Checking size of float... (cached) no Checking size of double... (cached) no Checking size of void*... (cached) no Failed to check types sizes/endianness. You do have a working C compiler don't you? If so then please contact the Yhc developers for help. So, at least with this pull, I seem to be stuck. I could probably pull a fresh Yhc and get going again, but I have not tried that. Comments? Best regards Thorkil

On 2/14/07, Thorkil Naur
Hello Niel,
On Tuesday 13 February 2007 23:49, Neil Mitchell wrote:
... Andrew: Does Yhi get built by default with -O ? ...
In the output from the Yhc build, I cannot find traces that -O is being used, neither for the ghc compiled nor the gcc compiles.
No, by default Yhi is not built with -O, but by passing type=release to scons it will be. But then I tried to add -O using the CCFLAGS and GHCFLAGS environment
variables that were mentioned recently. First, however, I did a scons clean, output was this:
"Nothing"? Hm ... At this point, I believe that I observed that bin/yhc still existed, so I decided to scons fullclean:
Scons outputs 'nothing' because the cleaning is done outside of the usual scons way of doing things, so scons doesn't think it has anything to do when in fact stuff has already been done. This is nothing to worry about, and is normal. Again "Nothing". But now bin/yhc had disappeared. So "scons". But:
So, at least with this pull, I seem to be stuck. I could probably pull a fresh Yhc and get going again, but I have not tried that.
This is a bug with the latest version of scons (at least I think it's a scons problem not a Yhc problem) and can be worked around by run 'scons --config=force' Regards, Andrew

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andrew Wilkinson wrote:
Scons outputs 'nothing' because the cleaning is done outside of the usual scons way of doing things, so scons doesn't think it has anything to do when in fact stuff has already been done. This is nothing to worry about, and is normal.
Yes, however, I believe this has confused me in the past too. It would be good if there was some (easy enough) way to not show this misleading message. Actually it might be nice if the commands said what they were removing... Looking in Sconstruct it seems there's quite some duplicate code between clean and fullclean targets. In the lists of filename extensions to clean is "fullclean" *but not "clean"* really supposed to include ".obj"? Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF0vbdHgcxvIWYTTURAtrzAJwLWSshX01+awcz0NixZTblbClOhwCfao/T bYlOn1UF2JWCQ24jilh+wyY= =5kLS -----END PGP SIGNATURE-----

Hello, On Wednesday 14 February 2007 09:48, Andrew Wilkinson wrote:
... No, by default Yhi is not built with -O, but by passing type=release to scons it will be. ... run 'scons --config=force' ,,,
Thanks a lot. Combining this, I got yhc/yhi compiled with ghc -O and gcc -O2. On Tuesday 13 February 2007 23:49, Neil Mitchell wrote:
... Yhc should be faster than Hugs, I would guess twice as fast as Hugs normally. ...
And, indeed, with this build of yhc, I get the following: ... __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: 20070105 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Main> t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297,[(77,ECUndefined {ecd = 1963506722254397})])") Main> [Leaving Hugs] real 6m14.572s user 5m38.863s sys 0m4.036s Compiling IntMath ( IntMath.hs ) ... Compiling Main ( t3.hs ) real 0m47.459s user 0m38.359s sys 0m1.534s t3: 2007-Feb-13 20.08 t3I_20: fecFactorList [6..105] r43r 1300 4300 1 t3I_20: (1963506722254397,"(1297,4297, [(77,ECUndefined{ecd=1963506722254397})])") real 2m55.289s user 2m32.733s sys 0m2.016s So -O'd yhc runs t3 at roughly twice the speed of Hugs. Best regards Thorkil
participants (4)
-
Andrew Wilkinson
-
Isaac Dupree
-
Neil Mitchell
-
Thorkil Naur