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

infinite loop in ocamlc/ocamlopt #7397

Closed
vicuna opened this issue Nov 2, 2016 · 10 comments
Closed

infinite loop in ocamlc/ocamlopt #7397

vicuna opened this issue Nov 2, 2016 · 10 comments

Comments

@vicuna
Copy link

vicuna commented Nov 2, 2016

Original bug ID: 7397
Reporter: @hhugo
Assigned to: @garrigue
Status: closed (set by @damiendoligez on 2016-11-04T14:51:27Z)
Resolution: fixed
Priority: urgent
Severity: block
Target version: 4.04.0 +dev / +beta1 / +beta2
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: typing
Monitored by: @garrigue

Bug description

The ocaml compiler never terminate on one of the file of the js_of_ocaml codebase.

See below for a minimal example.

Steps to reproduce

compile the following program with ocamlc/ocamlopt

type +'a t

class type a = object
method b : b
end

and b = object
method a : a
end

type _ response =
| C : #a t response

let f (type a) (a : a response) =
match a with
| C -> 0

Additional information

This is using an up to date 4.04.0+trunk opam switch

@vicuna
Copy link
Author

vicuna commented Nov 2, 2016

Comment author: @hhugo

Note that it works fine with 4.04.0+beta2

@vicuna
Copy link
Author

vicuna commented Nov 2, 2016

Comment author: @hhugo

most probably related to #7374

@vicuna
Copy link
Author

vicuna commented Nov 2, 2016

Comment author: @damiendoligez

Indeed. Bisecting points to this commit: 8811d34

@vicuna
Copy link
Author

vicuna commented Nov 3, 2016

Comment author: @garrigue

Fixed by commit 02d7c27.

Needed to call wrap_trace_gadt_instances.

@vicuna
Copy link
Author

vicuna commented Nov 3, 2016

Comment author: @hhugo

Js_of_ocaml now compiles, but there is a huge performance regression

$ ocamlfind ocamlc -w +A-4-7-9-37-38-41-44-45 -pp "camlp4o syntax/pa_js.cmo" -safe-string -package lwt,uchar -c -g xmlHttpRequest.ml -dtimings
all: 55.327s
preprocessing(xmlHttpRequest.ml): 0.001s
typing(xmlHttpRequest.ml): 55.239s
transl(xmlHttpRequest.ml): 0.080s
generate(xmlHttpRequest.ml): 0.005s

@vicuna
Copy link
Author

vicuna commented Nov 3, 2016

Comment author: @hhugo

There is a big performance regression

@vicuna
Copy link
Author

vicuna commented Nov 3, 2016

Comment author: @hhugo

step to reproduce:
opam install js_of_ocaml --deps-only --yes
git clone https://github.com/ocsigen/js_of_ocaml.git
cd js_of_ocaml
make -C lib xmlHttpRequest.cmo

with 4.04.0+beta2, I get :

$ ocamlfind ocamlc -w +A-4-7-9-37-38-41-44-45 -pp "camlp4o syntax/pa_js.cmo" -safe-string -package lwt,uchar -c -g xmlHttpRequest.ml -dtimings
all: 0.247s
preprocessing(xmlHttpRequest.ml): 0.001s
typing(xmlHttpRequest.ml): 0.174s
transl(xmlHttpRequest.ml): 0.064s
generate(xmlHttpRequest.ml): 0.005s

@vicuna
Copy link
Author

vicuna commented Nov 4, 2016

Comment author: @garrigue

I did expect a performance regression, but not that big indeed.
If you can leave me 24 hours, I'll try to find a solution.
I.e., we shouldn't need to expand absolutely all types to check that there is no occurence.

@vicuna
Copy link
Author

vicuna commented Nov 4, 2016

Comment author: @garrigue

Commit c20a709 seems to solve the performance problem.
It only starts expanding everything when exploring a constrained type parameter.
But it's still going to be potentially very expensive in that case.

@hhugo Could you check that it solves the problem for your whole code base?

@vicuna
Copy link
Author

vicuna commented Nov 4, 2016

Comment author: @hhugo

Problem solved. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants