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

Performance losses in generated OCaml code #684

Open
larshum opened this issue Feb 16, 2023 · 0 comments
Open

Performance losses in generated OCaml code #684

larshum opened this issue Feb 16, 2023 · 0 comments

Comments

@larshum
Copy link
Contributor

larshum commented Feb 16, 2023

As I brought up during the meeting today, I found a couple of situations where the OCaml code we generate results in worse performance than what we would get by implementing it directly in OCaml.

  1. Pattern lowering binds the target of a TmMatch in a let and later matches on the bound variable. When we have a simple comparison of integers, the generated binary code makes two comparisons (first evaluating the boolean and then checking whether it is true). In https://godbolt.org/z/s3fGYa8sP, the top version is what MExpr would generate, while the bottom is a direct implementation in OCaml, which leads to more efficient x86 code. EDIT: Note that the performance issue is eliminated when using the OCaml 5.0.0 compiler with flambda enabled.
  2. The generated OCaml code does not inline records in constructors. This leads to slightly worse performance compared to when it is inlined, as seen in https://godbolt.org/z/o8ffcbf5G.
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

No branches or pull requests

1 participant