logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: PHP Caching extensions accessing shared memory Page Previous  1, 2, 3  Next
Author
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 13 Feb '15 0:29    Post subject: Reply with quote

ng4win wrote:
Hmmm php does not have rights there to write anything so this file ain't there...
Then it most probably is in your tmp directory. It should be somewhere.
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Fri 13 Feb '15 1:04    Post subject: Reply with quote

Done several advanced searches but nope, nothing.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 13 Feb '15 1:34    Post subject: Reply with quote

The SYSTEM in ZendOPcache.MemoryBase@SYSTEM refers to the user that runs php. Open a DOS-prompt as Administrator, go to the root of your drive(s), and type

C:\>dir ZendOPcache.MemoryBase* /s

On my laptop this also reveals a ZendOPcache.MemoryBase@Jan.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 13 Feb '15 2:14    Post subject: Reply with quote

I put opcache inplace but i am receiving these errors in my syslog.

Code:
The description for Event ID 487 from source Zend OPcache cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Unable to reattach to base address
Attempt to access invalid address.


And if i put mmap base in place with a random string.

Code:
opcache.mmap_base=nginx


I get a APP Crash error.
Code:
The description for Event ID 0 from source Zend OPcache cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Bad mapping address specified in opcache.mmap_base
The operation completed successfully.

 php-cgi.exe
   5.6.5.0
   54c04495
   php_opcache.dll
   5.6.5.0
   54c04700
   c0000005
   00000000000057f5
   1428
   01d0472247fdc276
   C:\Users\root\Desktop\php-5.6.5-nts-Win32-VC11-x64\php-cgi.exe
   C:\Users\root\Desktop\php-5.6.5-nts-Win32-VC11-x64\ext\php_opcache.dll
   8e0d668e-b315-11e4-922c-0cc47a076a47


Isit suppose to be a memory address ?, only maybe the following.

Code:
opcache.mmap_base=0x20000000



//EDIT :
Using the following seems to have fixed those errors for me Very Happy Smile

Code:
opcache.mmap_base=0x20000000


Has to be a memory address documentation should be clearer about this.

I also use Wincache still as a usercache mechanism for my PHP application i just set the following for wincache.
Code:
wincache.namesalt=0x200000

http://php.net/manual/en/wincache.configuration.php#ini.wincache.namesalt
And it seems to be working well so far i will let you know how it goes.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 13 Feb '15 8:54    Post subject: Reply with quote

C0nw0nk wrote:
//EDIT :
Using the following seems to have fixed those errors for me Very Happy Smile

Code:
opcache.mmap_base=0x20000000


Has to be a memory address documentation should be clearer about this.

I am a bit surprised that 0x20000000 works in your 64bit PHP. For 64bit systems the addresses should be longer, for instance:

Code:
opcache.mmap_base=0x0000200000000000

See the OPcache code at this line:
https://github.com/zendtech/ZendOptimizerPlus/blob/master/shared_alloc_win32.c#L186
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Fri 13 Feb '15 10:40    Post subject: Reply with quote

Jan-E wrote:

See the OPcache code at this line:
https://github.com/zendtech/ZendOptimizerPlus/blob/master/shared_alloc_win32.c#L186


The comment above that is "awesome". Nobody seem to remember why it is that way.

Quote:
/* TODO:
improve fixed addresses on x64. It still makes no sense to do it as Windows addresses are virtual per se and can or should be randomized anyway
through Address Space Layout Radomization (ASLR). We can still let the OS do its job and be sure that each process gets the same address if
desired. Not done yet, @zend refused but did not remember the exact reason, pls add info here if one of you know why Smile
*/
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Fri 13 Feb '15 11:33    Post subject: Reply with quote

Pierre Joye knows why. Yet another disagreement with Zeev:
https://github.com/zendtech/ZendOptimizerPlus/issues/109#issuecomment-20654482
https://github.com/zendtech/ZendOptimizerPlus/commit/8b518a9cbf7f0264f0f7d8ee5c3b8c56908a6625
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Fri 13 Feb '15 13:05    Post subject: Reply with quote

