Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007244OCamlback end (clambda to assembly)public2016-04-27 11:472016-10-27 16:50
Reporterjoris 
Assigned Tochambart 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version4.04.0 +dev / +beta1 / +beta2Fixed in Version4.04.0 +dev / +beta1 / +beta2 
Summary0007244: Ocamlopt + flambda requires a lot of memory to compile large array literal expressions
Descriptionocamlopt + flambda needs several GB of memory to build a file with a lot of (very) large array literals. ocaml 4.02.3 uses between 4 and 5 times less memory on the same files.

The attached file is generated by ragel, a parser generator which uses arrays to store the automata.
Steps To Reproducebuild attached file with ocamlopt.opt -Oclassic ragel_file.ml. On my machine it requires 3.3GB of memory at peak to complete and several minutes. (-Oclassic or -O2 or anything else doesn't actually matter, there is no function in the test file)

(note the attached file is not the full ragel output but is enough to reproduce)
TagsNo tags attached.
Attached Files? file icon ragel_file.ml.xz [^] (356,460 bytes) 2016-05-03 11:35

- Relationships

-  Notes
(0015874)
joris (reporter)
2016-04-27 11:52

The file to reproduce is too large and i fail to upload it to mantis, so i've put it here : https://gist.github.com/jorisgio/8e8687be610d1c80a01c696a1aa68f98 [^]
(0015895)
doligez (administrator)
2016-05-03 11:35

Got the file, compressed it, and uploaded here.
(0015940)
Christophe Troestler (reporter)
2016-05-17 17:46

Not sure it is exactly the same but ocamlopt 4.03.0+flambda fails to compile the file https://github.com/Chris00/color_brewery/blob/master/src/color_brewery_palettes.ml [^] with

Fatal error: exception Stack overflow
Command exited with code 2.

(without flambda, the file compiles fine).
(0016273)
shinwell (developer)
2016-09-08 11:16

We should check this again with the current 4.04
(0016318)
chambart (developer)
2016-09-23 18:06

After looking a bit more at that, the problem seems to come directly from the file size. There is no specific inefficiency, but the conversion to a sequence of lets makes it too big. One way to handle that may be to circumvent the let conversion by directly producing the let_symbol during closure conversion. It is quite sad to have to special case this, but I can't find any better solution.
(0016319)
chambart (developer)
2016-09-23 18:09

By the way, Christophe, your situation is not the same, you should file a separate bug.
(0016467)
doligez (administrator)
2016-10-27 16:50

I've checked and GPR#840 fixes the issue. ( https://github.com/ocaml/ocaml/pull/840 [^] )

- Issue History
Date Modified Username Field Change
2016-04-27 11:47 joris New Issue
2016-04-27 11:52 joris Note Added: 0015874
2016-04-28 21:24 doligez Status new => acknowledged
2016-05-03 11:35 doligez Target Version => 4.04.0 +dev / +beta1 / +beta2
2016-05-03 11:35 doligez File Added: ragel_file.ml.xz
2016-05-03 11:35 doligez Note Added: 0015895
2016-05-17 17:46 Christophe Troestler Note Added: 0015940
2016-09-08 11:16 shinwell Note Added: 0016273
2016-09-08 12:05 shinwell Assigned To => chambart
2016-09-08 12:05 shinwell Status acknowledged => assigned
2016-09-23 18:06 chambart Note Added: 0016318
2016-09-23 18:09 chambart Note Added: 0016319
2016-10-27 16:50 doligez Note Added: 0016467
2016-10-27 16:50 doligez Status assigned => closed
2016-10-27 16:50 doligez Resolution open => fixed
2016-10-27 16:50 doligez Fixed in Version => 4.04.0 +dev / +beta1 / +beta2
2017-02-23 16:35 doligez Category OCaml backend (code generation) => Back end (clambda to assembly)
2017-02-23 16:44 doligez Category Back end (clambda to assembly) => back end (clambda to assembly)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker