Skip to content

Introduce warning 68 to warn about hidden allocation due to pattern match of mutable field in curried functions#9751

Merged
lpw25 merged 13 commits intoocaml:trunkfrom
hhugo:warn-alloc-clo
Aug 17, 2020
Merged

Introduce warning 68 to warn about hidden allocation due to pattern match of mutable field in curried functions#9751
lpw25 merged 13 commits intoocaml:trunkfrom
hhugo:warn-alloc-clo

Conversation

@hhugo
Copy link
Copy Markdown
Contributor

@hhugo hhugo commented Jul 9, 2020

Report a (new) warning when curried function allocate an extra closure due to pattern-matching on mutable argument

The goal is to give more visibility to theses hidden allocation points. It's currently too easy to degrade performances.

fix #9641

@hhugo hhugo changed the title Warn alloc clo Introduce warning 68 to warn about hidden allocation due to pattern match of mutable field in curried functions Jul 9, 2020
@hhugo hhugo force-pushed the warn-alloc-clo branch 3 times, most recently from c361f80 to c116438 Compare July 13, 2020 17:36
@hhugo hhugo marked this pull request as ready for review July 13, 2020 17:37
@hhugo
Copy link
Copy Markdown
Contributor Author

hhugo commented Jul 21, 2020

There are two special cases that code path (transl_function0):

  • compilation of curried functions (collecting as many arguments as possible)
  • flattening function taking a tuple

The transl_function0 has been split out in three functions to make the logic clearer.

  • transl_function0 is now responsible for the general case
  • transl_curried_function and transl_tupled_function are each responsible for one special case only.

Copy link
Copy Markdown
Contributor

@lpw25 lpw25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning is definitely useful, and the refactoring of transl_function is nice. Since this is a user facing change, I'll wait a bit before merging to give others a chance to comment.

@hhugo
Copy link
Copy Markdown
Contributor Author

hhugo commented Aug 4, 2020

I've rebased the feature and tuned it so that the CI is happy.

@lpw25
Copy link
Copy Markdown
Contributor

lpw25 commented Aug 5, 2020

No one has objected for a week so far. I will merge in the next couple of days.

@lpw25 lpw25 merged commit 49aa87c into ocaml:trunk Aug 17, 2020
@hhugo hhugo deleted the warn-alloc-clo branch September 10, 2020 11:50
hhugo added a commit to janestreet/ocaml that referenced this pull request Sep 22, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
mshinwell pushed a commit to janestreet/ocaml that referenced this pull request Sep 29, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
mshinwell pushed a commit to janestreet/ocaml that referenced this pull request Sep 30, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
mshinwell pushed a commit to janestreet/ocaml that referenced this pull request Sep 30, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
mshinwell pushed a commit to janestreet/ocaml that referenced this pull request Oct 1, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
mshinwell pushed a commit to janestreet/ocaml that referenced this pull request Oct 1, 2020
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
GreenArchon pushed a commit to GreenArchon/ocaml that referenced this pull request Dec 19, 2020
…atch of mutable field in curried functions (ocaml#9751)

Introduce new warning 68
# Conflicts:
#	Changes
#	boot/ocamlc
#	boot/ocamllex
#	lambda/translcore.ml
#	utils/warnings.ml
GreenArchon pushed a commit to GreenArchon/ocaml that referenced this pull request Dec 19, 2020
…atch of mutable field in curried functions (ocaml#9751)

Introduce new warning 68
# Conflicts:
#	Changes
#	boot/ocamlc
#	boot/ocamllex
#	lambda/translcore.ml
#	utils/warnings.ml
gretay-js pushed a commit to gretay-js/ocaml that referenced this pull request May 28, 2021
…o pattern match of mutable field in curried functions (ocaml#9751)

Introduce new warning 68

(cherry picked from commit 49aa87c)
Ngoguey42 pushed a commit to tarides/tezos that referenced this pull request Jun 7, 2021
The nice side-effect of this patch is to reduce the number of
allocations.  See ocaml/ocaml#9751 for the
introduction of this breaking change in OCaml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report a new warning when curried function allocate an extra closure ...

2 participants