Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125116 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 5E5E41ADB0F for ; Fri, 23 Aug 2024 09:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724407237; bh=0Bo5ioZlk+uvv4tovfL643IEhmo5PKK+Yu4QLVQ4ZkM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=doqyzOTsWlMdmU7DIw1QV84bYp2BEA7U/wKjuBkWJ7dsCfEVZs7nZ64atILLR+3zH EOqSB0Uw8qQgQf8doKlpwHs5szNEF/BaV0obVaB0hU7QNpJoimts1a9dDgwOZoqx8O goelBQN7yhrPtNoZ3UGbe4AquWBJGagy1Ygdv9HGC0J+ngDgDFHZLz52Wq2Mdp3+DQ gxMSLKyW+MinbzlM/U2P8hB6Ux6eXNmINeIMFaedC8j6jUVQGDH6kHrP7YjOyxTIo/ cefytkExvv9vbQgv78RDIrTuyHi1iiBANHqjwc0rpteUgClJSpAlho8CTRigeQxTnA KwhmEcrwZvzFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8EFB31801DF for ; Fri, 23 Aug 2024 10:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Aug 2024 10:00:32 +0000 (UTC) Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-498eb76145bso576566137.1 for ; Fri, 23 Aug 2024 02:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunglas.fr; s=google; t=1724407121; x=1725011921; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=frZj5GgP5bk0dT828TgFBu/x9Od6apPuo6i8qJ6hnnY=; b=IC50cPvOmmr5eUvh4MqUKpqx3YaXNhWf7ZODaVBtUhceHonDLsUNxMjjyMR1Q1HW83 Z4H2VQL74cCR8SjdM5sHWjkT7Ekaoio+yl2gG9F1xlh5P2g83cFyHmcfnVTQEcymS6pi wbYNgkg01Imh//MDqVb/G4ef7ZCzLDU4dr+veg2U5zqfVxyS43BIHy2G72ggqJurbfB/ UTo3A5XhUxWGkSnAeG79YXbjIdb+WFJF4eXTRJWCeqdt3Vs/4wmY9cAxUxdqZac2KLEK vMbbsMLEP6vSi4sxIdRt0b+1uPbik0RQpvVMMeY1S4+jqrUw0dURiYpvo9fJE30IkRR/ MJjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724407121; x=1725011921; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=frZj5GgP5bk0dT828TgFBu/x9Od6apPuo6i8qJ6hnnY=; b=NnO86uDZGqwRf7qDx4oTujszEznsnuOjxyE7fHTuvMzwo+jiBkR7OOLHqaxytiJ07H uvBrYRbXYoMfa1k4h8D7k7HcuiDmdeTP56f9Gdwfh7XNqp8mRNJtXharauMmMzL0pkL+ Bew2Bp6IPnSahQSopFVesKC+MQs6sS4O66sQTi/Cj6mwX93nq8uJXhzySUKB6aOMja6+ 21q+2LzNySeLtahH9fvtBQLKr1eeFaTk6G5Hd8zafPKkRZEzzz3+MwsDd7xf2azErhML k8V3Ol6t/hCovU0uTSu/HEYY59pVq2oWM1KTCirI5z2MRzM4TPksw/UyRTRS7Cc4Sf9I eTzA== X-Gm-Message-State: AOJu0YwgqPh8zwt6QFkqCzDRB/hx/pX2Bnoz6khMDPtcl+zVbReb2fZj /x/uYg6h2vlsrG/CQkrX+Lz5b0pf53PiivptUK35loWO8lcqvJhds+OqXgLTZyC770UHtFW3YIG obLEtITAmZ/HmpSTJrZ02aWdA1sJZBX+EX5D9Bw== X-Google-Smtp-Source: AGHT+IHlndVB3ozj7vPuqBEodn9xY+yPt9L9L4yB2oPFuBhJrA8PlyfKWU3zwaekJt2Qe5v5Ez9EGkKV91EXjYl3TYk= X-Received: by 2002:a05:6102:442a:b0:492:abbe:8923 with SMTP id ada2fe7eead31-498f4508608mr2542794137.6.1724407120788; Fri, 23 Aug 2024 02:58:40 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> In-Reply-To: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> Date: Fri, 23 Aug 2024 11:58:29 +0200 Message-ID: Subject: Re: [PHP-DEV] State of Generics and Collections To: Derick Rethans Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="000000000000e2199c062056d1f1" From: kevin@dunglas.fr (=?UTF-8?Q?K=C3=A9vin_Dunglas?=) --000000000000e2199c062056d1f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for sharing this research work. Instead of having to choose between fully reified generics and erased type declarations, couldn't we have both? A new option in php.ini could allow to enable the =E2=80=9Cerased=E2=80=9D mode as a performance, production-orien= ted optimization. In development, and on projects where performance isn't critical, types (including generics) will be enforced at runtime, but users will have the option of opting to disable these checks for production environments. If this is not possible, the inline caches presented in the article, combined with =E2=80=9Cworker=E2=80=9D runtimes such as FrankenPHP, Swoole,= RoadRunner, etc., could make the cost of enforcing generics negligible: technically, types will be computed once and reused for many HTTP requests (because they are handled by the same long-running PHP script under the hood). As working runtimes already provide a significant performance improvement over FPM, we could say that even if non-performance-critical applications (most applications) will be a bit slower because of the new checks, people working on performance-sensitive applications will have the opportunity to reduce the cost of checks to virtually nothing by switching to a performance-oriented runtime. Cheers, --000000000000e2199c062056d1f1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for shar= ing this research work.

Instead of having to choose between fully re= ified generics and erased type declarations, couldn't we have both? A n= ew option in php.ini could allow to enable the =E2=80=9Cerased=E2=80=9D mod= e as a performance, production-oriented optimization.
In development, an= d on projects where performance isn't critical, types (including generi= cs) will be enforced at runtime, but users will have the option of opting t= o disable these checks for production environments.

If this is not p= ossible, the inline caches presented in the article, combined with =E2=80= =9Cworker=E2=80=9D runtimes such as FrankenPHP, Swoole, RoadRunner, etc., c= ould make the cost of enforcing generics negligible: technically, types wil= l be computed once and reused for many HTTP requests (because they are hand= led by the same long-running PHP script under the hood). As working runtime= s already provide a significant performance improvement over FPM, we could = say that even if non-performance-critical applications (most applications) = will be a bit slower because of the new checks, =C2=A0people working on per= formance-sensitive applications will have the opportunity to reduce the cos= t of checks to virtually nothing by switching to a performance-oriented run= time.

Cheers,
--000000000000e2199c062056d1f1--