From: Yusuke Endoh <mame@tsg.ne.jp>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:37730] [Ruby 1.9 - Bug #4962][Open] come back gem_prelude!
Date: Sat, 2 Jul 2011 14:18:35 +0900 [thread overview]
Message-ID: <redmine.issue-4962.20110702141835@ruby-lang.org> (raw)
Issue #4962 has been reported by Yusuke Endoh.
----------------------------------------
Bug #4962: come back gem_prelude!
http://redmine.ruby-lang.org/issues/4962
Author: Yusuke Endoh
Status: Open
Priority: Normal
Assignee: Eric Hodel
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-07-01 trunk 32356) [i686-linux]
Hello, rubygems developers
Kosaki-san noticed that 1.9.3 is slower than 1.9.2 on many benchmarks.
http://www.atdot.net/sp/view/5qunnl
I investigated and found that the cause is the lack of gem_prelude.rb.
Loading rubygems seems to create many objects and keep the references
to them. See below:
$ ruby -ve 'GC.start; p ObjectSpace.count_objects[:TOTAL]'
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
9821
$ ./ruby -ve 'GC.start; p ObjectSpace.count_objects[:TOTAL]'
ruby 1.9.3dev (2011-07-01 trunk 32356) [i686-linux]
19638
$ ./ruby --disable-gems -ve 'GC.start; p ObjectSpace.count_objects[:TOTAL]'
ruby 1.9.3dev (2011-07-01 trunk 32356) [i686-linux]
9821
The number of live objects is proportional to the cost of GC mark phase.
You can actually confirm the performance degradation with the following
benchmark script:
require 'tempfile'
max = 200_000
str = "Hello world! " * 1000
f = Tempfile.new('yarv-benchmark')
f.write str
GC::Profiler.enable
max.times{
f.seek 0
f.read
}
p GC::Profiler.total_time
$ time ruby -v bm_io_file_read.rb
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
0.7280460000000308
real 0m3.965s
user 0m2.940s
sys 0m1.024s
$ time ./ruby -v bm_io_file_read.rb
ruby 1.9.3dev (2011-07-01 trunk 32356) [i686-linux]
1.396088000000029
real 0m4.786s
user 0m3.716s
sys 0m1.060s
$ time ./ruby --disable-gems -v bm_io_file_read.rb
ruby 1.9.3dev (2011-07-01 trunk 32356) [i686-linux]
0.7640390000000309
real 0m4.079s
user 0m2.872s
sys 0m1.192s
The performance degradation can be seen by not only such micro benckmarks,
but also my puzzle solvers :-(
There are some approaches to address the problem:
1. to introduce a generational GC; this is impossible until 2.0 because
it requires modifications to all extension libraries.
2. to diet rubygems; do not create any string, array, hash, and any
object as much as possible, and do not keep the references to them.
3. to restore gem_prelude.rb to delay loading rubygems.
I guess that 3 is a reasonable choice for 1.9.3. But I'm fine with any
solution to fix rubygems if 1.9.3 becomes as fast as 1.9.2 on the
benchmarks.
--
Yusuke Endoh <mame@tsg.ne.jp>
--
http://redmine.ruby-lang.org
next reply other threads:[~2011-07-02 5:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-02 5:18 Yusuke Endoh [this message]
2011-07-02 14:13 ` [ruby-core:37741] [Ruby 1.9 - Bug #4962] come back gem_prelude! Luis Lavena
2011-07-02 14:48 ` [ruby-core:37743] " KOSAKI Motohiro
2011-07-02 19:40 ` [ruby-core:37746] Re: [Ruby 1.9 - Bug #4962][Open] " Roger Pack
2011-07-05 21:56 ` [ruby-core:37813] " Aaron Patterson
2011-07-05 22:01 ` [ruby-core:37814] " Luis Lavena
2011-07-05 22:19 ` [ruby-core:37815] " Aaron Patterson
2011-07-10 23:50 ` [ruby-core:37975] " Nobuyoshi Nakada
2011-07-13 5:40 ` [ruby-core:38038] " Aaron Patterson
2011-07-05 23:46 ` [ruby-core:37818] [Ruby 1.9 - Bug #4962] " Eric Hodel
2011-07-06 0:16 ` [ruby-core:37819] " KOSAKI Motohiro
2011-07-06 2:06 ` [ruby-core:37820] " Eric Hodel
2011-07-06 4:14 ` [ruby-core:37821] [Ruby 1.9 - Bug #4962][Assigned] " Eric Hodel
2011-07-06 9:48 ` [ruby-core:37824] " KOSAKI Motohiro
2011-07-06 11:57 ` [ruby-core:37826] " Yusuke ENDOH
2011-07-06 18:20 ` [ruby-core:37830] " Eric Hodel
2011-07-06 18:20 ` [ruby-core:37829] " Eric Hodel
2011-07-06 21:21 ` [ruby-core:37833] [Ruby 1.9 - Bug #4962] " Eric Hodel
2011-07-06 22:02 ` [ruby-core:37834] " Benoit Daloze
2011-07-06 22:26 ` [ruby-core:37835] " Eric Hodel
2011-07-09 0:36 ` [ruby-core:37906] " Eric Hodel
2011-07-09 4:20 ` [ruby-core:37910] " Motohiro KOSAKI
2011-07-09 4:34 ` [ruby-core:37911] " Motohiro KOSAKI
2011-07-10 23:57 ` [ruby-core:37976] [Ruby 1.9 - Bug #4962][Closed] " Motohiro KOSAKI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-4962.20110702141835@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).