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

forcing a nil (no) backtrace with Java APIs #3488

Merged
merged 5 commits into from Jan 2, 2016
Merged

forcing a nil (no) backtrace with Java APIs #3488

merged 5 commits into from Jan 2, 2016

Conversation

@kares
Copy link
Member

kares commented Nov 23, 2015

RaiseException(Ruby runtime, RubyClass type, String msg, IRubyObject backtrace, boolean native) constructor despite accepting an IRubyObject backtrace parameter (and not just RubyArray), passing a nil does not end up with the RubyException#backtrace being nil but rather an empty array which is not fortunate as in user-land its easy to dismiss and confusing.

like to use the constructor for optional "lightweight" exception raising such as jruby/jruby-openssl#55

p.s. I'd like to consider backporting these changes to jruby-1_7 if there's no objections to that.

@kares kares changed the title forceing a nil (no) backtrace with Java APIs forcing a nil (no) backtrace with Java APIs Nov 23, 2015
@enebo enebo force-pushed the master branch from 2beed09 to 1ee9007 Nov 23, 2015
@kares kares force-pushed the force-backtrace-nil branch from 99e0d56 to 0a3b5cd Dec 15, 2015
kares added a commit to jruby/jruby-openssl that referenced this pull request Dec 17, 2015
…array)

... little more confusing than a `nil` but for now has todo (until jruby/jruby#3488)
kares added 5 commits Nov 22, 2015
…() lazy

the `backtrace()` return value when doing `set_backtrace` was ignored anyway
…rror)

which is slightly faster ... avoids an instanceof check + Ruby boolean wrapping
@kares kares force-pushed the force-backtrace-nil branch from 0a3b5cd to 53e70e9 Dec 31, 2015
@kares
Copy link
Member Author

kares commented Jan 2, 2016

the changes also slightly improved performance (when backtrace is not accessed) e.g.

require 'hitimes'

def measure(count = 1_000)
  Hitimes::Interval.measure do
    count.times do
      begin
        raise RuntimeError.new
      rescue RuntimeError => e
        puts e.message if false
      end
    end
  end
end

print "warmup: "
puts measure(200_000).inspect
print "......: "
puts measure(500_000).inspect

BEFORE:

warmup: 12.830130032
......: 29.00416128

warmup: 12.668082653
......: 27.926976294

warmup: 12.572626931
......: 28.33092909

AFTER:

warmup: 11.538297404
......: 25.360850043

warmup: 11.461425197
......: 25.174530815

warmup: 12.311494166
......: 26.668306498
kares added a commit that referenced this pull request Jan 2, 2016
forcing a nil (no) backtrace with Java APIs
@kares kares merged commit dbc4b02 into master Jan 2, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kares kares added this to the JRuby 9.0.5.0 milestone Jan 2, 2016
@kares kares deleted the force-backtrace-nil branch Jan 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.