Jan-E wrote:
The SYSTEM in ZendOPcache.MemoryBase@SYSTEM refers to the user that runs php. Open a DOS-prompt as Administrator, go to the root of your drive(s), and type

C:\>dir ZendOPcache.MemoryBase* /s

On my laptop this also reveals a ZendOPcache.MemoryBase@Jan.

I've searched for zend*, nothing, maybe it got mapped away inside the pagefile (which is normal behavior).
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Fri 13 Feb '15 14:44    Post subject: Reply with quote

ng4win wrote:
maybe it got mapped away inside the pagefile (which is normal behavior).

> https://gist.github.com/ck-on/4959032/?ocp.php
> Shared memory model win32
Yep I thought so Very Happy
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 13 Feb '15 15:24    Post subject: Reply with quote

I am actualy curious if wincache is sharing its memory with all processes now. (I have to use Wincache or a cache mechanism that allows for a user cache since i run Joomla sites so the only valid user caches are APC, Cachelite, Memcache, Memcached, Wincache and XCache.) But opcache is good for caching the opcode just disable opcode caching in any of the other caches you use to prevent crashes or issues.


Code:
wincache.namesalt=0x200000


Ever since putting in the memory address all processes should be storing and grabbing cached instances to me seems faster.

I was reading that those using IIS web servers this automaticly gets handled by IIS what means microsofts web server automaticly selects a address to use, but since we do not use their web server we have to set this manualy for our setups.

Also Jan because i am using a 64bit install should i switch out my memory addresses to be longer, since with the namesalt on wincache it wont work using a longer address since you are limited to just 8 chars long. =<8
http://php.net/manual/en/wincache.configuration.php#ini.wincache.namesalt
Quote:
This is used to avoid conflicts that may be caused if other applications within an IIS worker process tries to access shared memory. The length of the namesalt string cannot exceed 8 characters.


But i can change my opcache mmap base address to be the longer one. If it is worth it ?

I am still testing with it but so far it seems to be good. I will post back in a few hours and let you know if Wincache has dropped all cached content again when it changes to the next php process.

Only legal or allowed values for us to use as memory mapping addresses it seems.

64Bit :
0x0000100000000000, 0x0000200000000000, 0x0000300000000000, 0x0000700000000000

32Bit :
0x20000000, 0x21000000, 0x30000000, 0x31000000, 0x50000000

//EDIT :
Opcache is fine with shared memory Wincache is not Sad. Wincache dropped all the user items it has cached again. Need a user cache plugin that will work with shared memory.


Last edited by C0nw0nk on Sat 14 Feb '15 5:35; edited 1 time in total
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 14 Feb '15 3:57    Post subject: Reply with quote

I know XCache as a user cache mechanism wont share its memory otherwise ng4win would of said so.

Do we know if APC as a usercache mechanism not a opcode cache will share its memory this is my only problem now.

Opcode caching shares memory user caching does not Sad
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Sat 14 Feb '15 6:14    Post subject: Reply with quote

Try php_apcu.dll
https://github.com/krakjoe/apcu
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 14 Feb '15 16:16    Post subject: Reply with quote

Jan-E wrote:
Try php_apcu.dll
https://github.com/krakjoe/apcu


I have the apcu build out of your latest PHP pack Jan.

Quote:
APCu Support Enabled
Version 4.0.8
APCu Debugging Disabled
MMAP Support Disabled
Serialization Support php
Revision $Revision: 328290 $
Build Date Feb 4 2015 02:21:50


Code:
extension=php_apcu.dll


Running on default config as of if it is working or not i cant tell unlike wincache or opcache it does not give us stats and when i see a switch in or i close the current php process i have no way of seeing if it is still holding the cached data ?

