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

optimization of partial applications #5287

Closed
vicuna opened this issue Jun 10, 2011 · 1 comment
Closed

optimization of partial applications #5287

vicuna opened this issue Jun 10, 2011 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 10, 2011

Original bug ID: 5287
Reporter: @lefessan
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: all
OS: all
OS Version: all
Version: 3.12.0
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Parent of: #5933
Monitored by: @ygrek @jberdine "Julien Signoles" @hcarty @alainfrisch

Bug description

Partial applications like (f x) where f has arity greater than 3 are expensive, since every application will lead to a closure allocation for each intermediary argument. Moreover, such functions are not inlined anymore.

This patch fixes these two behaviors:

  • in cmmgen.ml, caml_curry functions are modified so that they can be applied directly, when all the remaining arguments are provided. No allocation anymore for intermediate arguments.
  • in closure.ml, partial applications are detected, and, when the true arity of the function is known, an eta-expansion is performed.

Problems:

  • since approximations of arguments are lost during applications, the optimization is less interesting than with the patch I sent by email, but its complexity is unchanged (the "planck" parser of Jun could trigger an exponential complexity due to the recursive call to "close")
  • approximations are not known for external functions when they are bigger than the inlining threshold, so the transformation cannot be triggered for them, although it would be interesting.

File attachments

@vicuna
Copy link
Author

vicuna commented Jun 12, 2011

Comment author: @xavierleroy

Patch applied in SVN trunk. We'll see how it goes.

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

No branches or pull requests

2 participants