Jira (PUP-5810) Increase performance by adding tail-call functionality to evaluator

5 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
Feb 3, 2016, 1:09:03 PM2/3/16
to puppe...@googlegroups.com
Henrik Lindberg created an issue
 
Puppet / Improvement PUP-5810
Increase performance by adding tail-call functionality to evaluator
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2016/02/03 10:08 AM
Priority: Normal Normal
Reporter: Henrik Lindberg

There is opportunity to optimize tail calls in puppet. Now when we do not do this, we have issues with recursive functions running out of stack since each call level is expensive.

We can implement this by:

  • adding a boolean flag to the AST call instructions.
  • in the rewrite step in the parser (where it detects parenthesized function calls), we detect if a call is a "tail-call", and we flip the "tail-call" bit in the AST
  • when performing the call, instead of adding yet another stack level, we throw a TailCall, which contains the information needed to proceed.

Tail-calls are all calls where the result of the call is also the result of the expression the call is part of. If we had a return it would be wherever there is a construct like return func().

Here is an example, where some potential tail calls can be detected.

function foo($x) {
  case $x {
    1 : { tail_call() }
    2: { not_tail_call(); tail_call() }
  }
  if cond {
    tail_call()
  }
  not_tail_call()
  tail_call()
}

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.12#64027-sha1:e3691cc)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Feb 9, 2016, 9:24:03 PM2/9/16
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Feb 9, 2016, 9:24:03 PM2/9/16
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Mar 2, 2016, 5:12:03 PM3/2/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Fix Version/s: PUP 4.4.1
Fix Version/s: PUP 4.x

Henrik Lindberg (JIRA)

unread,
Sep 7, 2016, 6:12:18 PM9/7/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Team: Puppet Developer Support
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Apr 25, 2017, 5:25:02 AM4/25/17
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
May 16, 2017, 8:46:02 AM5/16/17
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
May 17, 2023, 2:11:02 PM5/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP-5773
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Josh Cooper (Jira)

unread,
May 17, 2023, 2:11:02 PM5/17/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
May 17, 2023, 2:12:03 PM5/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Puppet Developer Experience
Reply all
Reply to author
Forward
0 new messages