Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44958 invoked from network); 5 Oct 2015 11:08:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2015 11:08:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.53 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.53 mail-vk0-f53.google.com Received: from [209.85.213.53] ([209.85.213.53:35938] helo=mail-vk0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D5/90-40211-F0A52165 for ; Mon, 05 Oct 2015 07:08:00 -0400 Received: by vkfp126 with SMTP id p126so93913277vkf.3 for ; Mon, 05 Oct 2015 04:07:57 -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=Oyk144Nz6tbYLTLunJi9wl0jj3SPjakol1WnxJy6+7U=; b=jRIC8QZ2ISopt3PBxCRyWH9ck5am/W4AfxVN57JqJoYfnyRN/Kg6TcIngu2vk9XoL8 mFUV5wU81SlCb2xriB6/cLgugXVWOmKDU++Bt5W3ZzHXFykRQEwwT8DfygO4P1Q2HDGv 42YkfvyIqa72QK8X0wvfzyyCUZ6jYfoimzdAmDGh1Yxz1p3EYIbUVTCdsmsdQ9Pr0r/C 8sNxFYuvCYc/hOCojNXdoqn2/0A4adfeo1WdXAz4Zj+pTwCvQRbFJvvLKuBh5A1FvYZN /YhSvVb2U/p/eCgc3SlDrI4sTArYVGfcjvGxmT6W4y3CIfH999Z9faeXmVo3ZopQJ8Qa 9/YQ== X-Gm-Message-State: ALoCoQkWfPjiG8L5E6Xv4yuzHgNbcXnmLcv9EYPaVtZ7O+TPrzpTzTORCKa78/GYXj3RJrIrldNhPxG8+FfqferIPBDpH6wwlKvx/qREVxu8v35DSDfZcjc8NhRrk92AYwopkOu6SrOjTf6UWj5w5cKPUvNpTq0OJi0S3H+hwtB0xoAfG3xtktY= MIME-Version: 1.0 X-Received: by 10.31.168.79 with SMTP id r76mr45015vke.102.1444043277143; Mon, 05 Oct 2015 04:07:57 -0700 (PDT) Received: by 10.103.24.5 with HTTP; Mon, 5 Oct 2015 04:07:57 -0700 (PDT) In-Reply-To: <01e101d0ff3f$8cc0c310$a6424930$@belski.net> References: <024e01d0fc89$31005990$93010cb0$@belski.net> <01e101d0ff3f$8cc0c310$a6424930$@belski.net> Date: Mon, 5 Oct 2015 14:07:57 +0300 Message-ID: To: Anatol Belski Cc: Matt Ficken , Pierre Joye , Laruence , PHP Internals , "dmitry@php.net" Content-Type: multipart/alternative; boundary=001a114159029328e90521598655 Subject: Re: [PHP-DEV] Re: Windows OpCache bug fix From: dmitry@zend.com (Dmitry Stogov) --001a114159029328e90521598655 Content-Type: text/plain; charset=UTF-8 On Mon, Oct 5, 2015 at 10:29 AM, Anatol Belski wrote: > Hi Dmitry, > > > -----Original Message----- > > From: Dmitry Stogov [mailto:dmitry@zend.com] > > Sent: Friday, October 2, 2015 9:34 AM > > To: Anatol Belski > > Cc: Matt Ficken ; Pierre Joye > > ; Anatoliy Belsky ; Laruence > > ; PHP Internals ; > dmitry@php.net > > Subject: Re: [PHP-DEV] Re: Windows OpCache bug fix > > > > > Dmitry, I'd have a question to this > > > > Also. if we can't map SHM into desired address space, we may map it > > > > in > > > any > > > > other address and copy data into the process memory similar to > > > file-cache. > > > In randomized memory layout, even the base were available and > > > OpenFileMapping were worky, some parts of that memory were already > > taken. > > > How exactly it could be done, could you please give a couple of > > > pointers to this? > > > > > > If MapViewOfFileEx(..., wanted_mapping_base) fails, we do > > MapViewOfFileEx(..., NULL). > > > > > > > Would the file cache be always required then? > > > > > > > This is not necessary, but depends on implementation of course. > > > Thanks for the advice. I was playing with this over these days. There are > two usual cases where it possibly fails when reattaching ATM > > - > https://github.com/php/php-src/blob/PHP-7.0/ext/opcache/shared_alloc_win32.c#L151 > - the saved address is available but is not suitable > - > https://github.com/php/php-src/blob/PHP-7.0/ext/opcache/shared_alloc_win32.c#L159 > - the actual MapViewOfFileEx case > > An unrelated plain C test shows, that MapViewOfFileEx can possibly fail > when called second time, too. Even with NULL or with another address as > base. But even if it could map at a different base - the internal > structures will probably have invalid addresses. right. we might need different code for zend_accle_hash access or convert corresponding structures to PIC. For opcdeos "invalid address" don't matter because we will copy them into process memory and fix (like in file-cache). > So it looks like there's indeed no profit to do any retry once the actualy > base address needed was failed to reattach to. > > IMHO the scenario that were usable - in case it fails to reattach to the > exact address, it has to switch to heap. Just for one request, it should > get a heap allocated segment and then invalidate all the cache. That way we > fulfill the following > > - the request is served for sure > - the scripts are not cached indeed, so no divergence with the actual real > cache > > A heap fallback memory handler would be probably quite easy to implement. > What do you think? > > Apropos with the heap - it also looks like when PHP is used as module > under mpm_winnt, all the cache could use heap instead of SHM. In that case, > there is only one Apache process serving with many threads. Except one > would want to share that cache outside Apache, using heap there could be a > much simpler solution. > Heap based cache makes the same problems. It increase the memory usage and doesn't provide cache consistency. Just fall-back to file-cache may be better. Actually, when I implemented file-cache I had a though about different storage back-ends (e.g. sqlite or memcache). This abstraction might make support for "improperly mapped SHM" quite easy. Thanks. Dmitry. > > Regards > > Anatol > > > > --001a114159029328e90521598655--