[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
IkJhY2twb3J0IGN1c3RvbSBmaWVsZCIgaXMgb25seSBhdmFpbGFibGUgZm9yIHRpY2tldHMgd2hv
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
VGhhbmsgeW91IGZvciBjb25maXJtYXRpb24uCkkgY2hlY2tlZCBhZ2FpbiBhbmQgdG8gZWRpdCBi
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
SSBhZGRlZCB5b3UgdG8gIlJlcG9ydGVyIiByb2xlIGluIHRoZSBwcm9qZWN0CgoyMDIw5bm0MTDm
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[ruby-core:100272] [Ruby master Bug#17209] String#slice allocates Range object in ruby 3.0.0preview1
From:
ko1@...
Date:
2020-10-02 01:39:36 UTC
List:
ruby-core #100272
Issue #17209 has been updated by ko1 (Koichi Sasada).
Status changed from Assigned to Closed
I forgot to merge it: https://github.com/ruby/ruby/pull/3587
----------------------------------------
Bug #17209: String#slice allocates Range object in ruby 3.0.0preview1
https://bugs.ruby-lang.org/issues/17209#change-87859
* Author: bruno.escherl@xing.com (Bruno Escherl)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
While trying to optimise a use case, where I need to get parts of a string extracted, ignoring a constant length prefix, I noticed that ruby 3.0.0preview1 allocates an additional Range object for String#slice, that ruby 2.7.1 didn't allocate.
Test script using memory_profiler gem:
``` ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'memory_profiler'
end
string = 'const:prefix:and:the:rest'
MemoryProfiler.report do
10000.times do
string.slice(13..-1)
end
end.pretty_print
```
Output for ruby 3.0.0preview1
```
Total allocated: 800000 bytes (20000 objects)
Total retained: 0 bytes (0 objects)
allocated memory by gem
-----------------------------------
800000 other
allocated memory by file
-----------------------------------
800000 profile_string_slice.rb
allocated memory by location
-----------------------------------
800000 profile_string_slice.rb:12
allocated memory by class
-----------------------------------
400000 Range
400000 String
allocated objects by gem
-----------------------------------
20000 other
allocated objects by file
-----------------------------------
20000 profile_string_slice.rb
allocated objects by location
-----------------------------------
20000 profile_string_slice.rb:12
allocated objects by class
-----------------------------------
10000 Range
10000 String
```
Output for ruby 2.7.1
```
Total allocated: 400000 bytes (10000 objects)
Total retained: 0 bytes (0 objects)
allocated memory by gem
-----------------------------------
400000 other
allocated memory by file
-----------------------------------
400000 profile_string_slice.rb
allocated memory by location
-----------------------------------
400000 profile_string_slice.rb:12
allocated memory by class
-----------------------------------
400000 String
allocated objects by gem
-----------------------------------
10000 other
allocated objects by file
-----------------------------------
10000 profile_string_slice.rb
allocated objects by location
-----------------------------------
10000 profile_string_slice.rb:12
allocated objects by class
-----------------------------------
10000 String
```
Is this a regression in ruby 3 or something that memory_profiler doesn't record correctly in 2.7?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>