Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124179 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 C7E381A009C for ; Tue, 2 Jul 2024 15:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719935461; bh=U4UJy/urj4htC4thdoNWI+HmDvWS6bgM34LIQ+MPCZM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kJiujsbNrw8Ofk0sa/xo3g/h8KRFuRJ1GZ39fKrEo5qSaTd+glDEsnQvOuK2Tga+/ ijKAXPzyEwiJ/q/1C5qwKZ4TAdxZQz3NQtW8osRvhbqUTihR1XwckAWEJl3iOrqSsB mylR8roFcl9qv17jZJs+BD13gGwO2lFvagKQ21YJvJB++oYcC2yqWSYDY3kpKqao5E kpUyXJcE+vBj5/tqF0ugKAjGvN5N2Xw9Lqh85994bBr00j6ZwJn4q7PM7h/lZfM7oZ 2dBq+J0i1rSlp+9dlbdh8oGozIGH7FDx8L1RWUnTp9njOCGjGQ+dLE2Nz6hfqg+Nm5 Gf/afZJFXm7CQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0EDE0180669 for ; Tue, 2 Jul 2024 15:51:01 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 ; Tue, 2 Jul 2024 15:51:00 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-58b0beaf703so1767606a12.2 for ; Tue, 02 Jul 2024 08:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719935378; x=1720540178; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fNP+FVMDdP6XRpimbRIvscGRaFQ8B5XVNLVrkqTqrvc=; b=m7r2pdnc+xVhjNf9B7KIroa4jqaa9P7HhUNzAds/pkyLpb5SHEMwAWFxuhJvKyNp1k 2oF0RuY3LTFWIYNocxUh5oRv8EOa/ZeSy0TdbR1EAjjrH2LwU3dJOIm1Y6iWmJbBOLLY WIg9GU8XTLRGTdoerrYshpGk5nCW8PUbnlUvLhTZFwS7392VZrpNMPzlxLXDRRkMl30u dgtOnKLvPW1TKEuN/xE8gRa+Rvg9wku9F2XT7KgfBFnswqR6ufn30A8Qk3jSMYmgIOFQ e00VpvogDxsl4Oe9B0DqlgC+DsKAFAIXGOnmAxGtlQoRfyTERyxmLn0rCFi9kHlHFLM+ TaUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719935378; x=1720540178; h=content-transfer-encoding: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=fNP+FVMDdP6XRpimbRIvscGRaFQ8B5XVNLVrkqTqrvc=; b=j6aIaBjkhReSSkHhIouFcYyddGWeSupMbOxsGv3R9LSMxwzUobVE1Yb5CCl54xIZqG A7Uo+B8ZOqq29PxH6PyM9pw9URRwkK18cJU6zoLgrfFCrDkzRfqZz9etzw2eMpzVTmaP TgjABczd9px6Go9JXFENMmeybi6rJv57qgy/MPlAE6yOCoCqJ27B9oneIa5nRxvliNuF VmFisT2dQWtrleS2Z0lrrIm527hbJeMcMzBNrmxC2DlCem5Et1X1S2a6mkoEgjAFhQvK 0fZ6wzejMZxFAsCXsMM+NlBilj/7oiWDxyJWv9/0o8uyrYCB5bhKHulCuDn0d6NUJKGI 65WQ== X-Forwarded-Encrypted: i=1; AJvYcCV6kviUpoM/aGHiQzU5oc5pmdE9+3bnF/7n2DYnQFgcR9/I+gtDXK+rHybd/md5vvJigi2BwHRNmqRDIqUqOtLBINdNN3XPDg== X-Gm-Message-State: AOJu0Yz8+Y/n/3LdsHau0uL7XA4zZzMv/IKRfZ6Lvda/WBdgjRb0PP16 87vpgQlCy4iM7fuerV2cz1kn4yEjgx7piXF+waUcYK0cWVaj2ljICtE1i2dya+IoEI3ObtFjjm7 +43wFs2QTrv1m1jXvyZlfxCTagFg= X-Google-Smtp-Source: AGHT+IGzuW7JdUbiyOkwaXIA0Hb6+MeIuw29eRcfrZWsdaMjZMVO5OctAP8kyH1yd6pxMFbq36tpQweGCJSnCHyNxYs= X-Received: by 2002:a05:6402:2344:b0:57d:73c:9299 with SMTP id 4fb4d7f45d1cf-5879f9849b9mr5862044a12.23.1719935377939; Tue, 02 Jul 2024 08:49:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 2 Jul 2024 17:49:26 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Marco Pivetta , Nicolas Grekas , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: arnaud.lb@gmail.com (Arnaud Le Blanc) Hi Tim, On Sun, Jun 30, 2024 at 3:54=E2=80=AFPM Tim D=C3=BCsterhus wrote: > On 6/27/24 16:27, Arnaud Le Blanc wrote: > >> * flags should be a `list` instead. A bitmask= for > >> a new API feels unsafe and anachronistic, given the tiny performance h= it. > >> > > > > Unfortunately this leads to a 30% slowdown in newLazyGhost() when switc= hing > > to an array of enums, in a micro benchmark. I'm not sure how this would > > impact a real application, but given this is a performance critical > > I'm curious, how did the implementation look like? Is there a proof of > concept commit or patch available somewhere? As the author of the first > internal enum (Random\IntervalBoundary) I had the pleasure of finding > out that there was no trivial way to efficiently match the various enum > cases. See the PR review here: > https://github.com/php/php-src/pull/9679#discussion_r1045943444 I've benchmarked this implementation: https://github.com/arnaud-lb/php-src/commit/f5f87d8a7abeba2f406407606949e5c= 6e512baab. Using a backed enum to have a more direct way to map enum cases to integers didn't make a significant difference. Here is the benchmark: https://gist.github.com/arnaud-lb/76f77b5d7409a9e4deea995c179c6e96. Caching the options array between calls had a less dramatic slowdown (around 10%): https://gist.github.com/arnaud-lb/87e7f58cc11463dd3aa098218eb= 95a90. Best Regards, Arnaud