Issue #6440 has been updated by Glass_saga (Masaki Matsushita).

File patch2.diff added

???????????????????????????茯??翠???????????????茯?炊??罕?????????????帥?障????????

????????????????????????????????????????n荀?膣????Array???m????障?ц???????????????с??????????<??筝?莇潟???????翫???????
絨????????n - m ?????ゃ??????茯?帥?с?????篋????篆?荐若???????障?????

Array????????鴻??????????????翫??????????????????眼??????Array???≪??????n - m ?????ゃ??茯??篋??????с????障????????
??????蚊??ゅ????眼??Array???≪??????????????????眼??Array???ゃ??????茯?帥??????????鴻?ф?≪??1荀?膣?茯????с????障?c?????????с??
n - m - 1 ?????ゃ?????茯?帥?????篋??????с????障?????????????????紊???眼??Array???≪?????????罕???с?????
緇???c??????????????眼??Array????n - m ?????ゃ?????茯?帥?????篋??????с???????????篁ュ?????n - m - 1 ?????ゃ?????茯?帥?????篋??????с????障?????

篁????????struct load_arg???readable??????????絨????????篏??????ゃ?????茯?帥?с??????????????茵????<?潟?????菴遵????????篋???????障????????
r_object0()???type???ARRAY??с???????翫???????arg->readable???len - 1???莇潟?????1荀?膣?茯??罸???????<?潟???????障?????
??????????n - m - 1?????ゃ????絲上??????障?????

???????????<??筝?莇潟???????翫???????arg->readable + 1?????ゃ?????茯?帥?с????障?????
arg->readable + 1???????????????????????眼??Array???≪?????????n - m?????ゃ?????茯?帥?????篋????後???????障?????

Hash???Struct???≪?????????罕?????????茵????c?????障?????
????????????????????????1荀?膣????????????2?????ゃ??????荀??????arg->readable????(len - 1) * 2???莇潟?????1荀?膣?茯??罸??2???綣??????????障?????
???????????眼??Hash???Struct???≪??????(n - m) * 2?????ゃ???????ゃ?障??arg->readable + 2?????ゃ????障?ц?????????с????????
1?????ゃ??紊??????茯?帥???????冴????????r_byte???r_bytes0???type???羝<??綽?荀??????????????c?????с??????????障?с?????c?????障????????

[ruby-dev:45637]????罕???????潟???????若???絎?茵?????????????????篁ヤ????????????????障????????

trunk(r35983)
       user     system      total        real
   0.560000   0.030000   0.590000 (  0.601471)

proposed:
       user     system      total        real
   0.090000   0.010000   0.100000 (  0.113099)

patch???羞私???????障?????
----------------------------------------
Feature #6440: 綣???違??IO???羝<???????翫?????Marshal.load????????????<?????????????????
https://bugs.ruby-lang.org/issues/6440#change-27165

Author: Glass_saga (Masaki Matsushita)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: 2.0.0


=begin
????(({Marshal.load}))??с???綣???違??(({IO}))???羝<?????(({IO#getbyte}))???(({IO#read}))??у??綺с???荀?????????帥?茯??水?冴?????膵違??菴????????
紊ч????<?純???????若?喝?冴???????榊??????????????潟?鴻???????∴????с????障????????
????????с??綣???違??(({IO}))???羝<???????翫?????(({Marshal.load}))????????????<??????????????篋???????罅??????障?????

  require 'benchmark'
  require 'tempfile'

  ary = Array.new(1000){ "hoge" }
  file = Tempfile.new("foo")
  Marshal.dump(ary, file)

  Benchmark.bm do |x|
    x.report do
      100.times do
        file.rewind
        Marshal.load(file)
      end
    end
  end

  file.close

筝?荐???????潟???????若??с??????????<???????ゃ????????????ruby???trunk???罸?莠?????????????????篁ヤ????????????????障????????

  trunk(r35660):
         user     system      total        real
     1.880000   0.000000   1.880000 (  1.874681)

  proposed:
         user     system      total        real
     0.180000   0.000000   0.180000 (  0.178556)

patch???羞私???????障?????
=end



-- 
http://bugs.ruby-lang.org/