From: Paul Brannan Date: 2007-11-07T05:49:46+09:00 Subject: Re: performance problem in 1.9 On Wed, Nov 07, 2007 at 04:22:19AM +0900, murphy wrote: > Paul Brannan wrote: > > I tried running 1.9 with -Ka and got the same results. > this is because the new encoding-aware methods are not optimized for > ASCII. it's really an issue. people expect Ruby 1.9 to be faster, not > slower. > [murphy] This doesn't explain, however, why execution duration increases non-linearly with respect to number of lines read. Even in a non-ascii encoding I wouldn't expect this behavior. For another experiment, I reverted to 20070824, which is before encoding.c was added, and re-ran the test: N 1.8 1.9 1000 0.087897 0.053321 2000 0.131613 0.097194 3000 0.211627 0.147591 4000 0.256672 0.195254 5000 0.318637 0.24071 6000 0.399293 0.303332 7000 0.453675 0.340333 8000 0.533178 0.378996 9000 0.637222 0.458902 10000 0.746804 0.490422 20000 1.370529 1.017592 30000 2.2133 1.700587 40000 2.843482 2.385207 50000 3.413713 2.902308 60000 4.144835 3.68966 70000 4.923352 4.457369 80000 5.647614 5.343812 90000 6.537824 6.248752 100000 7.245902 7.046532 200000 13.818056 18.446034 300000 20.71837 34.295005 400000 27.073161 53.57605 500000 34.938478 79.189373 So I still suspect that this is not related to M17N. I can also comment out the body of the while loop and get similar results: [pbrannan@zem tmp]$ cat test.rb t = Time.now while line = $stdin.gets do end print "#{(Time.now - t).to_f} " N 1.8 1.9 1000 0.003087 0.007534 2000 0.005437 0.01018 3000 0.011527 0.011794 4000 0.016189 0.010016 5000 0.018974 0.020079 6000 0.017216 0.021615 7000 0.025385 0.017993 8000 0.02577 0.023702 9000 0.027658 0.022724 10000 0.030802 0.034038 20000 0.079975 0.062713 30000 0.109732 0.072577 40000 0.132026 0.09485 50000 0.195151 0.119758 60000 0.24444 0.132599 70000 0.237653 0.158722 80000 0.289722 0.185829 90000 0.302497 0.204738 100000 0.381064 0.233099 200000 0.712633 0.477481 300000 1.085363 0.751782 400000 1.423243 1.008157 500000 1.804591 1.331532 1000000 3.547251 2.917445 5000000 18.105158 30.337461 6000000 21.327796 41.172421 So maybe the problem is in IO#gets? But I don't see any differences there that would cause this behavior. Paul