From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DD24B1F44D for ; Thu, 21 Mar 2024 17:33:17 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=md19Kamy; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=lzGG8DMN; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 4DCBD834F1; Thu, 21 Mar 2024 17:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1711042386; bh=GtCGqde24ryDAIBO/FnATC9S7/yLBcYvKNdVhCtfhTw=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=md19KamypdCL4RgoScIFOOg5WiES0GasUF/iOVFRSeVrDEojrsgTs1a9yIseQvMM3 p/hNhqC7O93W9DVl7tDLqMUCml4Lgj2nPdsoETRqtnFvFatXexbvt37qP/gWSLqslv zh+3MSreXjxw0qo1sHO3C6OLv8YaOpGUeaVrrupI= Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 3AF9F834E7 for ; Thu, 21 Mar 2024 17:33:01 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=lzGG8DMN; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=71ZxoInrN5GSEYdyGmsBDLITmLBL38yGKRey0LRXZuw=; b=lzGG8DMNtE6qpNyRGePQ95zF/6XSJ60PI/T6kBK9kkUaGlemDJtQKbxJZoFeaBeD/KEk 129LHqgE+VLGbtTducLIUujbfCqsOlIoPVYHrQLdaMVX+vBl3FohJgKV/NBrxa9WARbExX jYxH+X1qlqkGFWUuc0nIyA2FaoUr9yPJdRStheNMnOPAwm0R09wHyHWcbbZSsB/S9XxoEP 62YAsgtGkdPI9QvnMHm0A6uUSgLrHp6IATLn0HI2HnBLbjWPadVcTocyl3mW+R+c80qZwv Lt7Ltlb6GEqLUQXoxQe+tNcSxi3AnYg31qE97yKzqs7w50i0fnwh0GP5ByfvZvfw== Received: by recvd-canary-577fb4c7fd-7bgv6 with SMTP id recvd-canary-577fb4c7fd-7bgv6-1-65FC6F4C-2 2024-03-21 17:33:00.01199713 +0000 UTC m=+247309.058811333 Received: from herokuapp.com (unknown) by geopod-ismtpd-39 (SG) with ESMTP id VnI5aBK6S5mrwOp5VwXavg for ; Thu, 21 Mar 2024 17:32:59.982 +0000 (UTC) Date: Thu, 21 Mar 2024 17:33:00 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20338 X-Redmine-Issue-Author: fablestales X-Redmine-Issue-Priority: Normal X-Redmine-Sender: alanwu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 93882 X-SG-EID: =?us-ascii?Q?u001=2EYthNhoKkR+ru7duuIBCSWggX1QviTpo1BTmObZjYMiu+oRLYmEDXRfIb7?= =?us-ascii?Q?CNytBX3Z1NzrRLrrRADZUsP0ba42fW6nV9SYX4v?= =?us-ascii?Q?RMxzALAlyf3kenMUH73Pu2MrF4=2F=2F3DvxZ1LzYF2?= =?us-ascii?Q?fwQn0MhNDOVE6sEwT=2FwwcYUhd4hu=2FEmyMNOswm3?= =?us-ascii?Q?fiImeMoFHuvuGs1KveyQ4POPWEW0=2FO1S3s0Doe2?= =?us-ascii?Q?9j=2FZR9ULCFbleeUGHsc0mn5Te2AhbbLcfCBhcw1?= =?us-ascii?Q?I3PXkOcNXqf6oCvWF0cyq2rLeA=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: AVUBT72HXNFHWE5PJFYDI7ZW2MRQBY2L X-Message-ID-Hash: AVUBT72HXNFHWE5PJFYDI7ZW2MRQBY2L X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117283] [Ruby master Bug#20338] certain **kwsplat calls have regressed allocations over past few ruby releases List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "alanwu (Alan Wu) via ruby-core" Cc: "alanwu (Alan Wu)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20338 has been updated by alanwu (Alan Wu). Subject changed from calling new has regressed allocations over past few ruby releases to certain **kwsplat calls have regressed allocations over past few ruby releases Status changed from Open to Closed After commit:aceee71c35e0b387691836e756b4e008efd84cf1 and commit:15dc3aaa311b32203d8ffb414bcf9b8e55ce5691, it's now back down to 3.2 levels on the master branch: ``` $ ./miniruby -v test.rb ruby 3.4.0dev (2024-03-21T17:20:32Z master 15dc3aaa31) [arm64-darwin23] 3006 2005 ``` The extra allocations were general issues with kwsplat calls which `Class#new` uses internally. ---------------------------------------- Bug #20338: certain **kwsplat calls have regressed allocations over past few ruby releases https://bugs.ruby-lang.org/issues/20338#change-107409 * Author: fablestales (Fable Tales) * Status: Closed * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Given this script: ``` class Foo def initialize(**kwargs) end end class Bar def initialize(y:) end end b = GC.stat[:total_allocated_objects] 1000.times { Foo.new(y:1) } p GC.stat[:total_allocated_objects]-b b = GC.stat[:total_allocated_objects] 1000.times { Bar.new(y:1) } p GC.stat[:total_allocated_objects]-b ``` On Ruby 3.2 it prints ``` (fable-3_3_dead_with_patches) $ ruby --version ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [arm64-darwin23] (fable-3_3_dead_with_patches) $ ruby hi.rb 3006 2005 ``` On Ruby 3.3 it prints: ``` ((HEAD detached at v3_3_0)) $ ./ruby --version ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] ((HEAD detached at v3_3_0)) $ ./ruby hi.rb 3008 3005 ``` On master: ``` (master) $ git rev-parse HEAD 83618f2cfa004accdd1514de7dcbba291aa7e831 (master) $ ./ruby --version ruby 3.4.0dev (2024-03-14T12:33:30Z master 83618f2cfa) [arm64-darwin23] (master) $ ./ruby hi.rb 3006 4005 ``` so that is: since Ruby 3.2 `.new`ing an object with static keyword args has grown from 2 allocations per object to 4 allocations per object. I have a pull request which introduces a new instruction to the VM `opt_new` which basically inlines calling allocate and initialize directly, avoiding a lot of what is causing these extra objects to be allocated. My PR is here: https://github.com/ruby/ruby/pull/10254. With my patch the script prints 2006 and 1005 respectively. This is the smallest number of objects that _can_ be allocated for such calls. -- 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/