Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005944OCamlOCaml typingpublic2013-03-12 14:452013-04-23 02:38
Reporterbvaugon 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version4.00.2+dev 
Summary0005944: [patch] Bad typing performances of big variant type declaration
DescriptionThe typing complexity of variant type declaration like:

type t = X1 | X2 | X3 | [...] | X32768

is very bad.

This kind of code pattern is somtime usefull, in particular in OCaPIC low level libraries, and it can be fixed by the small and simple attached patch.
Steps To ReproduceInsert this kind of type declaration in a x.mli file and run:

time ocamlopt x.mli
Additional InformationThe culprit function is check_constraints defined in typing/typedecl.ml.
A small "Map" index resolve the problem, as you can see in the attached patch:
ocaml-4.00.1-fast-typedecl.diff.

With this patch, the time needed to compile a variant definition with 32768 constant constructors go down from 29s to 0.39s (on my computer).
TagsNo tags attached.
Attached Filesdiff file icon ocaml-4.00.1-fast-typedecl.diff [^] (1,242 bytes) 2013-03-12 14:45 [Show Content]

- Relationships

-  Notes
(0008961)
garrigue (manager)
2013-03-12 15:15

Well, this is really a huge type...

Your patch is small, so I will probably include it.
My only concern is that you may get into other performance problems using this type.
(0008962)
bvaugon (reporter)
2013-03-12 17:37

Yes, it's not impossible. But in practice, for now, I uses types like this in multiple programs without other compilation problems.

Thanks for your answer!
(0009189)
garrigue (manager)
2013-04-23 02:38

Patch merge in trunk and 4.00, revision 13588 and 13589.

- Issue History
Date Modified Username Field Change
2013-03-12 14:45 bvaugon New Issue
2013-03-12 14:45 bvaugon File Added: ocaml-4.00.1-fast-typedecl.diff
2013-03-12 15:15 garrigue Note Added: 0008961
2013-03-12 15:15 garrigue Assigned To => garrigue
2013-03-12 15:15 garrigue Status new => assigned
2013-03-12 17:37 bvaugon Note Added: 0008962
2013-04-23 02:38 garrigue Note Added: 0009189
2013-04-23 02:38 garrigue Status assigned => closed
2013-04-23 02:38 garrigue Resolution open => fixed
2013-04-23 02:38 garrigue Fixed in Version => 4.00.2+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker