From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 340A617D37A5 for ; Wed, 2 Oct 2013 22:43:50 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id AD987B5D858 for ; Wed, 2 Oct 2013 22:12:43 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 8097297A832 for ; Wed, 2 Oct 2013 22:12:46 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dKnUUrvQVVkh for ; Wed, 2 Oct 2013 22:12:46 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 5FB9197A82C for ; Wed, 2 Oct 2013 22:12:46 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 139B7952439 for ; Wed, 2 Oct 2013 22:12:41 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5A8A012071E; Wed, 2 Oct 2013 22:12:30 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from fluorine.ruby-lang.org (fluorine.ruby-lang.org [210.251.121.216]) by neon.ruby-lang.org (Postfix) with ESMTP id D036812039F for ; Wed, 2 Oct 2013 22:12:27 +0900 (JST) Received: from ruby-lang.org (localhost [127.0.0.1]) by fluorine.ruby-lang.org (Postfix) with ESMTP id 9181B3FEB9 for ; Wed, 2 Oct 2013 22:12:27 +0900 (JST) Date: Wed, 2 Oct 2013 22:12:27 +0900 From: "charliesome (Charlie Somerville)" To: ruby-core@ruby-lang.org Message-Id: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Redmine-Issue-Author: sam.saffron X-Auto-Response-Suppress: OOF X-Redmine-Issue-Id: 8977 X-Redmine-Mailinglistintegration-Message-Ids: 31260 X-Mailer: Redmine X-Redmine-Project: ruby-trunk Auto-Submitted: auto-generated X-Redmine-Site: Ruby Issue Tracking System X-Redmine-Host: bugs.ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 57600 Subject: [ruby-core:57600] [ruby-trunk - Feature #8977] String#frozen that takes advantage of the deduping X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #8977 has been updated by charliesome (Charlie Somerville). ko1 and I discussed this in IRC and decided that #frozen would be too easily confused with #freeze. An idea that came up was to use #dedup or #pooled instead. What do you think Sam? ---------------------------------------- Feature #8977: String#frozen that takes advantage of the deduping https://bugs.ruby-lang.org/issues/8977#change-42213 Author: sam.saffron (Sam Saffron) Status: Open Priority: Normal Assignee: Category: Target version: current: 2.1.0 During memory profiling I noticed that a large amount of string duplication is generated from non pre-determined strings. Take this report for example https://gist.github.com/SamSaffron/6789005 (generated using the memory_profiler gem that works against head) ">=" x 4953 /Users/sam/.rbenv/versions/2.1.0-dev/lib/ruby/2.1.0/rubygems/requirement.rb:93 x 4535 This string is most likely extracted from a version. Or "/Users/sam/.rbenv/versions/2.1.0-dev/lib/ruby/gems" x 5808 /Users/sam/.rbenv/versions/2.1.0-dev/lib/ruby/gems/2.1.0/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251 x 3894 A string that can not be pre-determined. ---- It would be nice to have "hello,world".split(",")[0].frozen.object_id == "hello"f.object_id Adding #frozen will give library builders a way of using the de-duping. It also could be implemented using weak refs in 2.0 and stubbed with a .dup.freeze in 1.9.3 . Thoughts ? -- http://bugs.ruby-lang.org/