Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78277 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96546 invoked from network); 23 Oct 2014 15:22:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2014 15:22:23 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.218.44 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.218.44 mail-oi0-f44.google.com Received: from [209.85.218.44] ([209.85.218.44:37184] helo=mail-oi0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/29-41150-D2D19445 for ; Thu, 23 Oct 2014 11:22:22 -0400 Received: by mail-oi0-f44.google.com with SMTP id x69so885904oia.31 for ; Thu, 23 Oct 2014 08:22:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=S12gD2L3qyDBG3SABjRcJj89XAQ04LvEcjcCtYsoKBM=; b=P5MiS2NWSv8cTptwrtj98bbytXzm1u070eo9aVW+W98lyRA7PKJnE4X1BhY0NJ0TmC q3JXRV5zRG2h8BqYPOnhu1LJZe/mE18h6fo+3l0JSCRNSUoX9fSVlrc9bPMFZq5aAu0v 2zb77AXAr3+jwJaS1snwlaPEttGAKb2Dqk5J19Bb+ytefJwb4ZpPLCrNeW9jUPlxK7sn 53DRZhC23j9Ke0wEugHYbq+EsxxHZ3UjcmKQjXTeeDoOtxBKDoFkq8VI7ftSHtpPWBio f+6WUfchLb1Xo6ksdZ4TgTtl+UEBiIL/MXcS5z96D5z46VXez3++MOVGKX0mNO6B9Z+K jg8Q== X-Gm-Message-State: ALoCoQmpYqY05MHqrxnBrVgVfhGx35VVNYBWuSK+YFQHX75OzwdetZz2BecCeOsmt+fyS3MEgD6l2O04SjSEdAbhvTBKJTFhunIs+cUM+gErtUf4wpY2lk3QaZEJ7b+W/j4olmATaAQ0PV+paF+Y1H8FIUJpsB+R9g== MIME-Version: 1.0 X-Received: by 10.202.177.65 with SMTP id a62mr1705767oif.92.1414077739080; Thu, 23 Oct 2014 08:22:19 -0700 (PDT) Received: by 10.60.70.41 with HTTP; Thu, 23 Oct 2014 08:22:18 -0700 (PDT) In-Reply-To: References: <8C47FA53-0964-49C0-963C-332A936348A5@ajf.me> <68229C26-4EEC-49DC-BA05-D5AC9728D1E8@ajf.me> Date: Thu, 23 Oct 2014 19:22:18 +0400 Message-ID: To: Andrea Faulds Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a113ce1f852b464050618a12e Subject: Re: [PHP-DEV] [RFC] Big Integer Support From: dmitry@zend.com (Dmitry Stogov) --001a113ce1f852b464050618a12e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Oct 23, 2014 at 5:50 PM, Andrea Faulds wrote: > Hi! > > > On 23 Oct 2014, at 13:47, Dmitry Stogov wrote: > > > > Hi Andrea, > > > > The synthetic benchmarks are not always reflect the impact on real-life > performance. > > > > Unfortunately, I wasn't able to run any big real-life apps with your > bigint branch, because it misses support for commonly used extensions > (ext/session, ext/json, ext/pdo). > > Yes, that=E2=80=99s unfortunate. ext/json is first on my list to update o= nce I=E2=80=99m > done with ext/standard, I particularly want large integers in JSON to > decode to bigints (though allow disabling this if you desire). I really > should=E2=80=99ve finished porting ext/standard months ago, I=E2=80=99ve = been dragging my > heels on that one. > > > I ran bench.php and it's a bit slower with bigint. > > > > master 1.210 sec > > bigint 1.330 sec > > > > I also measured the number of executed instructions using valgrind > --tool=3Dcallgrind (less is better) > > > > master 1,118M > > bigint 1,435M > > > > May be part of this difference is caused by missing latest master > improvements, but anyway, introducing new core type, can't be done for fr= ee. > > I=E2=80=99m not really sure about whether a new core type can=E2=80=99t b= e free. For > switch statements, if they=E2=80=99re compiled to a jump table, they shou= ldn=E2=80=99t be > any slower when a new case is added. But I=E2=80=99m not certain on that,= I don=E2=80=99t > spend much time reading generated asm. > > Does bench.php do any float operations? I=E2=80=99m not sure from reading= the > source, but I think it might end up having ints overflow and become float= s > in master or bigints in my branch. If that=E2=80=99s the case, it would o= bviously > be slower as bigints trade performance for accuracy. This particular issu= e > can=E2=80=99t really be helped. Although these apps, if they want floats,= can just > ask for them explicitly by marking their numbers with a dot. > bench.php does some math on long and floats, but I don't think overflow is involved. > > Another source of slowdown is, as previously mentioned, the asm functions > not being updated and hence me having to disable them. Particularly for > things like multiplication, addition and so on, the C code we have is far > less efficient. I believe the asm code simply checks for an overflow flag > after the operation, which should be very fast. yes, this may be a reason. > On the other hand, the C code converts the ints to doubles, does a double > operation, sees if the result of that is greater than PHP_INT_MAX convert= ed > to a double, and *then* does the operation if it won=E2=80=99t overflow. = This means > that, until the asm code is updated, all integer operations may be > significantly slower, which is unfortunate. However, I think that if the > asm were to be updated, the slowdown for integer ops would completely, or > at least mostly, disappear. > > > I also was able to run qdig, and it showed about 2% slowdown. > > > > [master] $ sapi/cgi/php-cgi -T 1000 /var/www/html/bench/qdig/index.php = > > /dev/null > > Elapsed time: 3.327445 sec > > > > [bigint] $ sapi/cgi/php-cgi -T 1000 /var/www/html/bench/qdig/index.php = > > /dev/null > > Elapsed time: 3.382823 sec > > > > It would be great to measure the difference on wordpress, drupal, ZF=E2= =80=A6 > > The reasons for the dig slowdown are likely the same. > 2% is not a big difference (it may be even a measurement mistake), but more tests should be done. > > -- > > I=E2=80=99ve so far been scared to touch the asm=E2=80=A6 but actually, I= don=E2=80=99t think it > could be *that* hard. It=E2=80=99s not doing something especially complex= . The > bigint API looks fairly stable now and I=E2=80=99m unlikely to change it = much > further, so there=E2=80=99s little worry about having to change the asm a= second > time. The main problem with asm, I suppose, is testing it. I do have a > 32-bit Ubuntu VM set up, but I=E2=80=99d also need to set up Windows VMs,= and > possibly others (don=E2=80=99t we have PowerPC in the source just now?). > change asm for 32-bit Linux and add TODO marks for others. I don't test PHP on PPC as well. Thanks. Dmitry. > > I might experiment with it tonight, or sometime later this week. > > Thanks. > > -- > Andrea Faulds > http://ajf.me/ > > > > > --001a113ce1f852b464050618a12e--