I was wondering if we can replace our Atom N270-based nettops that run Rails (ruby 1.8.6 ...) webapp with some equivalent ARM-based device (we like installation without a fan, power consumption, etc.) .
The ARM device was XScale-PXA270 @ 520, 128 MB (and possibly some slower SDRAMs), running under Linux, there was always enough free memory with comparable performance, like a jailbroken iPhone.
Benchmarking the production database (SQLite) gave us promising results (ARM was just 20-30% slower), so I tried to create a ruby (1.9.2p0).
The rails application started up slowly on ARM (fetching from sql and generating templates 10-20x slower). I decided to run some tests to find bottlenecks.
Again, some of the results were fine (along with the old ruby 1.8.6, which we are using now, 6x slower than ruby 1.9.2), and some were very slow (20-30 times slower). Fe. ARM hash methods seem to be 40 times slower. The launch of the Ruby Benchmark Suite revealed more bottlenecks, strings, threads, arrays ...
I knew that ARM was slower than Atom, I just did not expect such a huge difference, especially after SQLite worked fine.
Is there a drawback with Ruby on ARM, do I need to apply some corrections, is it hopeless and should rewrite the entire application in C if I want to use an ARM device, or simply the device does not have enough processing power?
<strong> Examples
def fib(n)
return 1 if n < 2
fib(n-1)+fib(n-2)
end
Benchmark.bm do |x|
x.report { fib(32) }
x.report { fib(36) }
x.report { h = {}; (0..10**3).each {|i| h[i] = i} }
x.report { h = {}; (0..10**4).each {|i| h[i] = i} }
x.report { h = {}; (0..10**5).each {|i| h[i] = i} }
end
ruby -rbenchmark bench.rb
Atom N270, 1 GB
ruby 1.9.2p0 (2010-08-18) [i686-linux]
user system total real
2.440000 0.000000 2.440000 ( 2.459400)
16.780000 0.030000 16.810000 ( 17.293015)
0.000000 0.000000 0.000000 ( 0.001180)
0.020000 0.000000 0.020000 ( 0.012180)
0.160000 0.000000 0.160000 ( 0.161803)
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]
user system total real
12.500000 0.020000 12.520000 ( 12.628106)
84.450000 0.170000 84.620000 ( 85.879380)
0.010000 0.000000 0.010000 ( 0.002216)
0.040000 0.000000 0.040000 ( 0.032939)
0.240000 0.010000 0.250000 ( 0.255756)
XScale-PXA270 @520, 128
ruby 1.9.2p0 (2010-08-18) [arm-linux]
user system total real
12.470000 0.000000 12.470000 ( 12.526507)
85.480000 0.000000 85.480000 ( 85.939294)
0.060000 0.000000 0.060000 ( 0.060643)
0.640000 0.000000 0.640000 ( 0.642136)
6.460000 0.130000 6.590000 ( 6.605553)
:
./configure --host=arm-linux --without-X11 --disable-largefile \
--enable-socket=yes --without-Win32API --disable-ipv6 \
--disable-install-doc --prefix=/opt --with-openssl-include=/opt/include/ \
--with-openssl-lib=/opt/include/lib
ENV:
PFX=arm-iwmmxt-linux-gnueabi
export DISCIMAGE="/opt"
export CROSS_COMPILE="arm-linux-"
export HOST="arm-linux"
export TARGET="arm-linux"
export CROSS_COMPILING=1
export CC=$PFX-gcc
export CFLAGS="-O3 -I/opt/include"
export LDFLAGS="-O3 -L/opt/lib/"
#LIBS=
#CPPFLAGS=
export CXX=$PFX-g++
#CXXFLAGS=
export CPP=$PFX-cpp
export OBJCOPY="$PFX-objcopy"
export LD="$PFX-ld"
export AR="$PFX-ar"
export RANLIB="$PFX-ranlib"
export NM="$PFX-nm"
export STRIP="$PFX-strip"
export ac_cv_func_setpgrp_void=yes
export ac_cv_func_isinf=no
export ac_cv_func_isnan=no
export ac_cv_func_finite=no