[#41134] [Bug:trunk] ext/tk on cygwin — Nobuyoshi Nakada <nobu@...>
なかだです。
[#41138] [Bug #3243] Can't build Ruby after r26506 — Yuki Sonoda <redmine@...>
Bug #3243: Can't build Ruby after r26506
[#41140] [Bug:trunk] the behavior of Tempfile#size was changed — Yusuke ENDOH <mame@...>
なかださん
Hi,
[#41173] [Feature #3251] allow to unlock mutex locked by another thread — Yusuke Endoh <redmine@...>
Feature #3251: allow to unlock mutex locked by another thread
[#41192] Re: [ruby-cvs:34848] Ruby:r27635 (trunk): * cont.c: apply FIBER_USE_NATIVE patch. This patch improve — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
[#41219] [ruby_1_9_2] コンパイルエラー — Takahiro Kambe <taca@...>
ruby_1_9_2ブランチのコンパイルでエラーが起きます。
[#41223] 正規表現オブジェクト中のキャプチャの数 — "KISHIMOTO, Makoto" <[email protected]>
きしもとです
[#41225] io/console IO#raw error when io is closed in the block — Tanaka Akira <akr@...>
io/console を使ってみたのですが、ちょっとうまく使えません。
2010年5月8日20:33 Tanaka Akira <[email protected]>:
[#41247] Regexpの仕様について — Masaya TARUI <tarui@...>
樽家です。
[#41259] Re: [ruby-cvs:34935] Ruby:r27723 (trunk): * ext/psych/parser.c (parse): Return strings encoded as — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
[#41278] [BUG:1.9] BINARY should not be ASCII-compatible — Yugui <yugui@...>
Yuguiです。
普段、あまりM17Nの件に反応しない卜部ですが、
2010/5/11 Urabe Shyouhei <[email protected]>:
[#41286] ruby_1_9_2 on NetBSD 5.1_RC1(+) — Takahiro Kambe <taca@...>
再び、こんばんは。
[#41316] [Bug #3295] make test aborted — Kazuhiro NISHIYAMA <redmine@...>
Bug #3295: make test aborted
チケット #3295 が更新されました。 (by Yusuke Endoh)
[#41329] NoMethodErrorなどのmessage — Masatoshi SEKI <m_seki@...>
咳といいます。
まつもと ゆきひろです
[#41334] [Bug #3307] ext/tk がheader fileの有無を誤判定する — Masaya Tarui <redmine@...>
Bug #3307: ext/tk がheader fileの有無を誤判定する
[#41348] [Bug #3316] Kernel#caller returns nil as well — Nobuhiro IMAI <redmine@...>
Bug #3316: Kernel#caller returns nil as well
遠藤です。
[#41350] [Bug #3318] net/imap/test_imap.rb reports an error on Windows — Usaku NAKAMURA <redmine@...>
Bug #3318: net/imap/test_imap.rb reports an error on Windows
[#41353] [Bug #3037] testrb の動作が1.8.7 の testrb と違いすぎる — Yusuke Endoh <redmine@...>
チケット #3037 が更新されました。 (by Yusuke Endoh)
2010年5月19日21:04 Yusuke Endoh <[email protected]>:
[#41377] [Bug #3326] ruby_1_8がAIXでコンパイルできません。 — Yutaka Kanemoto <redmine@...>
Bug #3326: ruby_1_8がAIXでコンパイルできません。
[#41382] [Feature #3328] Kernel#p outputs as default_internal encoding, and so on — Masaya Tarui <redmine@...>
Feature #3328: Kernel#p outputs as default_internal encoding, and so on
[#41407] [Bug #3339] win32ole test failure — Usaku NAKAMURA <redmine@...>
Bug #3339: win32ole test failure
助田です。
こんにちは、なかむら(う)です。
助田です。
こんにちは、なかむら(う)です。
志村と申します
[#41423] [Bug #3345] webrick test failure on Windows(?) — Usaku NAKAMURA <redmine@...>
Bug #3345: webrick test failure on Windows(?)
[#41430] [bug:trunk] rubyspec: Kernel.spawn redirects both STDERR and STDOUT to the given name ERROR — Yusuke ENDOH <mame@...>
遠藤です。
[#41452] [Bug #3360] rdoc fails when including BOM — white leaf <redmine@...>
Bug #3360: rdoc fails when including BOM
チケット #3360 が更新されました。 (by Nobuyoshi Nakada)
[#41481] [Bug #3370] test failure of drb — Usaku NAKAMURA <redmine@...>
Bug #3370: test failure of drb
[ruby-dev:41471] Re: NoMethodErrorなどのmessage
咳といいます。 まつもとさん、お返事ありがとうございます。 On 2010/05/30, at 15:19, Yukihiro Matsumoto wrote: > まつもと ゆきひろです > > In message "Re: [ruby-dev:41329] NoMethodErrorなどのmessage" > on Sun, 16 May 2010 23:06:00 +0900, Masatoshi SEKI <[email protected]> writes: > > |ちょっと前からRWikiというWiki風のアプリケーションを > |書いています。 > |たくさんのオブジェクトを参照しているRWikiのオブジェクトに、 > |irbで対話的にメッセージを送ることがよくあるのですが、 > |その際にメソッド名を間違えるととても長い時間待たされて > |困っています。 > > もうちょっと状況を説明してください。 > > まず、inspectを避けるかどうかを考える前に、NameError系はまさ > にこのような「とても長い」処理を避けるために、to_strを遅延し > ています。例外を印字しようとするなど明示的に要求しない限り、 > to_strを呼ばないはずです。ということは、本来 > > |この関数はMarshalの際にも呼ばれるようで、dRubyで例外が > |あがる際にもエラーを印字しない場合にも長い時間がかかります。 > > のように「印字しない場合にも呼ばれる」ということは起きないは > ずです。にもかかわらず、長い時間がかかると言うのは、dRubyが無 > 駄にmessageを取り出しているのではないでしょうか。でなければ、 > バグです。まずはここから考えたいです。 > > あと、「とても長い」も興味深い点です。これは1回1回の時間はさ > ほどでもないが、繰り返すので蓄積されて結果的に「とても長い」 > のでしょうか、それともdRubyの性質上、inspectが内部で呼び出す > to_sなどがネットワークを越えるので、「とても長い」のでしょう > か。もし、後者であれば、dRuby側でプロクシーに仕掛けをして > dRubyオブジェクトのinspectはネットワークを越えないようにする > 手もありますよね。 > とても長いっぷりは、RWikiのプロセスが1Gを超えるんですが その根になるオブジェクトへのNoMethodErrorのときなどに とても待たされます、って感じです。 自信の無さには自信があるので、最初にdRubyを疑いましたが、 リモートでなくても遅いようです。 nme.rb -- a = Array.new(ARGV.shift.to_i) begin a.foo rescue Marshal.dump($!) end -- こんなのを書いて、profileとるとinspectが呼ばれているのがわかります。 % ruby -r profile nme.rb 10000 % cumulative self self total time seconds seconds calls ms/call ms/call name 59.26 0.16 0.16 1 160.00 260.00 Array#inspect 37.04 0.26 0.10 10000 0.01 0.01 NilClass#inspect 3.70 0.27 0.01 1 10.00 10.00 Symbol#to_s 0.00 0.27 0.00 1 0.00 0.00 Class#new 0.00 0.27 0.00 1 0.00 0.00 NoMethodError#initialize 0.00 0.27 0.00 1 0.00 0.00 Exception#exception 0.00 0.27 0.00 1 0.00 0.00 NameError::message#! 0.00 0.27 0.00 1 0.00 0.00 Exception#backtrace 0.00 0.27 0.00 1 0.00 0.00 String#to_i 0.00 0.27 0.00 1 0.00 0.00 NameError#initialize 0.00 0.27 0.00 1 0.00 270.00 Marshal.dump 0.00 0.27 0.00 1 0.00 0.00 Kernel.method_missing 0.00 0.27 0.00 1 0.00 0.00 Exception#set_backtrace 0.00 0.27 0.00 1 0.00 0.00 Exception#initialize 0.00 0.27 0.00 1 0.00 270.00 NameError::message#_dump 0.00 0.27 0.00 1 0.00 0.00 Array#initialize 0.00 0.27 0.00 1 0.00 0.00 Array#shift 0.00 0.27 0.00 1 0.00 270.00 #toplevel % ruby -r profile nme.rb 1 % cumulative self self total time seconds seconds calls ms/call ms/call name 0.00 0.00 0.00 1 0.00 0.00 Array#inspect 0.00 0.00 0.00 1 0.00 0.00 Kernel.method_missing 0.00 0.00 0.00 1 0.00 0.00 Marshal.dump 0.00 0.00 0.00 1 0.00 0.00 String#to_i 0.00 0.00 0.00 1 0.00 0.00 NoMethodError#initialize 0.00 0.00 0.00 1 0.00 0.00 Exception#exception 0.00 0.00 0.00 1 0.00 0.00 NameError::message#! 0.00 0.00 0.00 1 0.00 0.00 Exception#backtrace 0.00 0.00 0.00 1 0.00 0.00 Class#new 0.00 0.00 0.00 1 0.00 0.00 NameError#initialize 0.00 0.00 0.00 1 0.00 0.00 Symbol#to_s 0.00 0.00 0.00 1 0.00 0.00 NilClass#inspect 0.00 0.00 0.00 1 0.00 0.00 Exception#set_backtrace 0.00 0.00 0.00 1 0.00 0.00 Exception#initialize 0.00 0.00 0.00 1 0.00 0.00 NameError::message#_dump 0.00 0.00 0.00 1 0.00 0.00 Array#initialize 0.00 0.00 0.00 1 0.00 0.00 Array#shift 0.00 0.01 0.00 1 0.00 10.00 #toplevel で、Marshal.dumpをコメントアウトすると次のようにinspectは呼ばれません。 nme2.rb -- a = Array.new(ARGV.shift.to_i) begin a.foo rescue # Marshal.dump($!) end -- % ruby -r profile nme2.rb 10000 % cumulative self self total time seconds seconds calls ms/call ms/call name 0.00 0.00 0.00 1 0.00 0.00 Kernel.method_missing 0.00 0.00 0.00 1 0.00 0.00 String#to_i 0.00 0.00 0.00 1 0.00 0.00 NoMethodError#initialize 0.00 0.00 0.00 1 0.00 0.00 Exception#exception 0.00 0.00 0.00 1 0.00 0.00 NameError::message#! 0.00 0.00 0.00 1 0.00 0.00 Exception#backtrace 0.00 0.00 0.00 1 0.00 0.00 Class#new 0.00 0.00 0.00 1 0.00 0.00 NameError#initialize 0.00 0.00 0.00 1 0.00 0.00 Exception#set_backtrace 0.00 0.00 0.00 1 0.00 0.00 Exception#initialize 0.00 0.00 0.00 1 0.00 0.00 Array#initialize 0.00 0.00 0.00 1 0.00 0.00 Array#shift 0.00 0.01 0.00 1 0.00 10.00 #toplevel > |それで提案です。 > | > |inspectは呼ばずに、いつもrb_any_to_s()、あるいは > | > |#<クラス名:オブジェクトid> > | > |の形式(なんていうの?)をメッセージに入れるのはどうで > |しょうか? > > それだとnilやfalse、Fixnumのようなものまで > > #<クラス名:オブジェクトid> > > になっちゃいますからねえ。 それで、error.cのname_err_mesg_to_str()を読みました。 1.8系はこんな感じです。1.9もほぼ同様です。 nil, true, falseはケアされてるみたい。 default:でinspectをした後に長さを数え、 それが長いときにrb_any_to_s()してるところが あります。 d = rb_protect(rb_inspect, obj, 0); if (NIL_P(d) || RSTRING(d)->len > 65) { d = rb_any_to_s(obj); } これを d = rb_any_to_s(obj); としていただけませんか、という提案です。 Marshal.dumpのほうは、 rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1); が関係あるのかなあと想像してます。 /* :nodoc: */ static VALUE name_err_mesg_to_str(obj) VALUE obj; { VALUE *ptr, mesg; Data_Get_Struct(obj, VALUE, ptr); mesg = ptr[0]; if (NIL_P(mesg)) return Qnil; else { const char *desc = 0; VALUE d = 0, args[3]; obj = ptr[1]; switch (TYPE(obj)) { case T_NIL: desc = "nil"; break; case T_TRUE: desc = "true"; break; case T_FALSE: desc = "false"; break; default: d = rb_protect(rb_inspect, obj, 0); if (NIL_P(d) || RSTRING(d)->len > 65) { d = rb_any_to_s(obj); } desc = RSTRING(d)->ptr; break; } if (desc && desc[0] != '#') { d = rb_str_new2(desc); rb_str_cat2(d, ":"); rb_str_cat2(d, rb_obj_classname(obj)); } args[0] = mesg; args[1] = ptr[2]; args[2] = d; mesg = rb_f_sprintf(3, args); } if (OBJ_TAINTED(obj)) OBJ_TAINT(mesg); return mesg; }