From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 11F8C1F4B4 for ; Tue, 12 Jan 2021 05:47:43 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 476F6120A9A; Tue, 12 Jan 2021 14:46:52 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id C8760120A99 for ; Tue, 12 Jan 2021 14:46:49 +0900 (JST) Received: by filterdrecv-p3iad2-74bd9fb996-5v2vq with SMTP id filterdrecv-p3iad2-74bd9fb996-5v2vq-22-5FFD37F8-5A 2021-01-12 05:47:36.999341646 +0000 UTC m=+2789120.022298166 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id HuAyIM_0QhC8EZ3oKQS8oQ for ; Tue, 12 Jan 2021 05:47:36.963 +0000 (UTC) Date: Tue, 12 Jan 2021 05:47:37 +0000 (UTC) From: muraken@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77922 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17291 X-Redmine-Issue-Author: mrkn X-Redmine-Issue-Assignee: matz X-Redmine-Sender: mrkn 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-SG-EID: =?us-ascii?Q?zpFjjZpImXPpY=2FcRIKDq1ipXkOYTu+Zo9t1k7iA7niDYBD=2Fae7j30Y4TZDU5sE?= =?us-ascii?Q?nkGCGNrAUD9VIP4Gam3NmrPZdPQfiq24QlA5wlI?= =?us-ascii?Q?KsFxeqj0htqm9Lxw5XrYFx7+hivVxYyKecqqsbC?= =?us-ascii?Q?Tg8OC53lR2YlxQVwq7fL6nLZlkeIPvM110Gqy69?= =?us-ascii?Q?0YNX9d4thYEBQ9y1l77XX0ZCyTI88d+C+Lzod1h?= =?us-ascii?Q?cbk5CVR3WU+NkvxN4=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102019 Subject: [ruby-core:102019] [Ruby master Feature#17291] Optimize __send__ call 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17291 has been updated by mrkn (Kenta Murata). mrkn (Kenta Murata) wrote in #note-3: > I found that rspec-core redefines `__send__`. > > https://github.com/rspec/rspec-mocks/blob/461d7f6f7f688f69154e410dcd9c7690120e7dbf/lib/rspec/mocks/verifying_double.rb#L45-L53 This redefinition is used to distinguish the form of the method call in a mock object. rspec-mocks recognizes that the form of `recv.__send__(:meth)` is used when `__send__` is called before `method_missing` is called, or the form of `recv.meth` is used when otherwise. The feature to distinguish method calling form is necessary to keep the compatibility if we employ this optimization of `__send__` call. ---------------------------------------- Feature #17291: Optimize __send__ call https://bugs.ruby-lang.org/issues/17291#change-89867 * Author: mrkn (Kenta Murata) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- I made a patch to optimize a `__send__` call. This optimization replaces a `__send__` method call with a call of the method whose name is the first argument of `__send__` method. The patch is available in [this pull-request](https://github.com/ruby/ruby/pull/3720). By this change, the redefined `__send__` method is no longer called when it is called by a symbol method name. I guess it is no problem because the following warning message is displayed for a long time. $ ruby -e 'def __send__; end' -e:1: warning: redefining `__send__' may cause serious problems This proposal introduces two new instructions: `sendsym` and `opt_sendsym_without_block`. These instructions handle the cases that the first argument of `__send__` method is not a symbol literal. I think I can combine these two instructions into one if prefered. This proposal includes the change proposed in #17288. I'll mark it as a duplicate of this proposal. I don't handle `send` method in this proposal. The reason is that we need to examine the redefinition of `send` method in the instruction execution time. I want to discuss only `__send__` method in this ticket. The benchmark result is below: ``` # Iteration per second (i/s) | |compare-ruby|built-ruby| |:----------------|-----------:|---------:| |vm_send_sym | 18.001M| 112.208M| | | -| 6.23x| |vm_send_var | 17.779M| 30.922M| | | -| 1.74x| |vm_send_var_alt | 3.817M| 6.817M| | | -| 1.79x| ``` -- https://bugs.ruby-lang.org/