martes, 21 de agosto de 2012

Fastruby 0.0.22: optimized dynamic calls

Fastruby is a gem which allows to execute ruby code much faster than normal, currently in a state of transition between a spike and a usable gem, it is released when possible with incremental improvements.

In previous post I promised to Improve speed of dynamic call lookups, this is because the speed optimization used to depend heavly on the possibility of inlining and therefore on the type information found at build-time. When no type information for method call receivers can be obtained at build-time, the method call is encoded as dynamic, and the method used to resolve dynamic calls so far was not optimal leading to results significantly worst than MRI 1.9

For example, the next code run faster because of the type information provided by lvar_type directive


class Y
  def bar(x)
    i = 1000000
    lvar_type(i,Fixnum)
   
    ret = 0
    while i > 0
      ret = x.foo(i,i)
      i = i - 1
    end
    return ret
  end
end


Else, removing lvar_type:


class Y
  def bar(x)
    i = 1000000
    #removed lvar_type
   
    ret = 0
    while i > 0
      ret = x.foo(i,i)
      i = i - 1
    end
    return ret
  end
end


Will result on this (for version without lvar_type):

Before (v0.0.21 and prior)

Now:






NOTE: When lvar_type is used, the results are the same as in v0.0.21 (see this post)

Next

No hay comentarios:

Publicar un comentario