Version française
Home     About     Download     Resources     Contact us    
Browse thread
compiling large file hogs RAM and takes a long time.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sam Steingold <sds@g...>
Subject: Re: large parametrized polymorphic variant type combinations take forever to compile
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jacques Garrigue wrote:
> 
> Could you send me your real code, so that I can see whether something
> unexpected is happening?

here is some more information:
file http://sds.podval.org/data/small.zip includes 6 files:

small1.ml small2.ml : define large (~1,000 variants) polymorphic variant
types (non-parametric).
compilation time: ~20 sec each.
small.ml : use small1.ml & small2.ml:
================ small.ml ====================
type t3 = [
| Small1.t1
| Small2.t2
]

let f ~fa ~fb ~fc = function
  | # Small1.t1 as x -> Small1.f ~fa ~fb x
  | # Small2.t2 as x -> Small2.f ~fa ~fb ~fc x
================ small.ml ====================
compilation time:
real    1m28.063s
user    1m8.628s
sys     0m0.828s

smallp1.ml smallp2.ml : define large (~1,000 variants) parametric
polymorphic variant types.
compilation time: ~20 sec each (same as non-parametric)
small_p.ml: use smallp1.ml smallp2.ml:
================ small_p.ml ====================
type ('a,'b,'c) t3 = [
| ('a,'b) Smallp1.t1
| ('a,'b,'c) Smallp2.t2
]

let f ~fa ~fb ~fc = function
  | # Smallp1.t1 as x -> Smallp1.f ~fa ~fb x
  | # Smallp2.t2 as x -> Smallp2.f ~fa ~fb ~fc x
================ small_p.ml ====================
compilation time:
real    29m31.639s
user    25m49.929s
sys     0m10.937s

note that the use of type parameters increased compilation time of "|#"
by a factor of 20!

$ ocamlc -version
3.09.3

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGk7iOPp1Qsf2qnMcRAvVaAKCDfgmyWfvQ4wQA5T6n8PfcIdxWJwCgi6i+
ds8yKZ7tkgFoe4LqXaumV9w=
=+jXg
-----END PGP SIGNATURE-----