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

0.8 ActiveModel::Serializer _fast_attributes - raise NameError without backtrace #1305

Closed
wants to merge 1 commit into from

Conversation

kml
Copy link

@kml kml commented Oct 28, 2015

For this test I'm getting ~x2 improvement on JRuby.
NameError is used internally for flow controll. Backtrace is not needed, so I'm not raising it.
Links: https://github.com/jruby/jruby/wiki/BacktraceGeneration https://www.coffeepowered.net/2011/06/17/jruby-performance-exceptions-are-not-flow-control/

u is istance of User class from bench/perf.rb

serializers = []

10_000.times do
  serializers << Class.new(ActiveModel::Serializer) do
    attributes :id, :name
  end
end

Benchmark.bm do |x|
  x.report("serializable_hash") do
    serializers.each do |serializer|
      serializer.new(u).serializable_hash
    end
  end
end

without patch:

$ jruby -S rake bench
Resolving dependencies.....
       user     system      total        real
serializable_hash 10.300000   0.610000  10.910000 (  7.324000)

with:

$ jruby -S rake bench
Resolving dependencies.....
       user     system      total        real
serializable_hash  6.470000   0.480000   6.950000 (  3.249000)

@bf4
Copy link
Member

bf4 commented Feb 15, 2016

The build for 0.8 should be fixed if you don't mind rebasing this and force pushing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants