You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Performance optimization: only compute stack traces when needed (#16616)
I noticed that `Throwable#fillInStackTrace` (which is called from the
constructor of Throwable) showed up while profiling the compiler. This
is because several data structures we use (`Diagnostic` and `TypeError`)
extend `Exception`. Since the stack trace is only used for debugging in
some rare cases and is expensive to compute, it's worth avoiding it
whenever possible. This can be done either by passing `false` to the
`writableStackTrace` constructor parameter, by overriding
`Throwable#fillInStackTrace` or by extending
`scala.util.control.NoStackTrace`.
I ended up not touching `Diagnostic` in this PR because it will be
changed in #16566 to not extend `Exception`.
0 commit comments