Skip to content

Commit

Permalink
fix a caching problem in OO code causing a 4.11 performance regression
Browse files Browse the repository at this point in the history
The regression was introduced by ocaml#9096 in this part of the diff:

             | Tcf_method (name, _, Tcfk_concrete (_, exp)) ->
-                let met_code = msubst true (transl_exp exp) in
+                let scopes = enter_method_definition ~scopes name.txt in
+                let met_code =
+                  msubst true (transl_scoped_exp ~scopes exp) in

transl_exp would use Translobj.oo_wrap on functions, while the new
transl_scoped_expr does not.

The regression was first reported by Sacha Ayoun in ocaml#10092, as it
results in a large slowdown (2x slower) on the Gillian codebase, which
uses an object-oriented visitor in a performance-critical way.
  • Loading branch information
gasche committed Dec 22, 2020
1 parent f9d3c21 commit 6c579e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lambda/translcore.ml
Expand Up @@ -856,7 +856,8 @@ and transl_function ~scopes e param cases partial =
and transl_scoped_exp ~scopes expr =
match expr.exp_desc with
| Texp_function { arg_label = _; param; cases; partial } ->
transl_function ~scopes expr param cases partial
Translobj.oo_wrap expr.exp_env true
(transl_function ~scopes expr param cases) partial
| _ ->
transl_exp ~scopes expr

Expand Down

0 comments on commit 6c579e4

Please sign in to comment.