Project

General

Profile

Bug #17101

YAML.load_file: Massive slowdown under Ruby 2.7 vs. Ruby 2.4

Added by fitmap (Justin Peal) 3 months ago. Updated 3 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]
[ruby-core:99454]

Description

When use Ruby 2.4, the following program runs fast, After ungrade to Ruby 2.7, the same program runs very very slow. Please unzip the attach first for test.

require 'yaml'
YAML.load_file('qlnv_h_h.yaml')


Files

qlnv_h_h.7z (1.41 MB) qlnv_h_h.7z 7z unzip first fitmap (Justin Peal), 08/03/2020 03:15 PM

Updated by MSP-Greg (Greg L) 3 months ago

You used the phrase 'runs very very slow'. I found 2.7 slower, as below. What were the times you had?

Using Psych.safe_load, got the following for several mingw builds, along with an mswin master build.

All returned a hash with 608 keys. Tests done on an older slow notebook.

Interesting that the mswin build was much faster than all the others. I should run some of the Ruby benchmarks, as that was unexpected.

Time  Psych  Ruby
 19   2.2.2  2.4.10
 41   3.0.2  2.5.8
 38   3.1.0  2.6.6
 26   3.1.0  2.7.1
 25   3.1.0  2.8.0dev (2020-08-03T10:46:39Z master 1d637b1f5e) [x64-mingw32]
 12   3.1.0  2.8.0dev (2020-08-03T10:46:39Z master 1d637b1f5e) [x64-mswin64_140]

Updated by S_H_ (Shun Hiraoka) 3 months ago

I tried this benchmark in several ruby's(Ubuntu18.04 in WSL2. using rbenv).

prelude: |
  require 'yaml'
benchmark: 
  load_file: YAML.load_file('qlnv_h_h.yaml')
loop_count: 1

And, result.

sh@MyComputer:~/rubydev/bugs$ benchmark-driver yml.yaml --output compare --rbenv '2.4.4;2.5.8;2.6.6;2.7.1;2.8.0-dev'
Calculating -------------------------------------
                          2.4.4       2.5.8       2.6.6       2.7.1   2.8.0-dev 
           load_file      0.113       0.075       0.076       0.058       0.134 i/s -       1.000 times in 8.839451s 13.406090s 13.240691s 17.256679s 7.435239s

Comparison:
                        load_file
           2.8.0-dev:         0.1 i/s 
               2.4.4:         0.1 i/s - 1.19x  slower
               2.6.6:         0.1 i/s - 1.78x  slower
               2.5.8:         0.1 i/s - 1.80x  slower
               2.7.1:         0.1 i/s - 2.32x  slower

Between 2.5 and 2.7 is slow, but master(2.8.9-dev) is very fast(faster than 2.4!).

And checked yaml versions(in these ruby's).

Ruby version YAML version
2.8.0-dev 0.2.5
2.7.1 0.2.1
2.6.6 0.2.1
2.5.8 0.1.7
2.4.4 0.1.7

Updated by fitmap (Justin Peal) 3 months ago

I run this program on Windows 10 64-bit. Very very slow: I wait more than 10 minutes, then I press Ctrl-Break. Now I install Ruby 2.6, then the program runs as fast as Ruby 2.4.

Also available in: Atom PDF