Project

General

Profile

Feature #14820

[PATCH] ipaddr.rb: use frozen_string_literal

Added by normalperson (Eric Wong) 6 months ago. Updated 6 months ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:87375]

Description

ipaddr.rb: use frozen_string_literal

This reduces GC count by around 10% and provides a tiny speedup.

"make exam" passes, and I've read every single line of ipaddr.rb
so it APPEARS safe.  An extra set of eyes would be appreciated.

==> i.rb <==
500_000.times do
  IPAddr.new(-"3ffe:505:2::1")
  IPAddr.new(-"192.168.2.0/24")
end
p GC.count

  $ /usr/bin/time ./ruby i.rb
  4058
  11.16user 0.33system 0:11.50elapsed 99%CPU (0avgtext+0avgdata 10160maxresident)k
  0inputs+0outputs (0major+1390minor)pagefaults 0swaps

  $ /usr/bin/time ./ruby -I lib i.rb
  3651
  10.97user 0.32system 0:11.30elapsed 99%CPU (0avgtext+0avgdata 10196maxresident)k
  0inputs+0outputs (0major+1377minor)pagefaults 0swaps

History

#1 [ruby-core:87378] Updated by knu (Akinori MUSHA) 6 months ago

  • Status changed from Open to Assigned

Thanks for taking the time for this! It looks good to me as well. I'll commit this after testing this out with some of my products that kind of heavily use ipaddr.

Also available in: Atom PDF