Aswell as i dont think it is very stable.
For some reason it keeps occasionaly crashing php.
Code:
Faulting application name: php-cgi.exe, version: 5.6.5.0, time stamp: 0x54c04495
Faulting module name: php_apcu.dll, version: 5.6.5.0, time stamp: 0x54d17431
Exception code: 0xc0000005
Fault offset: 0x0000000000003876
Faulting process id: 0x1f80
Faulting application start time: 0x01d0485f68316634
Faulting application path: C:\Users\root\Desktop\php-5.6.5-nts-Win32-VC11-x64\php-cgi.exe
Faulting module path: C:\Users\root\Desktop\php-5.6.5-nts-Win32-VC11-x64\ext\php_apcu.dll
Report Id: a631bf35-b453-11e4-922c-0cc47a076a47


And thats just by adding the extension in on its default settings i have not even tried to change any configs yet Shocked Perhaps it is incompatible with opcache or something ?

I cant use APCu crashing to much with opcache and i dont even know why let alone if it is actualy going to share its memory with other processes.

Wincache and Xcache seem to be the most stable but neither share their memory for user caching so back to square one Sad
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 15 Feb '15 4:18    Post subject: Reply with quote

Ok i think i have found what i have been looking for all along i will post back in the morning letting you know if this is a soloution.

But i was googling and reading about on various forums when suddenly i turned to my PHP Info page.

On our php info pages Wincache is the only cache that has a undocumented function.

Code:
wincache.apppoolid=


After looking into this function i found a similar topic on the IIS forums.
http://forums.iis.net/post/2021001.aspx

Apparently the app pool id can be numbers letters or a word name etc. But all of your PHP-CGI processes will then look to this app pool id and use that to pull and use items with eachother.

Code:
wincache.apppoolid=MYID


After setting this i noticed straight away that all my php processes hit counts from wincache was allot higher what to me indicates wincache is no longer counting the hit count of a single process but rather them all. (Shared memory caching)

In the morning when i get up i will check on my server (production) and tell you if my caches have dropped again or this time are still running.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 15 Feb '15 15:32    Post subject: Reply with quote

Success Smile Mr. Green

Wincache now shares its memory just by setting
Code:
wincache.apppoolid=

Another function that is undocumented and unclear what its intentions are.

So now i have a user cache that shares its memory too and i think i will drop zend opcache and enable wincaches opcache instead. Smile (I don't know what one is faster but i prefer running less plugins/extensions.)

So the final soloution is you can either use Wincache as both a opcache and usercache by setting the following to a random name number or string.
Code:
extension=php_wincache.dll
wincache.apppoolid=C0nw0nk


Or you can just use wincache as a usercache and put zend's opcache in and make it share its memory with every process using the following.
Code:
zend_extension=php_opcache.dll
opcache.mmap_base=0x20000000


Works out for all of us who are using PHP on Windows.

//EDIT :
I submitted a report for PHP.NET to alter the documentation to include the undocumented function.

https://bugs.php.net/bug.php?id=69062
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 26 Feb '15 0:03    Post subject: Reply with quote

php_wincache was patched three hours ago. Description of the patch:

Move shared memory segments out of the Windows System Pagefile

http://svn.php.net/viewvc/pecl/wincache/trunk/
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 26 Feb '15 12:15    Post subject: Reply with quote

Thanks for the information jan when will you compile the updated version into your builds Very Happy ?
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 26 Feb '15 12:37    Post subject: Reply with quote

I already did that.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 26 Feb '15 13:11    Post subject: Reply with quote

So where does it store the memory pool now if not in our paging file, By default the windows paging file was limited to 4GB but i set mine to be system managed so it became the same as the ammount of ram i have on the machine.
Back to top
Jan-E



Joined: 09 Mar 2012
Posts: 1248
Location: Amsterdam, NL, EU

PostPosted: Thu 26 Feb '15 13:17    Post subject: Reply with quote

Just in RAM, I suppose. But I did not look how Eric Stensen patched it.
Back to top


Reply to topic   Topic: PHP Caching extensions accessing shared memory View previous topic :: View next topic
Post new topic   Forum Index -> Other Software Page Previous  1, 2, 3  Next