Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005944OCamltypingpublic2013-03-12 14:452013-04-23 02:38
Assigned Togarrigue 
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/
A small "Map" index resolve the problem, as you can see in the attached patch:

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
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.
bvaugon (developer)
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!
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
2017-02-23 16:45 doligez Category OCaml typing => typing

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker