Skip to content

Instantly share code, notes, and snippets.

@billdueber
Last active December 23, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billdueber/6554154 to your computer and use it in GitHub Desktop.
Save billdueber/6554154 to your computer and use it in GitHub Desktop.
jruby +indy object creation much slower
indy slowdown was due to me havint JRUBY_OPTS include -J-XX:+TieredCompilation and
-J-XX:TieredStopAtLevel=1, supposedly to make startup faster. Removing them
removes the performance issue. Jira ticket closed.
# Benchmark object creation with/without indy. Call with the word "true" or "false" as the only argument, corresponding
# to how indy is set, e.g.
#
# for i in 1 2 3 4;
# do for indy in true false;
# do jruby --server -Xcompile.invokedynamic=$indy obj_creation_bench.rb $indy;
# done;
# done
require 'benchmark'
require 'benchmark/ips'
seconds = 30 # Test for this long
subobjects = [1, 10, 100] # Create this many subobjects (B) added to primary object (A)
class A
attr_accessor :subs
def initialize
@subs = []
end
def add(i)
subs << B.new(i)
end
def add_a_bunch(t)
t.times do |i|
add(i)
end
end
end
class B
def initialize(i)
@int = i
end
end
puts RUBY_DESCRIPTION
indy = ARGV[0]
Benchmark.ips(seconds) do |x|
subobjects.each do |so|
x.report("indy=#{indy} #{so} objs") do
a = A.new
a.add_a_bunch(so)
end
end
end
puts "\n\n"
> jruby -v
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
# Create a simple object, then create a number of subobjects and add them to the main object.
# Averaged out results over five runs (passing 30 seconds to Benchmark.ips),
# calling with -Xcompile.invokedynamic=true / false appropriately
#sobjs +indy i/s noindy i/s
1 202_266.0 925_029.8
10 57_060.4 264_968.8
100 7_098.6 32_453.0
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
Calculating -------------------------------------
indy=true 1 objs 9150 i/100ms
indy=true 10 objs 4111 i/100ms
indy=true 100 objs 640 i/100ms
-------------------------------------------------
indy=true 1 objs 193809.6 (±2.8%) i/s - 5810250 in 30.004000s
indy=true 10 objs 54932.4 (±2.1%) i/s - 1648511 in 30.024000s
indy=true 100 objs 6818.3 (±2.1%) i/s - 204800 in 30.050000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 [darwin-x86_64]
Calculating -------------------------------------
indy=false 1 objs 22165 i/100ms
indy=false 10 objs 15336 i/100ms
indy=false 100 objs 2902 i/100ms
-------------------------------------------------
indy=false 1 objs 959355.5 (±4.6%) i/s - 28703675 in 30.006000s
indy=false 10 objs 263968.8 (±2.6%) i/s - 7913376 in 30.003000s
indy=false 100 objs 31526.5 (±1.7%) i/s - 946052 in 30.017000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
Calculating -------------------------------------
indy=true 1 objs 9084 i/100ms
indy=true 10 objs 4352 i/100ms
indy=true 100 objs 688 i/100ms
-------------------------------------------------
indy=true 1 objs 204318.1 (±2.2%) i/s - 6131700 in 30.026000s
indy=true 10 objs 59117.9 (±2.3%) i/s - 1775616 in 30.055000s
indy=true 100 objs 7403.3 (±2.0%) i/s - 222224 in 30.032000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 [darwin-x86_64]
Calculating -------------------------------------
indy=false 1 objs 22306 i/100ms
indy=false 10 objs 15810 i/100ms
indy=false 100 objs 3223 i/100ms
-------------------------------------------------
indy=false 1 objs 921170.0 (±4.2%) i/s - 27570216 in 29.987000s
indy=false 10 objs 278675.8 (±2.0%) i/s - 8363490 in 30.024000s
indy=false 100 objs 35031.3 (±1.7%) i/s - 1050698 in 30.002000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
Calculating -------------------------------------
indy=true 1 objs 9146 i/100ms
indy=true 10 objs 4471 i/100ms
indy=true 100 objs 712 i/100ms
-------------------------------------------------
indy=true 1 objs 204823.5 (±1.9%) i/s - 6146112 in 30.018000s
indy=true 10 objs 59611.8 (±1.6%) i/s - 1788400 in 30.009000s
indy=true 100 objs 7536.0 (±1.2%) i/s - 226416 in 30.049000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 [darwin-x86_64]
Calculating -------------------------------------
indy=false 1 objs 22845 i/100ms
indy=false 10 objs 14560 i/100ms
indy=false 100 objs 2545 i/100ms
-------------------------------------------------
indy=false 1 objs 857788.7 (±3.4%) i/s - 25700625 in 29.998001s
indy=false 10 objs 227483.5 (±2.0%) i/s - 6828640 in 30.030000s
indy=false 100 objs 27001.0 (±2.0%) i/s - 811855 in 30.080000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
Calculating -------------------------------------
indy=true 1 objs 9033 i/100ms
indy=true 10 objs 4392 i/100ms
indy=true 100 objs 697 i/100ms
-------------------------------------------------
indy=true 1 objs 213573.9 (±2.7%) i/s - 6404397 in 30.010000s
indy=true 10 objs 59031.6 (±1.6%) i/s - 1774368 in 30.066000s
indy=true 100 objs 7323.4 (±2.1%) i/s - 219555 in 29.996000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 [darwin-x86_64]
Calculating -------------------------------------
indy=false 1 objs 22210 i/100ms
indy=false 10 objs 15690 i/100ms
indy=false 100 objs 3139 i/100ms
-------------------------------------------------
indy=false 1 objs 904297.1 (±4.1%) i/s - 27051780 in 29.981001s
indy=false 10 objs 273873.8 (±2.7%) i/s - 8221560 in 30.047000s
indy=false 100 objs 34443.6 (±1.4%) i/s - 1035870 in 30.080000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 +indy [darwin-x86_64]
Calculating -------------------------------------
indy=true 1 objs 8696 i/100ms
indy=true 10 objs 3958 i/100ms
indy=true 100 objs 606 i/100ms
-------------------------------------------------
indy=true 1 objs 194807.7 (±1.9%) i/s - 5843712 in 30.008000s
indy=true 10 objs 52611.9 (±1.6%) i/s - 1579242 in 30.025000s
indy=true 100 objs 6413.0 (±1.5%) i/s - 192708 in 30.056000s
jruby 1.7.5.dev (1.9.3p392) 2013-09-10 9edc566 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-ea-b27 [darwin-x86_64]
Calculating -------------------------------------
indy=false 1 objs 22106 i/100ms
indy=false 10 objs 15957 i/100ms
indy=false 100 objs 3211 i/100ms
-------------------------------------------------
indy=false 1 objs 982539.6 (±4.9%) i/s - 29378874 in 29.996000s
indy=false 10 objs 280845.6 (±2.8%) i/s - 8425296 in 30.025000s
indy=false 100 objs 34264.6 (±1.8%) i/s - 1027520 in 29.998000s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment