Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107656 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70144 invoked from network); 24 Oct 2019 15:00:57 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 24 Oct 2019 15:00:57 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 198302C2CA1 for ; Thu, 24 Oct 2019 05:47:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 24 Oct 2019 05:47:20 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id c11so20190369iom.10 for ; Thu, 24 Oct 2019 05:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=UosfoZ7vmodEJu4i0h1sQCq6wqpPnUfxLMBOwO84gFo=; b=SWL8le0A5etU1t1Y284PI+++T0PWHp9pyLeKgGdRtxc7+PXMb+4pnQBD0fVJDJaqyj AYRidHTqOkJxFafS46wnPavSpyOXU1omSj6xjotGpDT5QJAOPlrkK77dGfhvaRfPICEl +zcLzlpjsaAhUEVhNC5AV3RZTsZSxDp+4yhTa6d825RVcfzm79AbReqj51Y394A8LAlr QU6M1hsC85/0kzg4/ZIKt2xypWeQTUK5/AA+xwmwgwZtSNdt6r8GGIudUicab1KfJaNw l4in54kUIgyLC0aMG2vmXBWRnYcPJIAeCkumJEFRs4JNw4Gzu0ZKvo6ZMSTdSDh+zr7I TssA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=UosfoZ7vmodEJu4i0h1sQCq6wqpPnUfxLMBOwO84gFo=; b=B40f75w4yLPfdmby4E+UpV1rMT+lrVQE3PoKnG5jNR9f1CaB9JpavNVOHoNr0rI5lY FHNDNTXLBJSlETZIcamxINa6d1dbTyXMn0OcmCjonOODG0htg+JIzOnNlwNt6HwUrb33 mfLLOoPIW7iSskom9K9ZeeRkJCBRqqpYYW55j1TiWVhr+YfX5nS21A4abOF14VmLxnjI uubJu+RqYe0HvGgtm86Nak0Dd+h9ySY8rN3qpRYspTu3gUo3rvcKy3Kk5x68echlRmps 8fFwfiXqnP5QT4WffZGEL0dLRcDtMcQCLkzFvnA3gIVE9qP5lzHyPuJZQZw82ZPE+lZP eb3Q== X-Gm-Message-State: APjAAAWFrRwapmvoT/3cfA+bYKE3kSZ5I7CTOaLDuAgBzwhJMG5GIUPX 3CG6RGtWIM9OsLyfIXruJn54qTS5Su1uBV5z6rITYw== X-Google-Smtp-Source: APXvYqxn+hXxKfJ45FlwQE2d30XkCgE96P+SH58Yr0Z78nRTWlLJYDK9uelW5nbfHe7TvV8NMb/QiqOhjy3PpOpEFuI= X-Received: by 2002:a6b:7942:: with SMTP id j2mr9304622iop.161.1571921239371; Thu, 24 Oct 2019 05:47:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 24 Oct 2019 13:47:08 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000001678890595a76fda" X-Envelope-From: Subject: Re: [PHP-DEV] Re: [RFC] Union Types v2 From: rowan.collins@gmail.com (Rowan Tommins) --0000000000001678890595a76fda Content-Type: text/plain; charset="UTF-8" Hi Dmitry, On Wed, 23 Oct 2019 at 16:43, Dmitry Stogov wrote: > Actually, I think PHP already took wrong direction implementing "typed > references" and "type variance". > Introducing more "typing", we suggest using it, but this "typing" comes > with a huge cost of run-time checks. > From 10% (scalar type hint of argument) to 3 times (typed reference > assignment) performance degradation. > Anyone may rerun my benchmarks > https://gist.github.com/dstogov/fb32023e8dd55e58312ae0e5029556a9 > I think this performance impact is a real concern; PHP is the only language I know of which implements type checks entirely at run-time in production code, and we should ask ourselves if that's definitely the right approach. Would it be possible, at least in principle, to build a static analysis tool which could prove that certain type checks would never fail, and prime OpCache with code that leaves them out? As I understand it, this is how Dart works: the compiler only emits run-time checks for assertions it can't prove true by static analysis. The simpler idea I had in this area was caching what type checks a value had passed, either on each zval or perhaps just at the class level, so that checking the same type again would be much faster, even if it was a complex union with multiple interfaces. Regards, -- Rowan Tommins [IMSoP] --0000000000001678890595a76fda--