Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69805 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57534 invoked from network); 23 Oct 2013 13:56:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 13:56:02 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.212.180 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:59396] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/8C-10840-275D7625 for ; Wed, 23 Oct 2013 09:56:02 -0400 Received: by mail-wi0-f180.google.com with SMTP id ey11so918417wid.13 for ; Wed, 23 Oct 2013 06:55:59 -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=aoLUyQMvvZfHJB282vwsjrJY+fvK+dwOc9ezw8dfFq8=; b=hw6sQMuFrnpI1RW09tspH/DK+BK9LrsPhv//lJpdyW5KjIT7N4NKnTnkpvjgH7wtoB 4prtbEfhF0F3pO1TiYr6J0T0KwVNtPFHK/4RdsVIMyFbNV4QKXMpwzZMLVgn6LgoBNHu xXyHtF+IbVM0qwo3HHQ8g2H1ndqSl1ZJoGW5rAqSfUHbcF5P6g/tnaypRz/j3HRNm7Pg L4pdH4YZF8w2EhSr4+IxK+yOTGE6RmoVORG4WglTU54V/clWs9jWQzH3ao8MF5MUgQHS GGpz8boZ8O+E8A+HIKWc3m/mrlSL1GCPwe9HuHC9S11OZeZGv0qC49LmAhEfwWBs3qwP KhyQ== X-Gm-Message-State: ALoCoQkBOeea5tSOQVBbOGWvECCOcwyfwWpkp/F85EAFHJKRW0S9ObR3ZWFD+fGHucWl/0eqXNXG0ZjsukXbKZcR0KTFlB1O+GWcdrmWdcLMmlCPCGJ895mBqEd2KkI/JYZNGwP+X2fO MIME-Version: 1.0 X-Received: by 10.180.198.77 with SMTP id ja13mr2324144wic.34.1382536559316; Wed, 23 Oct 2013 06:55:59 -0700 (PDT) Received: by 10.227.214.144 with HTTP; Wed, 23 Oct 2013 06:55:59 -0700 (PDT) In-Reply-To: <63d89379efdd7f2ba0bcf0b62d5025af.squirrel@webmail.klapt.com> References: <63d89379efdd7f2ba0bcf0b62d5025af.squirrel@webmail.klapt.com> Date: Wed, 23 Oct 2013 17:55:59 +0400 Message-ID: To: Anatol Belski Cc: Pierre Joye , PHP Internals , Andi Gutmans , Zeev Suraski , Xinchen Hui Content-Type: multipart/alternative; boundary=047d7b604a6881ebd304e968e02a Subject: Re: [PHP-DEV] Re: Fix for bug #50333 From: dmitry@zend.com (Dmitry Stogov) --047d7b604a6881ebd304e968e02a Content-Type: text/plain; charset=UTF-8 Hi Anatol, First of all PHP is mainly used as NTS on Linux (LAMP stack) It's the reason I tested it first, to check if your patch affects the performance that is really important for users. I still think that tsrm_do_alloca() have to be replaced by do_alloca(). They have exactly the same logic, except that the first one fallback to malloc() and the second one to emalloc(). It must not be affected by malloc()s and realloc()s if you changed them into emalloc() and erealloc(). May be I missing something... I'm not sure about alloca() usage on Windows, but you may change zend.h if you like. BTW: I don't think we should replace alloca() by _malloca(), because do_alloca() already does the same in portable way and uses per-request heap. Thanks. Dmitry. On Wed, Oct 23, 2013 at 2:55 PM, Anatol Belski wrote: > Hi Dmitry, > > On Mon, October 21, 2013 14:30, Dmitry Stogov wrote: > > Hi, > > > > > > I don't have strong opinion about the patch. > > I thought malloc() -> emalloc() change might improve PHP performance in > > general, but unfortunately it doesn't. On the other hand the patch is > quite > > big and introduces source level incompatibility. > > > > The patch is not complete. At least it misses this chunk: > > > > > > --- a/sapi/cgi/cgi_main.c > > +++ b/sapi/cgi/cgi_main.c > > @@ -1396,7 +1396,7 @@ static void init_request_info(fcgi_request *request > > TSRMLS_DC) > > } else { > > SG(request_info).request_uri = > > env_script_name; } > > - free(real_path); > > + efree(real_path); > > } > > } else { > > /* pre 4.3 behaviour, shouldn't be used but > > provides BC */ > > > > It's also much better to use do_alloca() instead of tsrm_do_alloca() (the > > patch changed them to less efficient emalloc()). May be if you change > it, > > we would see improvement :) > > > > As I said, currently, the patch doesn't significantly affect performance > > of non-thread-safe build on Linux. > > > > > > master patched improvement Blog (req/sec) 106.1 105.1 -0.94% drupal > > (req/sec) 1660.5 1668.6 0.49% fw (req/sec) 231.7 227.499 -1.81% hello > > (req/sec) 11828.8 11980.5 1.28% qdig (req/sec) 470 477.3 1.55% typo3 > > (req/sec) 580.1 579.3 -0.14% wordpress (req/sec) 185.9 188.5 1.40% > xoops > > (req/sec) 130 131.2 0.92% scrum (req/sec) 185.199 185 -0.11% ZF1 Hello > > (req/sec) 1154.7 1155.2 0.04% ZF2 Test (req/sec) 248.7 250.7 0.80% > > Thanks. Dmitry. > > > > > > > > > > On Fri, Oct 18, 2013 at 7:33 PM, Anatol Belski wrote: > > > > > >> Hi, > >> > >> > >> the pull request https://github.com/php/php-src/pull/500 fixing the bug > >> #50333 is ready to review. Manual tests done so far on linux and > >> windows in TS and NTS mode with CLI and Apache show no regression. The > >> performance tests are to be done yet. > >> > >> Regards > >> > >> > >> Anatol > >> > > thanks for the comments, the CGI part is fixed in the same patch. > > While investigating on how to go further with your suggestion, I've yet a > couple of open questions. > > The reason for moving files into Zend, as I can see from the original > patch is, that the tsrm_init has to happen after Zend memory manager init > in order to use the e* function family. It has to be true also for the > do_alloca() case as when the stack size was exceeded, it'll fallback to > emalloc(). For that reason, I'd rather implement your suggestion into the > existing patch as it's quicker just to see if it'd make sense at all. If > it would, tsrm files can be moved back into TSRM/ and one can look for > magic to initialize it in the right order. > > It'd of course make sense to convert everything for do_alloca() usage, > just a replace for tsrm_do_alloca would already work, but ... there are > some places in the original codelike > http://lxr.php.net/xref/PHP_TRUNK/TSRM/tsrm_virtual_cwd.c#493 where malloc > is used. Or virtual_file_ex which is using realloc(), with do_alloca that > memory should be probably just left unfreed on the stack? Do you generally > think i should touch those places, would it be ok to leave them alone for > now for the tests? As otherwise it might need signature change of some > functions, it's about use_heap when the stack size is exceeded to avoid > memory leaks. > > When I look here http://lxr.php.net/xref/PHP_TRUNK/Zend/zend.h#200 , only > some GNU based platform profits from alloca() on both TS and NTS. Some > others are only active with NTS only. Is there a particular reason for > that? I think that macros could be refactored at least for the Windows > part, as this page > http://msdn.microsoft.com/en-us/library/5471dc8s(v=vs.110).aspx deprecates > _alloca nowadays. > > Also wondering why you was doing NTS perf tests, as the ticket is about > improvement for multi-threaded envs. Nevertheless the overall improvement > were even better of course :) > > Regards > > Anatol > > --047d7b604a6881ebd304e968e02a--