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

Truffle omit backtraces #3637

Merged
merged 11 commits into from
Feb 3, 2016
Merged

Truffle omit backtraces #3637

merged 11 commits into from
Feb 3, 2016

Conversation

chrisseaton
Copy link
Contributor

Omit backtraces when we think they can't be used, as JRuby IR does. Obviously not going to work for someone looking for the exception by ObjectSpace but I think that's the only edge case and you really would have to try very hard to tigger it. Could also upset some debugger stuff? At worst, we can give a nice error message that they'll see and will tell them how to turn it off.

loop do
  start = Time.now
  1_000.times do
    raise rescue 14
  end
  puts Time.now - start
end

Note the tiny number of iterations. On MRI runs in 0.00117 s, JRuby 0.001 s, JRuby+Truffle+Graal before the optimisation 0.469 s. With the optimisation 0.07 s.

We still have two bad problems: first, there is still some huge cost somewhere with exceptions we don't know about, which has nothing to do with iterateFrames as with the optimisation we don't call that. Secondly, when we actually create a backtrace it's crazy - we materialise all frames in order to get the method object for printing the backtrace.

@nirvdrum @eregon @pitr-ch @headius @thedarkone

@chrisseaton chrisseaton added this to the truffle-dev milestone Feb 2, 2016
@chrisseaton
Copy link
Contributor Author

Found a transfer in the wrong place and added an explode loop, which reduced us to 0.02 s. Still don't know why it's an order of magnitude slower than JRuby. Needs investigation at some point.

@chrisseaton
Copy link
Contributor Author

@enebo tells me in JRuby they re-use a single instance of the exception when doing the omitted version. We allocate and escape a new instance every time.

@thedarkone
Copy link
Contributor

@chrisseaton:

Graal is no better than jruby+truffle when it comes to eliding backtraces ;), so (without benching) maybe this will help:

// in public class RaiseException extends RuntimeException
public final Throwable fillInStackTrace() {
    return null;
}

@chrisseaton
Copy link
Contributor Author

@thedarkone huh... I didn't know we didn't already do that... we do in our ControlFlowException, and I've even left myself a comment asking me why I'm not using it.

That was indeed the problem - we're now 10x on JRuby (I had to change the number of iterations to 100k to make it visible).

Thanks!

@thedarkone
Copy link
Contributor

// TODO CS 1-Mar-15 shouldn't this be a ControlFlowException?
😈.

@chrisseaton
Copy link
Contributor Author

Cheers

@headius
Copy link
Member

headius commented Feb 2, 2016 via email

chrisseaton added a commit that referenced this pull request Feb 3, 2016
@chrisseaton chrisseaton merged commit 832eff3 into master Feb 3, 2016
@chrisseaton chrisseaton deleted the truffle-elide-backtraces branch February 3, 2016 12:11
@enebo
Copy link
Member

enebo commented Feb 3, 2016

@chrisseaton sorry I made an ass of u and me since I had assumed you have replaced fillInBacktrace. Although a single instance in theory I think should have also partially addressed that since fillInBacktrace should only get called once.

@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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.

None yet

4 participants