Skip to content

set_backtrace should disable backtrace generation on raise #5605

@headius

Description

@headius

Reported by @jeremyevans while improving perf of no-trace flow control exceptions.

The following benchmarks should perform roughly the same. Instead, the one with set_backtrace performs more like a normal exception with a full backtrace.

3-argument raise:

loop do
  t = Time.now
  1000000.times do
    begin
      raise(Exception, '', [])
    rescue Exception
    end
  puts Time.now - t
end

set_backtrace:

loop do
  t = Time.now
  1000000.times do
    begin
      e = Exception.new
      e.set_backtrace([])
      raise e
    rescue Exception
    end
  puts Time.now - t
end

There's some logic missing in JRuby to avoid generating a backtrace if one is manually set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions