Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69962 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9347 invoked from network); 30 Oct 2013 06:49:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2013 06:49:48 -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.173 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.212.173 mail-wi0-f173.google.com Received: from [209.85.212.173] ([209.85.212.173:43166] helo=mail-wi0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/20-07416-B0CA0725 for ; Wed, 30 Oct 2013 01:49:47 -0500 Received: by mail-wi0-f173.google.com with SMTP id ey11so6297319wid.12 for ; Tue, 29 Oct 2013 23:49:44 -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=FGncAg3xS54tDR+M/8OQkczltbUf2sBx9D9Uq1eVcXY=; b=KyRBf94rnYA6Lb+o/iv6Ys9ikI7b5Xz9INFVm5sqfuZqUH29SMF7jbeVsx+4NkfQZC 48lxL4IGA0A5Wv2gt3wqRjtxQAs5CBgDE/I2X8dyb8VzvUKVDExFvdOt+YePebZAb6VF MXE2mr0/sgNhRaQtC5OfqRB381Lg6/1ONms0U/e5ajuTvGH3J+tJ3nx080z7xrXxr2Re 883V82mM+OvfQjGvSd8UyBKhNIeQfE7G7Fkq2Ghq+/xA/YrCrl2GNnDH36HjzCel4NmJ 7bXI1lc41uVvvs2XyCEzF1s6X2O0uUF61bYpLvfR0qreYIFvqiAew5GcR73PMDz4SY3B XPog== X-Gm-Message-State: ALoCoQnufD0WYJJ5a2s1O96PQaa51DYL5a2KeAc2j8DLV1Y/j61TNaunwEQ+MpMoGktBxd/OG/rnpR1ziiC01cgyIxS6v6x4RId4qAXH7lhsKFvuQ2wbQgcNCw+2Wp1W3RGgIKUIwF5q MIME-Version: 1.0 X-Received: by 10.194.88.225 with SMTP id bj1mr415405wjb.50.1383115784698; Tue, 29 Oct 2013 23:49:44 -0700 (PDT) Received: by 10.227.214.144 with HTTP; Tue, 29 Oct 2013 23:49:44 -0700 (PDT) In-Reply-To: <1383099923.15492.36.camel@ghost> References: <63d89379efdd7f2ba0bcf0b62d5025af.squirrel@webmail.klapt.com> <7c830ad80d33e82eb5f1553d03a44c6d.squirrel@webmail.klapt.com> <1383099923.15492.36.camel@ghost> Date: Wed, 30 Oct 2013 10:49:44 +0400 Message-ID: To: Anatol Belski Cc: Pierre Joye , PHP Internals , Andi Gutmans , Zeev Suraski , Xinchen Hui Content-Type: multipart/alternative; boundary=089e010d852a07d1f804e9efbd25 Subject: Re: [PHP-DEV] Re: Fix for bug #50333 From: dmitry@zend.com (Dmitry Stogov) --089e010d852a07d1f804e9efbd25 Content-Type: text/plain; charset=UTF-8 I don't think it makes sense to invest into it right now. Lets finish with existing patch. Also, alloca() allocates data on CPU stack, so such data is automatically freed when function returns. In case you change CWD_STATE_COPY() to use alloca(), the "state" couldn't be returned from the function. I'm not sure if it'll work for all use cases. Thanks. Dmitry. On Wed, Oct 30, 2013 at 6:25 AM, Anatol Belski wrote: > Hi Dmitry, > > On Tue, 2013-10-29 at 11:45 +0400, Dmitry Stogov wrote: > > Hi Anatol, > > > > > > Thank you for update. > > > > I'm surprised you don't see speed difference even with ZTS :( > > > > > > I didn't get what you propose to change in virtual_file_ex(). > > > > > > I'll do a more careful patch review later on this week. > > > > > > the story is that > > - the original patch had replacements for all tsrm_do_alloca() and > malloc() to emaloc() > - after that, i've turned the places originally having tsrm_do_alloca() > to do_alloca() > > Just as we discussed, and that's the current state of the patch. Still, > there are many places using the e*() family of functions, like > > > https://github.com/weltling/php-src/blob/bug50333/Zend/zend_virtual_cwd.c#L151 > > https://github.com/weltling/php-src/blob/bug50333/Zend/zend_virtual_cwd.c#L1340 > > Alone for that two I find 21 occurrences of each elsewhere in the file. > As they are used very often in other filesystem functions like > virtual_copy(), virtual_rename(), etc. That's why I thought it could > make sense to turn any emalloc() usage into do_alloca(). But as the > do_alloca(size, use_heap) requires that use_heap argument to determine > the fallback situation, the signatures in at least that two cases for > virtual_file_ex() or CWD_STATE_COPY() will need to be extended, so the > correct freeing can happen. A simple snippet in pseudo code, just to > illustrate the idea > > currently: > > some_function() > { > CWD_STATE_COPY(&new_state, &CWDG(cwd)); > virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC); > CWD_STATE_FREE(&new_state); > } > > should be like: > > some_function() > { > ALLOCA_FLAG(use_heap) > CWD_STATE_COPY(&new_state, &CWDG(cwd), use_heap); > virtual_file_ex(&new_state, path, NULL, CWD_REALPATH, use_heap > TSRMLS_CC); > CWD_STATE_FREE(&new_state, use_heap); > } > > That's of course much deeper change and would affect more code outside > just the scope of that one file, still that's manageable. I'd expect > some more functions needing that, so then we'd have do_alloca() usage > everywhere and drop all e*() invocations. Maybe then we see some > effect :) > > Regards > > Anatol > > > > > > --089e010d852a07d1f804e9efbd25--