Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67405 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97988 invoked from network); 12 May 2013 19:02:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2013 19:02:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.42 mail-oa0-f42.google.com Received: from [209.85.219.42] ([209.85.219.42:39320] helo=mail-oa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/34-55400-E37EF815 for ; Sun, 12 May 2013 15:02:22 -0400 Received: by mail-oa0-f42.google.com with SMTP id i10so6792697oag.15 for ; Sun, 12 May 2013 12:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=8ZxucyFwGwhb1sbNvpIeJ/HRy5j/WmBG7ChtWj4nPWs=; b=k8M0yMakH7M7E1OVx760OXN4YNcpMaGPM1XzIgj3vx2XYNYSy/MULaHXnE1GiW36b4 VVj2uiOY9+nVeYWd0q/5ldjl/HhhNkyMs77n7mnHw4CoUWx1rsl/QM+ib9Fmkb7EUez7 a050644sUHOlsxydihgmXFYpxFgm92JBpIEIvkEUSVbYtMVz1nSuwhQR9RiejWGOv2w5 FAf/MsrkFf2pdBckhTKu/EaFHcTjW1yw4EpI/cGZ35PspNc9xKJA2ZLqaPEVRmIIZQ7b mMzDu786UKpP5D2XitRqzQYsyesH7/phcYg9uekOojvT7tc48GNnQ4Sxt6CCflE8bzjA NQvQ== MIME-Version: 1.0 X-Received: by 10.182.105.227 with SMTP id gp3mr11175024obb.81.1368385339755; Sun, 12 May 2013 12:02:19 -0700 (PDT) Received: by 10.182.49.136 with HTTP; Sun, 12 May 2013 12:02:19 -0700 (PDT) In-Reply-To: <518FD653.6070705@daylessday.org> References: <518FD653.6070705@daylessday.org> Date: Sun, 12 May 2013 21:02:19 +0200 Message-ID: To: Antony Dovgal Cc: PHP internals Content-Type: multipart/alternative; boundary=089e013a051017e49604dc8a0a39 Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: nikita.ppv@gmail.com (Nikita Popov) --089e013a051017e49604dc8a0a39 Content-Type: text/plain; charset=ISO-8859-1 On Sun, May 12, 2013 at 7:50 PM, Antony Dovgal wrote: > On 2013-05-12 19:25, Nikita Popov wrote: > >> Hi internals! >> >> https://wiki.php.net/rfc/**operator_overloading_gmp >> >> This RFC proposes to add operator overloading for INTERNAL classes. >> Furthermore it exemplarily implements the new API for GMP. >> > > IMO the proposal B is quite reasonable change, but the proposal A (i.e. > the operator overloading part) is definitely an overkill. > A simple benchmark should demonstrate that using GMP for basic arithmetic > would kill performance in quite a brutal way. > I think this is a misunderstanding. I do not suggest to use GMP for all arithmetic and also do not suggest to auto-promote to GMP for large numbers. The operator overloading only comes into play if one of the operands is already a GMP instance. Regarding performance: The addition of the operator overloading does have a measurable impact on performance. The switch of GMP from resources to objects also does not show any clear change either way. What does become faster is if a gmp function gets a non-gmp argument and needs to cast it to GMP (this is faster because now only the mpz_t instance is created and not a full resource). Obviously when the overloaded operators are used rather than the functions it's faster too. Nikita --089e013a051017e49604dc8a0a39--