Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127264 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 B68101A00BC for ; Thu, 1 May 2025 14:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746109638; bh=Pb2HYzyIxEZ5rXUO9EDYWU5rE/nWumeqxPP7BDsA8Dc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ODSYXr2W9DEeJe07WLhHFTWliRn+XusuKnaJNebIMj8a8laZ9nmRD8d5eSbqSnDLU eR6pGd3PiTFKgT6aBbaW+W/ywJXxRCV6cFWImla5vKAJDSSO6QcCuwfswGpr5CbrU3 FGnYKyNuM0C4GX+1WRHNHhWpWlkNRJmzL82msb9du3XJTJVvbNFgO5fHBA+Bs6DIpI T0RtkAz20FVg4TMoKjoG7SL9wGyrLB7YsoJHxeaw6MDQJ3TnF3c18BdTr6avCYxrOL TCvUp2fhQmJ+8dE+uZbFAUR/so2mvNI/63iglkyzx1Cz1qUFSapIKPIqht9O8mhQ/0 l4BGAp3EHFa0g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFEC918084F for ; Thu, 1 May 2025 14:27:17 +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,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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 ; Thu, 1 May 2025 14:27:17 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4394a823036so9124365e9.0 for ; Thu, 01 May 2025 07:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1746109772; x=1746714572; 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=/dRViECkyeHexpwl84+Mwc/kVMBks4/7RTE+IZ4pcpQ=; b=BmjRXqRwUAoCyHp9ddcnBRBSMRs7MKtRhQEZViY+tyMuoD7TLyw1Gccl22Ywc+JQ8o sCH6Qs3CX9yyCzW2jzhPkcBOjG+iFKMzM4o74YDX1C3CF1zZIEFmPeAdlpBHCg9x8gcY DHM9oC7Ud/scKHubhrgIiu8cC3+/3U9mnCr/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746109772; x=1746714572; 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=/dRViECkyeHexpwl84+Mwc/kVMBks4/7RTE+IZ4pcpQ=; b=hZvT376lNR+ZyhcIwsZyGcd0MCaPrebkbagJoYAoo6HVRHi4ZRgN63nDcX0b+yhqY6 UBsHtvjF08EFqwBEhy40F8fHsLtr65wV9dG8dpdVMK/Fy9otFzgD1GNI68CNC2KsmIi+ niEFGK96sldvUpmA+1hm0Rz+LxN29sDIYUCjlT8KbXCNu3ccf2buPeFemNAqXYukPHnf i2wWXeZu9LRYh5mvluFFGCsIlfESs3ABEYbM76K84Ctla8JUtFjhDifqIMwDQnf9pALX ZtS/BzlatgVw5VSznnWcpU8AkKOL4hhBuw601z1JUW3WUAOB5XuQ9jQ1iWWhtp3Tz4rv wrAA== X-Forwarded-Encrypted: i=1; AJvYcCWVfjXN5fRlesttW6nwpdVzjYhqScqFZ+uP/bW3tZacq8n5Glovgh8TxJj0Wu4Qiy2EAUD6pcQmxxc=@lists.php.net X-Gm-Message-State: AOJu0YymRxEnxwYVNzUG/fsMmHyfTZfu7tVGBozKB/onmkx2qR0/5qbu OEq1pzddPEvMu1K23bbXphl7eEbtx/g2vkqAxRs+3sNZZEXrSIy4tJtPdS/YTZ1lr98A98FTPO2 LFQeGSISrUy8vHMuV715Tu/MTzSzwapmyZTEwlA0uRGnHg7uOTKSwpw== X-Gm-Gg: ASbGncsRXo5LPflm8A2+Euwl5jYDeA93PS8ZStgvVo4Dculzq2NKkSnDiV6sNfyDzr6 C2zWZIS72duVKPHbPsy2fThCftrl7elxdF3zGI8m0goKaLKr0tpbVlxJJxSdn9XTISJdVat2u8W 1DnUVz9Ti5q/97676qrcEjow== X-Google-Smtp-Source: AGHT+IFfRjpGmTxUiwf5dO/fbXTKYMBbs3jyul8yc3kEkY88rAK6XvCxMjnjRw8i238nSAcAmcYCmUevGi0MItmLXxc= X-Received: by 2002:a05:6000:178c:b0:3a0:8c5a:6af3 with SMTP id ffacd0b85a97d-3a08f7a49fbmr7246620f8f.53.1746109772334; Thu, 01 May 2025 07:29:32 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <39597a9c-6854-40c6-a529-32b2b178cb27@app.fastmail.com> <7bc87f46-7d5a-4848-b505-a77499281f45@gmail.com> <88839E7C-E41B-434F-B7D5-16240D64ABD3@pmjones.io> In-Reply-To: <88839E7C-E41B-434F-B7D5-16240D64ABD3@pmjones.io> Date: Thu, 1 May 2025 08:29:20 -0600 X-Gm-Features: ATxdqUHuDNzed7IxWhOYTwZ5WR3sCUPneLWmgmNSgy6Nep0xa60uerKHKJpTEYU Message-ID: Subject: Re: [PHP-DEV] Concept: Lightweight error channels To: "Paul M. Jones" Cc: Niels Dossche , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: levi.morrison@datadoghq.com (Levi Morrison) On Tue, Apr 29, 2025 at 9:48=E2=80=AFAM Paul M. Jones = wrote: > > > > > On Apr 27, 2025, at 07:26, Niels Dossche wrot= e: > > > > Regarding performance however, rather than introducing yet another comp= letely new concept to do almost the same thing, why not try to improve exce= ption performance instead? > > > > I just opened a PR that makes instantiating exceptions much much faster= , and this is only after like 15 mins of work. I'm sure there's even more t= o gain. > > I mean, squeeze out gains where you can where the effort:reward ratio is = good, but the following is a naive but representative result on an MacBook = M3 Pro: > > ``` > return false 100000 times =3D 0.075289011001587 > throw exception 100000 times =3D 0.11530804634094 > ``` > > Do we consider a difference of 0.075/100000s vs 0.115/100000s that big a = deal when compared to (e.g.) establishing a database connection? The first part, the 0.075 vs 0.115... yeah, we care. That's 50% slower. But the thing is, the math with exceptions is kind of knowable because one of the key aspects of its cost is walking the call stack. How deep is the call stack going to be when a given library throws an exception? You don't really know. I work for an observability company on a profiler, so I regularly see customer call stacks. It is incredibly common to see much deeper call stacks, especially any framework with a middleware concept. I can't share a lot more detail without customer permission, but we do have a blog post about a real-world situation for one of our customers which had 85-ish frames deep when they were throwing exceptions: https://www.datadoghq.com/blog/php-exception-profiling/. tl;dr For this customer, throwing exceptions accounted for about 23% of the total CPU time. So yeah, we _do_ care about the performance of exceptions. Granted, code for this customer was bit of an unusual situation, but it still matters even today. It definitely matters if people are going to start throwing exceptions more frequently for less-exceptional errors.