locked
Thread Safe RRS feed

  • Question

  • User2009299772 posted
    Hi there, When we will have a Thread-safe version? Thanks Ricardo
    Saturday, April 28, 2012 5:47 AM

All replies

  • User409000176 posted

    You are welcome to download the source from the PECL site and compile a thread-safe version on your own, however, it's not reccomended.

    Wincache is designed to be used with Fast-CGI + IIS, so a thread-safe version is a waste of cycles.  :-)

    Thx!

        --E.

    Friday, May 18, 2012 2:56 PM
  • User-1974255642 posted


    You are welcome to download the source from the PECL site and compile a thread-safe version on your own, however, it's not reccomended.

    Been there, done that. It will not compile as ts. x64 nts and x86 nts are fine, but x86 ts and x64 ts are a no-go:

    C:\php-sdk\php54dev>nmake /i /nologo php_wincache.dll
    wincache_opcopy.c
    pecl\wincache\wincache_opcopy.c(105) : error C2081: 'tsrm_ls' : name in formal parameter list illegal
    pecl\wincache\wincache_opcopy.c(120) : warning C4028: formal parameter 5 different from declaration
    pecl\wincache\wincache_opcopy.c(223) : error C2059: syntax error : 'type'
    pecl\wincache\wincache_opcopy.c(590) : error C2059: syntax error : 'type'
    pecl\wincache\wincache_opcopy.c(726) : error C2059: syntax error : 'type'
    pecl\wincache\wincache_opcopy.c(735) : error C2059: syntax error : 'type'
    pecl\wincache\wincache_opcopy.c(1454) : error C2059: syntax error : 'type'
    pecl\wincache\wincache_opcopy.c(2938) : error C2059: syntax error : 'type'
    wincache_utils.c
    pecl\wincache\wincache_utils.c(330) : error C2065: 'tsrm_ls' : undeclared identifier
    pecl\wincache\wincache_utils.c(333) : error C2065: 'tsrm_ls' : undeclared identifier
    pecl\wincache\wincache_utils.c(333) : error C2065: 'tsrm_ls' : undeclared identifier

    Friday, May 18, 2012 5:14 PM
  • User409000176 posted

    Jan--

    I've checked in the fix such that Wincache should now compile with #define ZTS (configure --enable-zts).  It is, however, not tested nor supported for Wincache to run with --enable-zts.  Your Milage May Vary(tm), Caveat Emptor(tm), "The Secretary Disavows All Knowledge...", etc., etc..

    Good Luck!

        --E.

    Friday, May 25, 2012 2:51 PM
  • User-1974255642 posted

    Hi Eric,

     I will have to test that. I started compiling under PHP5.4.2 nts x86 and my php-cgi crashed immediately. I was already expecting that because I saw you had increased the ZCACHE maximum to 1024. Well, 1024 is not possible, the current max for the ucachesize under PHP 5.4 is 934 (I checked that one with today's build) and 930 under PHP 5.3. To be safe I always compile with a ZCACHE maximum of 928.

     While we are at this topic: scachesize never did anything in the RC1 build.

    Jan

    PS x64 is even less supported than thread safe and/or using php_wincache.dll with Apache, but under x64 the maxima are 2046 (2G - 2M) ;)

    Friday, May 25, 2012 5:37 PM
  • User-1974255642 posted

    OK, it compiled as thread safe. But when I loaded the extension in php.ini with the default parameters and executed a 'php-cgi phpinfo.php' php-cgi.exe crashed after (!) it had produced the phpinfo() output. 'php phpinfo.php' ran happily and produced the text output of phpinfo().

    By mistake, at a certain moment I compiled php_wincache as static in stead of shared (--enable-wincache should have been --enable-wincache=shared). Surprisingly enough the static build did not lead to a crash when running 'php-cgi phpinfo.php'.

    My gut feeling: there is something rotten in the memory handling. Apparently, the NTS version does not have full access to a 1GB memory segment. And the difference between the static and shared builds of the TS version also smells like malloc problems.

    Time to consult Dmitry and/or Pierre once again?

    Sunday, May 27, 2012 6:04 PM
  • User-1974255642 posted

    Changes needed to make php_wincache compile as NTS X64 extension. In config.w32 we have to remove the /SAFESEH flag, which is not compatible with X64. Changed code:

    /* edited
     When /SAFESEH is specified, the linker will only produce an image if it can also produce a table
     of the image's safe exception handlers. This table specifies for the operating system which
     exception handlers are valid for the image.
     */
     PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
     if (!PHP_CL) {
      ERROR("MS C++ compiler is required");
     }
     X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
     if (X64) {
      /*
      /SAFESEH is only valid when linking for x86 targets. /SAFESEH is not supported for platforms
      that already have the exception handlers noted. For example, on x64 and Itanium, all exception
      handlers are noted in the PDATA. ML64.exe has support for adding annotations that emit SEH
      information (XDATA and PDATA) into the image, allowing you to unwind through ml64 functions.
      */
      AC_DEFINE('PHP_WINCACHE64', 1);
     } else {
      ADD_FLAG('LDFLAGS_WINCACHE', '/SAFESEH');
     }


    We will use the PHP_WINCACHE64 in precomp.h to increase the cache sizes:

    #ifdef PHP_WINCACHE64      /* under win64 all values can be enlarged to 2046 (at the same time!) */
     #define OCACHE_SIZE_MAXIMUM       2046  /* edited. was:  255 */
     #define FCACHE_SIZE_MAXIMUM       2046  /* edited. was:  255 */
     #define ZCACHE_SIZE_MAXIMUM       2046  /* edited. was:   85 */
    #endif

    Where is the preview option to see if the code-tag works as usual? ;)

    Sunday, May 27, 2012 6:14 PM