Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004074OCamlback end (clambda to assembly)public2006-08-03 16:242018-11-09 14:36
Assigned Tofrisch 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0004074: Patch for in-place compilation of structures
Description[edit: english translation]

The attached patch adds an "-inplace" option to ocamlopt. When the option is set, it uses for all structures the same compilation scheme as is currently done for global structures only. This reduce pressure on the register allocater when compiling big structures.

The patch is careful to adapt the inliner to the new way of filling structure fields.

The program generated by the following code:

  print_string "module F(X:sig val x : int end) = struct\n let x0 = X.x";;
  for i = 1 to 300 do Printf.printf " let x%i = %i * x%i\n" i i (i-1) done;;
  print_string "end";;

needs 15 seconds to compile with ocamlopt and 0.3s with option -inplace,
and the generated .o goes from 15044 bytes to 12740 bytes.


Le patch en pièce jointe ajoute une option "-inplace" à ocamlopt, dont l'effet
est d'utiliser le schéma de compilation des structures globales pour toutes les structures. Ça permet de réduire la pression sur l'allocateur de registres lorsque l'on compile de grosses structures.

Le patch prend soin d'adapter l'inliner pour qu'il comprenne la nouvelle manière de remplir les champs d'une structure.

Le programme produit par:

  print_string "module F(X:sig val x : int end) = struct\n let x0 = X.x";;
  for i = 1 to 300 do Printf.printf " let x%i = %i * x%i\n" i i (i-1) done;;
  print_string "end";;

prend 15s à compiler avec ocamlopt et 0.3s avec l'option -inplace,
et le .o passe de 15044 octets à 12740 octets.
Attached Files? file icon diff_inplace [^] (26,297 bytes) 2006-08-03 16:24 [Show Content]

- Relationships
related to 0005546closedfrisch moving a function into an internal module slows down its use 
related to 0005573closedfrisch Access to values in nested modules 
related to 0007630resolvedgasche FLambda particularly slow with large file consisting in top-level trivial aliases. 

-  Notes
frisch (developer)
2006-08-05 11:17
edited on: 2012-04-05 06:11

You have to remove the assertion (assert(a.(n) = Value_unknown) so that it still works without -inplace.

frisch (developer)
2006-08-08 19:15
edited on: 2012-04-05 06:12

For the record, the patch compiles for example in 7 seconds, against 21s without the patch. It is mostly the computation of the register interference graph which makes the difference.

frisch (developer)
2018-11-09 14:36

The linear-scan allocator would take care of such cases.

- Issue History
Date Modified Username Field Change
2006-08-03 16:24 frisch New Issue
2006-08-03 16:24 frisch File Added: diff_inplace
2006-08-05 11:17 frisch Note Added: 0003727
2006-08-08 19:15 frisch Note Added: 0003730
2006-08-29 16:40 doligez Status new => acknowledged
2012-03-29 09:29 frisch Relationship added related to 0005546
2012-04-04 22:47 gasche Relationship added related to 0005573
2012-04-05 06:09 gasche Severity minor => feature
2012-04-05 06:09 gasche Summary Patch pour compiler les structures en place => Patch for in-place compilation of structures
2012-04-05 06:09 gasche Description Updated View Revisions
2012-04-05 06:11 gasche Note Edited: 0003727 View Revisions
2012-04-05 06:12 gasche Note Edited: 0003730 View Revisions
2012-06-20 11:19 frisch Category OCaml general => OCaml backend (code generation)
2013-09-03 17:17 doligez Tag Attached: patch
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)
2017-09-25 15:41 gasche Relationship added related to 0007630
2018-11-09 14:36 frisch Note Added: 0019447
2018-11-09 14:36 frisch Status acknowledged => resolved
2018-11-09 14:36 frisch Resolution open => fixed
2018-11-09 14:36 frisch Assigned To => frisch

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker