Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129727 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 lists.php.net (Postfix) with ESMTPS id E995C1A00BC for ; Tue, 30 Dec 2025 23:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1767137030; bh=uaSerVMu1QWZimwBXKSfFDqCg532regVbG5wdKjjXWE=; h=From:Subject:Date:References:To:In-Reply-To:From; b=N3+5JYv+fGnlVksz3Siho47sxfnpubcV9EIZDOdf7SE+r9kpk0e7G7FCYFcZxXO+D uOWcAmIuUjWR+f+rX4YE0IF3j6vWmpxJWIO5AM90Z8DLNQeMb0+nFLljzionRCXOI3 Sn27TxvEQJ34+WMU1zJtSPe76GXJwfVTWjyaGrkJqNwQYnXY4F/5ffHYRd+73DJna2 dULBmS6wHZGU5La+ZrZIwcT+QoWQIcHQb/9uYaqgOqfhIWfobCZBZjVY9gtywRa0c+ GQ+17TCwYovn9c62D9RtOwT8bLY597eCwIba7PJd8OJnqmfyK2d0feyvwffDjIKGoS OSuDug7CIPorw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 63009180086 for ; Tue, 30 Dec 2025 23:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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, 30 Dec 2025 23:23:46 +0000 (UTC) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-b7277324054so1683368266b.0 for ; Tue, 30 Dec 2025 15:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767137020; x=1767741820; darn=lists.php.net; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :from:to:cc:subject:date:message-id:reply-to; bh=IeVb3Vf3+zgOoTXhtf4sG2hbvW/VSIkrI2w1CIy1Wi4=; b=fmxnmmfO8jKCEpCqPModMuwYZWZfZLJtWN4m0R+KSjeFt2Wk1MSZdLa2DBFgUxhGCs Hfpl92V+XqBUiKLIpEQmPY3jfn0995ZFZwtOyq2AOsjSuQWC920Pd2ptdKizCY3cEHDP jf35YaXfQoJ+keB7D5o2dOHpx9/DCz3S7DW8wEPOSybfzAiDYZO/ajRyc06w/E3Lhu5b KMcyD2p34UIlWyOZK1HuMGWexopxhm1LsXQPCZb4mW4x8bOWbIoQXPrLFxsadjtNtMXy zZ9GX1Ueyp1vbd9wDHl6UtA9P1n7sKffevv7VL/YGOTesggW5aQgRETRfRpzm1K3n3AR njdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767137020; x=1767741820; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IeVb3Vf3+zgOoTXhtf4sG2hbvW/VSIkrI2w1CIy1Wi4=; b=QJakEHuPx+q0BkMbv9Dtk1Ak9XIEWy0KNXnoH3kLxtKxBQsl0su084/nQFRuTLskG5 7ib2Yvq1/wf5HZ1mBZ0nqFg9N9p2ayE4o70lo4U1V1f9WkZHjfMeiajHgsEDfHwwUOcx vfUd94go9i4SgnEkjPL7dTphstuSqi9c07ezeIWtlPZScLINiBxmbPVkThZ66AVrXTH7 1MyfXDApRQ+lHqi6WVG1sNjruxxo6OOdN1r+adi9JamnCtA8IVuru1sx7DLNmAKb4e0q 6QQyP/T3hb1MzLlaAjBK64wANviTv5KCdp6wRxX4eH4uztxNueoURBCBawgpHSgPx9nY mN7w== X-Gm-Message-State: AOJu0Yzrg08mHfTzhqo7eLJEscpLk5WSJJHEDEmi31q2q4kFqfYVMy+x 0nGcRXhU8aenLvKlDFMie1zbqO9if0NoOztm9QB7vCQPxoNYQJwG+6PXGkt+Zw== X-Gm-Gg: AY/fxX7KuYpshpEbSV9FqFI3HSgLPmQ7NS16invJooa4EmSN6lEwoChEkil+ki2iywS b1U2RqPIOmRwSonnhf8DR+ulQuMOlCAZCNvJFqWFiwLA3LjXTemqR0KiAgu5mOY2qYNJwIXuJxM B3LzpExjan+p8sMchpsn4P9khSs7cQ+n6Jl+4zOIzvdDfFplCsZKjHqP9s04dtvhIlChBaJ+aWm DyuW0PWvNWrbOI/3RTSq/INBFxUUOCm+HCwy4pWs4Hf8YQHrw62wkLb7DgJ45uNBMG2cZzV3C5J PftCcGgLF7OIUEHrCQBhy5SBuvA79ZZlrgpPOea/enfGHEyGCkZnOWFaMsnHBJyWmnUgdHn6QZG SUmtA8qCob2doVhqORFCMNtjXJF1NsPfX85qrs1S8B+S3KeCbiNKU+8cdfOAvtRB5HPsmeKSnZT lk5gN9H+3CDRmOCed0y/GMWEeV9QTM+bDIuQ== X-Google-Smtp-Source: AGHT+IFMOjm+ahF4yIlHc9JBg0wwBM+LO2WZyTnIydYFy39hzeEBhiVGpQVaOhoco29nYY//T+TzKQ== X-Received: by 2002:a17:906:730d:b0:b72:b710:cbfd with SMTP id a640c23a62f3a-b80371a2c62mr3400924366b.36.1767137019478; Tue, 30 Dec 2025 15:23:39 -0800 (PST) Received: from smtpclient.apple ([2a02:2f0c:c107:3700:55c5:eeff:b4e9:2e7a]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f18575sm3705417366b.54.2025.12.30.15.23.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Dec 2025 15:23:39 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_F62A7661-B790-462A-A42E-186E1AD21140" Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PHP-DEV] [Discussion] Reflection-based constructor autowiring (scope clarification) Date: Wed, 31 Dec 2025 01:23:27 +0200 References: <6C2A8D96-BB4C-4091-85D8-21654C242364@gmail.com> To: "internals@lists.php.net" In-Reply-To: Message-ID: <9BB22BFE-CB1B-4A25-A911-8181B76B0613@gmail.com> X-Mailer: Apple Mail (2.3826.700.81) From: azolee@gmail.com (=?utf-8?B?QU5EUsOBUyBab2x0w6FuIEd5w6FyZsOhcw==?=) --Apple-Mail=_F62A7661-B790-462A-A42E-186E1AD21140 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi all, I=E2=80=99ve completed the benchmarks based on the guidance in the = thread. In short: Cold-start measurements (fresh PHP process per run) show no meaningful = difference between direct instantiation and reflection-based autowiring. = Process startup dominates, and reflection overhead is effectively lost = in the noise. Warm-process benchmarks show a consistent ~3-4x overhead for runtime = autowiring compared to direct instantiation, even with request-scope = constructor plan caching. This appears to be a model-level cost rather = than something easily eliminated by implementation details alone. Based on these results, I don=E2=80=99t see a lazy-proxy-like = engine-only win here. Userland implementations already seem close to the = practical ceiling for runtime autowiring, and further gains would likely = be incremental. Given that, I agree this does not currently make a compelling case for a = core addition, and that runtime autowiring remains better addressed in = userland or framework-specific solutions. Thanks to everyone who provided feedback and guidance. Best regards, Zoli eng. ANDR=C3=81S Zolt=C3=A1n-Gy=C3=A1rf=C3=A1s --------------------------------------- tel: +40 745 797 798 mail: azolee@gmail.com > On 30 Dec 2025, at 20:41, Marco Pivetta wrote: >=20 > Hey Zoli, >=20 > On Tue, 30 Dec 2025 at 08:17, ANDR=C3=81S Zolt=C3=A1n Gy=C3=A1rf=C3=A1s = > wrote: >> If you have any guidance on what you would consider a representative = benchmark or a meaningful performance threshold for =E2=80=9Cworth = moving into core=E2=80=9D, I=E2=80=99d appreciate it. >>=20 >=20 > In the grand majority of cases where autowiring is meaningful (at = least for PHP), you care about a "cold start" of the application = (although that's changing with ReactPHP/FrankenPHP/Roadrunner/etc.). >=20 > You may design a PHPBench or Hyperfine test that: >=20 > * starts a PHP process, autowires something, shuts down. Hyperfine = helps a lot here. > * repeats the above, but within a warm process (classes already = loaded, tight loop repeating the operation). PHPBench is a bit more = precise here. >=20 > You probably care about these cases: >=20 > * zero-arguments constructor > * simple concrete class references > * default constructor arguments > * resolvers > * autowiring of a complex multi-level structure >=20 > In all the above cases, you probably care about the usage with = autowiring API vs the usage via direct instantiation, so you can see the = exact overhead. >=20 > Marco Pivetta=20 >=20 > https://mastodon.social/@ocramius >=20 > https://ocramius.github.io/ > =20 --Apple-Mail=_F62A7661-B790-462A-A42E-186E1AD21140 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Hi all,

I=E2=80=99ve= completed the benchmarks based on the guidance in the thread.

In short:

  • Cold-start measurements (fresh PHP process per = run) show no meaningful difference between direct instantiation and = reflection-based autowiring. Process startup dominates, and reflection = overhead is effectively lost in the noise.
  • Warm-process = benchmarks show a consistent ~3-4x overhead for runtime autowiring = compared to direct instantiation, even with request-scope constructor = plan caching. This appears to be a model-level cost rather than = something easily eliminated by implementation details = alone.

Based on these results, I = don=E2=80=99t see a lazy-proxy-like engine-only win here. Userland = implementations already seem close to the practical ceiling for runtime = autowiring, and further gains would likely be incremental.

Given that, I agree this does not currently make = a compelling case for a core addition, and that runtime autowiring = remains better addressed in userland or framework-specific = solutions.

Thanks to everyone who provided = feedback and guidance.

Best = regards,

Zoli



eng. ANDR=C3=81S = Zolt=C3=A1n-Gy=C3=A1rf=C3=A1s
---------------------------------------tel: +40 745 797 798
mail: azolee@gmail.com

On 30 Dec 2025, at 20:41, Marco = Pivetta <ocramius@gmail.com> wrote:

Hey Zoli,

On Tue, 30 = Dec 2025 at 08:17, ANDR=C3=81S Zolt=C3=A1n Gy=C3=A1rf=C3=A1s <azolee@gmail.com> = wrote:

If you have any guidance on = what you would consider a representative benchmark or a meaningful = performance threshold for =E2=80=9Cworth moving into core=E2=80=9D, = I=E2=80=99d appreciate it.


In = the grand majority of cases where autowiring is meaningful (at least for = PHP), you care about a "cold start" of the application (although that's = changing with = ReactPHP/FrankenPHP/Roadrunner/etc.).

You may = design a PHPBench or Hyperfine test that:

* = starts a PHP process, autowires something, shuts down. Hyperfine helps a = lot here.
* repeats the above, but within a warm process = (classes already loaded, tight loop repeating the operation). PHPBench = is a bit more precise here.

You probably care = about these cases:

* zero-arguments = constructor
* simple concrete class references
* = default constructor arguments
* resolvers
* = autowiring of a complex multi-level = structure

In all the above cases, you probably = care about the usage with autowiring API vs the usage via direct = instantiation, so you can see the exact = overhead.


= --Apple-Mail=_F62A7661-B790-462A-A42E-186E1AD21140--