Java Loves Ruby
Blah blah blah:
Sky -
Beige -
Simple -
Serif -
Night -
Default
# JAVA_OPTS="-client -Djruby.compile.mode=OFF" \
bundle exec rails server
# JRUBY_OPTS="--1.9 -J-XX:+CMSClassUnloadingEnabled \
-J-XX:+UseConcMarkSweepGC \
-J-XX:MaxPermSize=256m -J-Xmx1800m" \
bundle exec rails server
# jruby --ng-server &
# bundle exec rails server
$ time bundle exec rake environment
real 0m19.876s
user 0m18.244s
sys 0m0.764s
$ time rake environment
real 0m13.322s
user 0m9.979s
sys 0m2.817s
# strace rake environment 2>&1 | grep ENOENT
...
open("x/ldap_fluff-0.1.3/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/net-ldap-0.3.1/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/jshintrb-0.2.1/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/js-routes-0.6.2/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/jammit-0.6.5/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/yui-compressor-0.9.6/lib/singleton.rb", O_RDONLY) = -1 ENOENT
open("x/i18n_data-0.3.3/lib/singleton.rb", O_RDONLY) = -1 ENOENT
...
# bundle install | wc -l
120
# strace bundle exec rake environment 2>&1 | grep ENOENT | wc -l
4023
# strace bundle exec rake environment 2>&1 | grep ENOENT | wc -l
172342
File.open("thefile.bin", 'wb') do |f|
f.write(stuff)
end
if defined? JRUBY_VERSION
gem 'activerecord-jdbc-adapter'
gem 'jdbc-postgres',
gem 'activerecord-jdbcpostgresql-adapter',
else
gem 'pg'
end
ERROR undefined method `collect' for "created_at DESC":String (NoMethodError)
.../activerecord-jdbc-adapter-1.2.6/lib/arjdbc/postgresql/adapter.rb:620:in `distinct'
...
# yum -y install \
systemtap \
systemtap-runtime \
kernel-debuginfo-`uname -r` \
kernel-debuginfo-common-`uname -i`-`uname -r` \
kernel-devel-`uname -r`
# touch /test
# ls -i /test
274
# ll /dev/md-0
brw-rw----. 1 root disk 253, 0 Apr 17 10:23 /dev/dm-0
# cat filechange.stp
global ATTR_MODE = 1
probe kernel.function("setattr_copy")!,
kernel.function("generic_setattr")!,
kernel.function("inode_setattr") {
dev_nr = $inode->i_sb->s_dev
inode_nr = $inode->i_ino
if (dev_nr == MKDEV($1,$2) # major/minor device
&& inode_nr == $3
&& $attr->ia_valid & ATTR_MODE)
printf ("%d %s(%d) %s 0x%x/%u %o %d\n",
gettimeofday_us(), execname(), pid(), probefunc(),
dev_nr, inode_nr, $attr->ia_mode, uid())
}
# stap -v filechange.stp 253 0 274 &
# chmod 600 /test
1334676922011223 chmod(6157) generic_setattr 0xfd00000/274 100600 0
# cat factorial.rb
def factorial n
f = 1; for i in 1..n; f *= i; end; f
end
puts factorial 42
# cat calls.stp
probe ruby.function.entry
{
printf("%s => %s.%s in %s:%d\n", thread_indent(1),
classname, methodname, file, line);
}
probe ruby.function.return
{
printf("%s <= %s.%s in %s:%d\n", thread_indent(-1),
classname, methodname, file, line);
}
# stap calls.stp -c "ruby factorial.rb"
1405006117752879898543142606244511569936384000000000
0 ruby(16160): => Module.method_added in factorial.rb:1
13 ruby(16160): <= Module.method_added in factorial.rb:1
0 ruby(16160): => Object.factorial in factorial.rb:5
25 ruby(16160): => Range.each in factorial.rb:2
61 ruby(16160): => Fixnum.* in factorial.rb:2
...
705 ruby(16160): <= Bignum.* in factorial.rb:2
712 ruby(16160): <= Range.each in factorial.rb:2
718 ruby(16160): <= Object.factorial in factorial.rb:2
0 ruby(16160): => Object.puts in factorial.rb:5
20 ruby(16160): => Bignum.to_s in factorial.rb:5
38 ruby(16160): <= Bignum.to_s in factorial.rb:5
53 ruby(16160): => IO.write in factorial.rb:5
74 ruby(16160): <= IO.write in factorial.rb:5
81 ruby(16160): => IO.write in factorial.rb:5
99 ruby(16160): <= IO.write in factorial.rb:5
106 ruby(16160): <= Object.puts in factorial.rb:5
# cat rubycount.stp
global fn_calls;
probe ruby.function.entry
{
fn_calls[classname, methodname] <<< 1;
}
probe end {
foreach ([classname, methodname] in fn_calls- limit 30) {
printf("%dx %s.%s\n",
@count(fn_calls[classname, methodname]),
classname, methodname);
}
delete fn_calls;
}
# stap rubycount.stp -c "ruby factorial.rb"
1405006117752879898543142606244511569936384000000000
21x Bignum.*
21x Fixnum.*
2x IO.write
1x Module.method_added
1x Range.each
1x Bignum.to_s
1x Object.puts
1x Object.factorial
# cat ./ruby-top-modified.stp
global fn_calls[10240];
probe ruby.function.entry {
if (isinstr(file, "katello")) fn_calls[pid(),
file, methodname, line] <<< 1;
}
probe timer.ms(4000) {
ansi_clear_screen()
printf("%6s %80s %6s %25s %6s\n",
"PID", "FILENAME", "LINE", "FUNCTION", "CALLS")
foreach ([pid,filename,funcname,lineno] in fn_calls- limit 15) {
printf("%6d %80s %6d %25s %6d\n",
pid, filename, lineno, funcname,
@count(fn_calls[pid, filename, funcname, lineno]));
}
delete fn_calls;
}
# cat Gemfile
gem 'rails', '3.0.10'
gem 'json'
gem 'rest-client', :require => 'rest_client'
gem 'jammit', '>= 0.5.4'
gem 'rails_warden', '>= 0.5.2'
gem 'net-ldap'
gem 'oauth'
gem 'ldap_fluff'
if File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
require 'bundler_ext'
BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :group1, :group2, Rails.env)
else
Bundler.require :group1, :group2, Rails.env
end