From: "gregolsen (Innokenty Mikhailov)" Date: 2012-04-04T19:41:30+09:00 Subject: [ruby-core:44124] [ruby-trunk - Bug #6183] Enumerator::Lazy performance issue Issue #6183 has been updated by gregolsen (Innokenty Mikhailov). File new_lazy_enumerator.diff added Here's the new patch attached - problem, mentioned by Yusuke Endoh, fixed - now I'm creating a new copy of enumerator on each lazy method call. Also I fixed an error for big arrays - forgot to gc_mark procs array. Thomas, that's the point - current implementation is very simple and hence very inefficient. It mimics ruby implementations but as soon as we are in the C sources already - we can come up with something more efficient. ---------------------------------------- Bug #6183: Enumerator::Lazy performance issue https://bugs.ruby-lang.org/issues/6183#change-25651 Author: gregolsen (Innokenty Mikhailov) Status: Assigned Priority: Low Assignee: nobu (Nobuyoshi Nakada) Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-17 trunk 35075) [x86_64-linux] I benchmarked Enumerator::Lazy and that's what I got: user system total real Lazy: 0.690000 0.010000 0.700000 ( 0.733160) Normal: 0.160000 0.010000 0.170000 ( 0.186695) It seems like even with 4 chain links and 3000 elements in initial array, Lazy enumerator is almost 4(!) times slower than the normal case. Instead of performance benefit we've got 4 times performance drawback. See test file attached. -- http://bugs.ruby-lang.org/