Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for in-place compilation of structures #4074

Closed
vicuna opened this Issue Aug 3, 2006 · 3 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Aug 3, 2006

Original bug ID: 4074
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2018-11-09T13:36:56Z)
Resolution: fixed
Priority: normal
Severity: feature
Category: back end (clambda to assembly)
Tags: patch
Related to: #5546 #5573 #7630
Monitored by: @whitequark jmeber MIchaelWohlwend @hcarty @alainfrisch

Bug 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.

File attachments

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 5, 2006

Comment author: @alainfrisch

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 8, 2006

Comment author: @alainfrisch

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 9, 2018

Comment author: @alainfrisch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.