Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88690 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7787 invoked from network); 6 Oct 2015 06:27:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Oct 2015 06:27:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=themattficken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=themattficken@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.68 as permitted sender) X-PHP-List-Original-Sender: themattficken@gmail.com X-Host-Fingerprint: 209.85.215.68 mail-la0-f68.google.com Received: from [209.85.215.68] ([209.85.215.68:36298] helo=mail-la0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/53-05723-6D963165 for ; Tue, 06 Oct 2015 02:27:34 -0400 Received: by laem9 with SMTP id m9so7210036lae.3 for ; Mon, 05 Oct 2015 23:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8dwG07lemZ5+6QLP5tduNSxiy7R4eXv4/vJEY55hqRA=; b=LCRC0eYei1D4b0WU1xKI1hF/EgunkdLLW0wzJH2Cr9oluBHlk0CquU8zjVQZcV2kry H+OfW9SsujKlinqzS1c67YO0UY0Y+L4ExgWZgndVrRuspHFQhqzQmNsHj/jhUVUP+9YS 2dU/0nTsS4rU5broEmlRAvxLVE6FmU0hoMiKXi5C1LaACYdTSCq8Jvmgl5QeqYLdsbLT X3CsW+0GM5P5SdIAH8VWB956qUnyNpCRo4eT9W4clmZHzE27lhRa5haDiEEp6cCNxUpa XrW3v2LClwPFS003IOhJQthcJK2qJ/YAM+qIjo4Z4fLzpBr4+xh9dXrbdpwzSCD1R1mA lgMQ== MIME-Version: 1.0 X-Received: by 10.112.184.137 with SMTP id eu9mr13530551lbc.21.1444112850552; Mon, 05 Oct 2015 23:27:30 -0700 (PDT) Received: by 10.112.46.38 with HTTP; Mon, 5 Oct 2015 23:27:30 -0700 (PDT) In-Reply-To: References: Date: Mon, 5 Oct 2015 23:27:30 -0700 Message-ID: To: Eric Stenson Cc: Dmitry Stogov , Pierre Joye , Anatoliy Belsky , Laruence , PHP Internals , "dmitry@php.net" Content-Type: multipart/alternative; boundary=001a11c3ccaa790eaf052169b982 Subject: Re: [PHP-DEV] Re: Windows OpCache bug fix From: themattficken@gmail.com (Matt Ficken) --001a11c3ccaa790eaf052169b982 Content-Type: text/plain; charset=UTF-8 Ultimately if the 2nd OpCache is shared in a new SHM, in-process in a new SHM or in-process Heap, memory will increase, scripts have to be recompiled and there are consistency issues. File-cache will avoid recompiling scripts, but unless OpCache is disabled, there needs to be a 2nd OpCache stored somewhere. For the stat, reset and revalidate consistency issues, to build off Anatol's idea: If can't reattach to base address, then reattach to any address and create a 2nd OpCache in Heap, BUT keep the SHM open so that the stat fields(fe ZCSG(hits)) are still accessible. Those fields aren't pointers so they should work from whatever base address MapViewOfFileEx() provides, if not, could fork ZCSG into 2 structs (somehow reuse existing stat fields on existing SHM). opcache_get_status() in any/all processes would read those fields from SHM. Since there would be 2+ processes with an OpCache (the original in SHM, and sidestep OpCaches on the heaps of those processes), can't use a simple flag (would be cleared by 2nd process, before 3rd got it). Could add ZCSG(opcache_count) field and increment every time an OpCache gets created (and decrement on process exit). Simple, but not using zend_shared_alloc_lock() avoids creating new locking issues. Add a new ZCSG(opcache_revalidate_count) in that struct that is set to ZCSG(opcache_count) anytime opcache_reset() or opcache_invalidate() called or if persistent_compile_file() finds a changed script. In process with side-step OpCache, in persistent_compile_file() (assuming opcache.validate_timestamps && revalidate_freq>0) will check if ZCSG(opcache_revalidate_count) > 0 and will then decrement the count and reload scripts from file-cache (where it checks opcache.revalidate_freq). And then wrap this all in some `#ifdef ZEND_WIN32`s Would still have extra memory usage. When I have a process that can't reattach I usually get several, so having an in-process OpCache(SHM or Heap) may lead to more memory usage than a shared SHM, but having 2 SHMs in a process would mess up the nice existing code. Don't have to recompile scripts(quickly loads from file-cache) and fixes the 3 consistency issues, and would keep serving up requests without performance loss. Yes, temporary incomplete solutions often get forgotten and not replaced later with a better complete solution, but in this case we're motivated try to fully fix this whole issue and if that doesn't work, at least build a more complete solution, but that takes time (known issue for already a few years), we should do something that works for now. This is more complex than a bugfix that creates a 2nd SHM OpCache. Can we do this now? What is still possible for 7.0? 7.0.1? On Mon, Oct 5, 2015 at 11:49 AM, Eric Stenson wrote: > >From: Dmitry Stogov [mailto:dmitry@zend.com] > > > >> On Thu, Oct 1, 2015 at 11:54 AM, Matt Ficken > >> wrote: > >> > >>> Pierre Joy wrote: > >>> And what wincache does. It is slower but the request is served. > >> > >> WinCache (file cache) if it can't reattach, creates a new shared mem > >> file > > > > I'm not sure how WinCache works, but opcache already implements most > > necessary functionality. > > Sorry for getting to the party late, but let me clarify what WinCache does: > > 1. For the opcode cache, if WinCache can't map to the same address, it > falls back to using process-local (heap) memory for the opcode arrays. > This is because the elements in the opcode arrays contain absolute > pointers, and we don't want to spend cycles (a) converting all pointers to > offsets when copying opcode arrays into shared memory, and then (b) > converting all offsets back to absolute addresses when copying the opcode > array back out of shared memory. WinCache simply gets the pointer to the > opcode array in shared memory and returns it, unmodified, to the PHP Core > for execution. > > When WinCache falls back to process-local memory, it does NOT create a > second memory mapped segment, and does not chew additional cross-process > resources. > > 2. WinCache's file cache does not map to an identical address in all > processes. We simply map it to *any* address (using NULL for the suggested > address to MapViewOfFileEx), and then use relative offsets in the cache > structures for all entries in shared memory. > > 3. WinCache's user cache and session cache are similar to the file cache, > and do not have to map to the same address in all processes. Cache entries > use relative offsets to locate cache entries, and the values do not contain > absolute addresses. > > Finally, For PHP7, WinCache has removed its opcode cache. We assume that > Windows consumers of PHP7 will use Zend Opcache for opcode caching. > > Thx! > --E. > --001a11c3ccaa790eaf052169b982--