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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct/revisit exception backtrace (and stack-trace) #6014

merged 10 commits into from Jan 8, 2020


Copy link

@kares kares commented Dec 31, 2019

original motivation for these changes was that the internal "lightweight" forced backtrace didn't have any reduced impact over a normal raise but also the fast that the legacy Java parts got neglected (not having the proper forced stack-trace as before).

last part is probably due having two TestRaiseException cases - one of which wasn't run since the recent changes (adding the Java exception hierarchy for Ruby ones) ...

than I realized RaiseException usually replaces a custom Java trace so not need to initially fillInStackTrace (which turned out to be potentially incorrectly on with -Xjump.backtrace)

p.s. also added some minor pre-filtering (e.g. getStackTrace from top - has been bothering me for a while 馃檲) - we could take it further to skip the Java stack trace head to not include all of the exception <init> (all the way to java.lang.Throwable.<init>) ... maybe later.

kares added 9 commits Dec 30, 2019
previously the constructor would hit preRaise twice
forcefully generating an unnecessary backtrace ...
- from the Ruby side we did not check set exception.backtrace
  handle case when its set (backtrace disabled) properly
- the legacy Java side always had its own stack-trace
  (regardless of the requested java trace parameter)

also added some preliminary filtering to skip internal parts
... there's certainly room to skip more in certain cases
since we always setStackTrace manually (from ctor)
@kares kares added this to the JRuby milestone Dec 31, 2019
Copy link
Member Author

@kares kares commented Dec 31, 2019

numbers confirm that a forced back-trace now is much faster (raise RuntimeError, '', nil) :

Warming up --------------------------------------
       raise default   841.000  i/100ms
 raise nil backtrace   898.000  i/100ms
Calculating -------------------------------------
       raise default      9.296k (卤 1.2%) i/s -     93.351k in  10.044026s
 raise nil backtrace      9.290k (卤 1.8%) i/s -     93.392k in  10.056207s
Warming up --------------------------------------
       raise default   867.000  i/100ms
 raise nil backtrace    78.471k i/100ms
Calculating -------------------------------------
       raise default      9.434k (卤 1.6%) i/s -     94.503k in  10.019629s
 raise nil backtrace      1.626M (卤 2.2%) i/s -     16.322M in  10.040849s

Copy link
Member Author

@kares kares commented Dec 31, 2019

Java 11 is half the speed for 'normal' raises (no change and I re-call this is a known thing) :

jruby (2.5.7) 2019-10-30 458ad3e Java HotSpot(TM) 64-Bit Server VM 11.0.2+9-LTS on 11.0.2+9-LTS +jit [linux-x86_64]

Warming up --------------------------------------
       raise default   449.000  i/100ms
 raise nil backtrace   466.000  i/100ms
Calculating -------------------------------------
       raise default      4.695k (卤 1.7%) i/s -     47.145k in  10.045269s
 raise nil backtrace      4.665k (卤 1.8%) i/s -     47.066k in  10.092519s
jruby (2.5.7) 2019-12-31 fe4b188 Java HotSpot(TM) 64-Bit Server VM 11.0.2+9-LTS on 11.0.2+9-LTS +jit [linux-x86_64]

Warming up --------------------------------------
       raise default   464.000  i/100ms
 raise nil backtrace    72.106k i/100ms
Calculating -------------------------------------
       raise default      4.962k (卤 1.1%) i/s -     49.648k in  10.006191s
 raise nil backtrace      1.489M (卤 1.2%) i/s -     14.926M in  10.027093s

... maybe something to tackle with later 馃

@kares kares changed the title Fix exception backtrace [fix] proper exception backtrace (and Java stack-trace) Dec 31, 2019
@kares kares changed the title [fix] proper exception backtrace (and Java stack-trace) correct/revisit exception backtrace (and stack-trace) Dec 31, 2019
Copy link

@headius headius left a comment

Looks good to me, with a couple comments on filtering that we should maybe discuss outside this PR. I assume this broke when we (probably me) reworked raise workflow to match CRuby more exactly? I know I ran benchmarks that showed force backtrace was much faster not too long ago. Very nice to have some tests that ensure we're not generating multiple traces.

Copy link

@headius headius commented Jan 7, 2020

That's a 馃憤 from me even though I submitted the review as a general comment.

@kares kares merged commit a961fb3 into jruby:master Jan 8, 2020
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants