[#112457] [Ruby master Feature#19443] Cache `Process.pid` — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Issue #19443 has been reported by byroot (Jean Boussier).
16 messages
2023/02/16
[#112584] [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system — "normalperson (Eric Wong) via ruby-core" <ruby-core@...>
Issue #19465 has been reported by normalperson (Eric Wong).
9 messages
2023/02/25
[#112595] [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
2023/02/25
SXNzdWUgIzE5NDY1IGhhcyBiZWVuIHVwZGF0ZWQgYnkgbm9idSAoTm9idXlvc2hpIE5ha2FkYSku
[#112613] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— Eric Wong via ruby-core <ruby-core@...>
2023/02/26
"nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@ml.ruby-lang.org> wrote:
[#112615] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— SHIBATA Hiroshi via ruby-core <ruby-core@...>
2023/02/27
MzUxMzZlMWU5YzIzMmFkN2EwMzQwN2I5OTJiMmU4NmI2ZGY0M2Y2MyBpcyBicm9rZW4gd2l0aCBg
[#112626] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— Eric Wong via ruby-core <ruby-core@...>
2023/02/28
```
[ruby-core:112345] [Ruby master Bug#19424] Significant performance decreases in `OpenStruct#marshal_load` in Ruby 3.0 and 3.1
From:
"jeremyevans0 (Jeremy Evans) via ruby-core" <ruby-core@...>
Date:
2023-02-10 20:19:52 UTC
List:
ruby-core #112345
Issue #19424 has been updated by jeremyevans0 (Jeremy Evans).
byroot (Jean Boussier) wrote in #note-2:
> Is this a regression in `Marshal.load` or in `OpenStruct#marshal_load`?
>
> 2.7 ships with `ostruct 0.2.0` and `3.0` ships with `ostruct 0.3.1`.
>
> Either trying `ostruct 0.2.0` with Ruby 3.0 or `ostruct 0.3.1` with Ruby 2.7 should tell use where to look.
With the current version of ostruct 0.5.5 installed for all Ruby versions, it looks like there is a still a decrease in performance in Ruby 3.0, but no decrease in 3.1.
```
$ ruby27 -v t.rb && ruby30 -v t.rb && ruby31 -v t.rb
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-openbsd]
["OpenStruct::VERSION", "0.5.5"]
user system total real
OpenStruct dump 0.520000 0.000000 0.520000 ( 0.520580)
OpenStruct load 1.360000 0.000000 1.360000 ( 1.362451)
ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-openbsd]
["OpenStruct::VERSION", "0.5.5"]
user system total real
OpenStruct dump 0.540000 0.000000 0.540000 ( 0.539436)
OpenStruct load 2.120000 0.000000 2.120000 ( 2.271033)
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-openbsd]
["OpenStruct::VERSION", "0.5.5"]
user system total real
OpenStruct dump 0.550000 0.000000 0.550000 ( 0.559946)
OpenStruct load 2.190000 0.010000 2.200000 ( 2.213022)
```
So part of the issue is `ostruct` (due to the commit mentioned), and part of the issue appears to be `Marshal.load` changes in 3.0.
----------------------------------------
Bug #19424: Significant performance decreases in `OpenStruct#marshal_load` in Ruby 3.0 and 3.1
https://bugs.ruby-lang.org/issues/19424#change-101789
* Author: sumitdey035 (Sumit Dey)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.2
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I can see degradation in **Marshal load** only in Ruby 3.1.2 compared to 2.7.4
Processing time increased by 200%(2.4 sec to 4.3 sec)
Memory allocation increased by 600%(6500001 to 39000004)
```
require 'benchmark'
require 'ostruct'
N_OJ = 500_000
ex_HASH = { 'one' => 1, 'array' => [ true, false ] }
ex_JSON = '{ "one": 1, "array": [ true, false ] }'
ex_STRUCT = OpenStruct.new( one: 1, hash: ex_HASH, array: [ true, false ] )
ex_MARSHAL = "\x04\bU:\x0FOpenStruct{\b:\bonei\x06:\thash{\aI\"\bone\x06:\x06ETi\x06I\"\narray\x06;\bT[\aTF:\narray[\aTF"
"-----------------Ruby #{system("rbenv version")}----------------"
Benchmark.bm(20) do |x|
x.report('native marshal dump') do
N_OJ.times do
y = Marshal.dump(ex_STRUCT)
end
end
x.report('native marshal load') do
N_OJ.times do
y = Marshal.load(ex_MARSHAL)
end
end
start_memory = GC.stat[:total_allocated_objects]
N_OJ.times do
y = Marshal.dump(ex_STRUCT)
end
end_memory = GC.stat[:total_allocated_objects]
print "Marshal dump memory allocation- #{end_memory - start_memory}\n"
start_memory = GC.stat[:total_allocated_objects]
N_OJ.times do
y = Marshal.load(ex_MARSHAL)
end
end_memory = GC.stat[:total_allocated_objects]
print "Marshal load memory allocation- #{end_memory - start_memory}\n"
end```
**Benchmark and Memory consumption result**

---Files--------------------------------
Screenshot 2023-02-07 at 1.04.49 PM.png (184 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/