拿hessian2测了一下,2.1性能比2.0有一成的提升!
windows上安装:
1.自己HOST有ruby,有rake和rb-readline
2.
git clone https://github.com/oneclick/rubyinstaller.git
cd rubyinstaller
rake devkit:ls
DKVER=mingw64-32-4.7.2 rake ruby21
3.
cp sandbox/devkit /e/
cp sandbox/ruby21_mingw/* /e/devkit/
4. E:\devkit\bin;E:\devkit\mingw\bin;加进PATH
5. mingw版的so要对2.1重新做
eventmachine
git clone https://github.com/eventmachine/eventmachine.git
cd eventmachine
git checkout v1.0.3
cd ext
ruby extconf.rb && make
cp rubyeventmachine.so "E:\devkit\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3-x86-mingw32\lib\2.1\"
cd fastfilereader
ruby extconf.rb && make
cp fastfilereaderext.so "E:\devkit\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3-x86-mingw32\lib\2.1\"
nokogiri
wget http://mirror.anl.gov/pub/gnu/libiconv/libiconv-1.14.tar.gz
cd libiconv-1.14 && ./configure --prefix=/mingw && make && make install
wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
cd libxml2-2.9.1 && ./configure --without-python --prefix=/mingw && make && make install
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.28.tar.gz
cd libxslt-1.1.28
# libxslt/security.c line 346 调mkdir方法第二个参数擦掉
./configure --without-python --prefix=/mingw && make && make install
cd "E:\devkit\lib\ruby\gems\2.1.0\gems\nokogiri-1.6.1-x86-mingw32\ext\nokogiri"
ruby extconf.rb --with-xml2-include="E:\devkit\mingw\include\libxml2" --with-xslt-include="E:\devkit\mingw\include" && make
装gem报错,在gem目录/ext/mkmf.log里看到:
error: redefinition of 'struct timespec'
解决:这是由于DKVER和ruby21不匹配,把rubyinstaller/sandbox/下devkit, ruby21_build, ruby21_mingw删了,再DKVER=mingw64-32-4.7.2 rake ruby21
卸gem报错:
Continue with Uninstall? [yN] e:/devkit/lib/ruby/2.1.0/rubygems/user_interaction.rb:286: [BUG] Segmentation fault
解决:不要用conemu,推荐wintabber
有些POSIX的头文件win32 API不支持(mingw是基于win32 API的),如sys/socket.h,要用替代方案:
if RUBY_PLATFORM =~ /mingw/
gem 'eventmachine'
gem 'thin'
gem 'redis'
else
gem 'unicorn'
gem 'hiredis', '~> 0.4.0'
gem "redis", '>= 2.2.0', require: %w[ redis redis/connection/hiredis ]
end
rbenv的It seems your ruby installation is missing psych:
http://stackoverflow.com/questions/12882190/unable-to-resolve-ruby-error-missing-psych
invalid byte sequence in GBK:
常见原因是,抛异常的代码周围几行有中文,rack-1.5.2/lib/rack/showexceptions.rb试图用Erb的h方法把它们显示到页面上,Encoding根据环境用GBK去解释这个utf8的中文导致。解决办法是把环境编码设成utf8:
bash
export RUBYOPT=-Ku
cmd
chcp 65001
根据c编译器,ruby被编译成对应的平台版本,默认用cc、gcc编译出来是无标识的,有标识的如freebsd、mingw32、cygwin、mswin32-60(vc6.0)、mswin32-100(vc10.0)、darwin-11(Mac)等。
扩展c的gem平台版本必须和ruby一致。用vc10编译出来的ruby,不能用mswin32-60版的gem。
benchmark
https://github.com/acangiano/ruby-benchmark-suite
总体上 linux快于 freebsd,mingw快于 win32和cygwin。