Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116266 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50352 invoked from network); 13 Oct 2021 00:57:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Oct 2021 00:57:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F6EF180381 for ; Tue, 12 Oct 2021 18:43:39 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 12 Oct 2021 18:43:38 -0700 (PDT) Received: by mail-pg1-f181.google.com with SMTP id d23so756858pgh.8 for ; Tue, 12 Oct 2021 18:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wikimedia.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=avOw1upFQBBvE2V0vMFRgZUnsDp4gQaZvoG8X9ThuMY=; b=YkbRcuiWOG0rr8voZU3W/2zxVEXKfcCY2QiCw+Ar+jxiR64fH4cmnjdMyjAUcfMgp/ LC+5UOfR2JRkaBwhb9XBlMRWaIIHQcTcc4yqKAUofPHw1zW2yDCAFFaeKKpkDY7+3fO3 OvyTiQHBHNdR+nBiUNlh2rNMTSLXQaDWQ6kFI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=avOw1upFQBBvE2V0vMFRgZUnsDp4gQaZvoG8X9ThuMY=; b=I4jsKn646Uemi0aj30GGrm9dVmE3VAoi5y1+aioR0GWwgZ+PeUqkgT3W1yiwlYVlT1 p5Bhd5DrKYTZghKDkkQZu4j0J0C8dc2R7BStgS+Qnbhy5ZToS+ObtSglMkVXBEA247in mzQFLV1+4czt4TBTv7qODOAT89Kr60KMonLpP9BvLI5jCw0x3Nrev5u5jZfJqd25D6lu ODwxXi7EiCVZx7VeH9aEMNRJEjhIuc607iLmT3TutN+Pvn/KmFrcJMCw+KBz6hi82ke6 iFtb397JWKLTuhbhFGaM2Uz0sHJan/9eFEhfV+DrvGfZFSnNOmvp0bES0s4N8IemMyOH AQ1A== X-Gm-Message-State: AOAM532IaQYAL7qC5kgGX4w3yjDu8dH3s/Cn8cNNn9gjbUOxmtbxujLO 5Pu/2tQ6/yxjtEXdstRFcp466O+um/vOpOXX X-Google-Smtp-Source: ABdhPJxZmkZy/nHFBQ6aWOzSB3C/AK5Od8fMc1+iZ1aTQo70O0/5FDtrI7lTo1Jn+A7zPZpr2JfHSw== X-Received: by 2002:aa7:8b1a:0:b0:44d:37c7:dbb6 with SMTP id f26-20020aa78b1a000000b0044d37c7dbb6mr8334876pfd.11.1634089417248; Tue, 12 Oct 2021 18:43:37 -0700 (PDT) Received: from [10.1.1.45] (124-168-132-124.dyn.iinet.net.au. [124.168.132.124]) by smtp.gmail.com with ESMTPSA id e9sm4341745pjl.41.2021.10.12.18.43.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 18:43:36 -0700 (PDT) To: Nikita Popov , PHP internals References: Message-ID: Date: Wed, 13 Oct 2021 12:43:33 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [PHP-DEV] Re: [RFC] Deprecate dynamic properties From: tstarling@wikimedia.org (Tim Starling) On 12/10/21 9:23 pm, Nikita Popov wrote: > Based on the received feedback, I've updated the RFC to instead provide an > #[AllowDynamicProperties] attribute as a way to opt-in to the use of > dynamic properties. As previously discussed, this won't allow us to > completely remove dynamic properties from the language model anymore, but > it will make the upgrade path smoother by avoiding multiple inheritance > issues. Especially given recent feedback on backwards-incompatible changes, > I think it's prudent to go with the more conservative approach. I think it would still be the biggest compatibility break since PHP 4->5. Adding a custom property is a common way for an extension to attach data to an object generated by an uncooperative application or library. As the RFC notes, you could migrate to WeakMap, but it will be very difficult to write code that works on both 7.x and 8.2, since both attributes and WeakMap were only introduced in 8.0. In MediaWiki pingback data for the month of September, only 5.2% of users are on PHP 8.0 or later. Also, in the last week, I've been analyzing memory usage of our application. I've come to a new appreciation of the compactness of undeclared properties on classes with sparse data. You can reduce memory usage by removing the declaration of any property that is null on more than about 75% of instances. CPU time may also benefit due to improved L2 cache hit ratio and reduced allocator overhead. So if the point of the RFC is to eventually get rid of property hashtables from the engine, I'm not sure if that would actually be a win for performance. I'm more thinking about the need for a sparse attribute which moves declared properties out of properties_table. I would support an opt-in mechanism, although I think 8.2 is too soon for all core classes to opt in to it. We already have classes that throw an exception in __set(), so it would be nice to have some syntactic sugar for that. -- Tim Starling