Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2533 invoked by uid 1010); 26 Nov 2003 19:42:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 2507 invoked from network); 26 Nov 2003 19:42:20 -0000 Received: from unknown (HELO tjw.org) (208.47.40.253) by pb1.pair.com with SMTP; 26 Nov 2003 19:42:20 -0000 Received: from tjw.org (tjw@localhost [127.0.0.1]) by tjw.org (8.12.10/8.12.9) with ESMTP id hAQJflcJ030341; Wed, 26 Nov 2003 13:41:47 -0600 Received: (from tjw@localhost) by tjw.org (8.12.10/8.12.8/Submit) id hAQJfkFv030340; Wed, 26 Nov 2003 13:41:46 -0600 X-Authentication-Warning: tjw.org: tjw set sender to tjw@webteam.net using -f Date: Wed, 26 Nov 2003 13:41:46 -0600 To: internals@lists.php.net Message-ID: <20031126194145.GN15129@morbo.tjw.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: PHP4 ext/java threading From: tjw@webteam.net ("Tony J. White") The PHP4 java extension has problems when running inside a threaded webserver. http://bugs.php.net/bug.php?id=16690 This is due to the fact that the JavaVM pointer was a Thread Safe Resorce Manager Global (TSRMG). This pointer is meant to be shared by all threads, and so should be a real global. The other java TSRM globals are correct as each thread will get it's own JNIEnv from the JavaVM. Credit goes to Momchil Georgiev for figuring this out. My CVS account doesn't appear to have write access, so here are where the patch and new java.c can be found: http://tjw.org/php_java/java.c.thread_patch http://tjw.org/php_java/java.c I tested this on Apache 2.0 (with MPM worker) on Linux only. It should be noted that running the PHP Java extension from inside of a threaded webserver gives a HUGE performance benefit. This is becasuse in non-threaded webservers (e.g. Apache 1.3) each child process spawns its own completely seperate JVM instead of just having one shared JVM . In my simple testing running siege to compare Apache 1.3 and 2.0 (with threads), the threaded webserver produced a 0.3 load average while apache 1.3 produced a 30.0 load average. I was running 'siege -n 30 -i' on Example 1 from the PHP manual page for the java extenstion. -Tony