ACM Modules

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
davidyin
Registered User
Posts: 4
Joined: Wed Jun 10, 2009 2:13 am

Re: ACM Modules

Post by davidyin »

ToonArmy wrote:
naderman wrote:Chris started an article on caching: http://wiki.phpbb.com/Cache
Chris also forgot to press submit :roll:
Anyone knows which version of acm_xcache.php works with phpBB 3.0.5?
User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: ACM Modules

Post by bantu »

davidyin wrote:Anyone knows which version of acm_xcache.php works with phpBB 3.0.5?
The package php5-xcache (1.2.2-3) in Ubuntu/Debian works out of the box for me. All I had to do was edit the xcache ini file. :)
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: ACM Modules

Post by ToonArmy »

davidyin wrote:
ToonArmy wrote:
naderman wrote:Chris started an article on caching: http://wiki.phpbb.com/Cache
Chris also forgot to press submit :roll:
Anyone knows which version of acm_xcache.php works with phpBB 3.0.5?
The modules in SVN should work fine with 3.0.5, you will need acm_xcache.php and acm_memory.php.
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image
TerryE
Registered User
Posts: 95
Joined: Sat May 23, 2009 12:24 am
Contact:

Re: ACM Modules

Post by TerryE »

Chris, I've started dumping my tuning notes in my wiki user space: Terrye/A phpBB Use Case Discussion, where I've identified and discussed 3 main infrastructure use cases for the phpBB installation. You might want to track this and the other pages that I'll dump there. At the moment this is just working thoughts, but I want to turn them into an installation / tuning guide eventually. What is quite clear to me is that the acm_files module should really be optimised for the "shared web hosting" scenario and the PHP accelerator versions for the Virtual and Dedicated Hosting scenarios. Anyway have a scan.

I want to finish my tuning analysis, but I already have some outline suggestions that will help with performance improvement that you might consider worthwhile and slipstream into 3.0.6. I just want to double check them first to avoid making a prat of myself and wasting your time. Terry.
Last edited by TerryE on Tue Jun 16, 2009 1:16 am, edited 1 time in total.
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: ACM Modules

Post by ToonArmy »

TerryE wrote:Chris, I've started dumping my tuning notes in my wiki user space: Terrye/A phpBB Use Case Discussion, where I've identified and discussed 3 main infrastructure use cases for the phpBB installation. You might want to track this and the other pages that I'll dump there. At the moment this is just working thoughts, but I want to turn them into an installation / tuning guide eventually. What is quite clear to me is that the acm_files module should really be optimised for the "shared web hosting" scenario and the PHP accelerator versions for the Virtual and Dedicated Hosting scenarios. Anyway have a scan.

I want to finish my tuning analysis, but I already have some outline suggesting that will help with performance improvement that you might consider worthwhile and slipstream into 3.0.6. I just want to double check them first to avoid making a prat of myself and wasting your time. Terry.
Terry, we've already been reading it. ;) I certainly agree that the file ACM module should be tuned for the most constrained of environments, any board with decent level of activity really should be using it at all. I'd be most interested to here of your suggestions in good time. :)
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image
TerryE
Registered User
Posts: 95
Joined: Sat May 23, 2009 12:24 am
Contact:

Re: ACM Modules

Post by TerryE »

One example is where you've added extra tracking variables <prefix>sql_<tablename> which contains the array
  • '<md5hash>' => true
to help with coherency and pruning when you change the base table. Whenever a new query is cached, the corresponding <prefix>sql_<tablename> is read, the extra element is added and it is then saved back to the cache. The <prefix>sql_<md5hash>> records themselves have a TTL and thus self destruct when expired, but <prefix>sql_<tablename> is not culled and just grows. The sessions one is particularly bad and on our VBox system grows a couple of 2Mb per day. (This isn't an issue for us because we already bounce Apache in the early hours for backup.)

I suggest that you store the array '<md5hash>' => ttl instead and run over it with an array_filter() to cull expired entries whenever you load this and thus keep it from growing. You can also do the trick of gating this prune by a if (rand(1,20) == 1) clause so that it is only done on 5% of the updates, thus minimising the overhead.
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: ACM Modules

Post by ToonArmy »

Something like this:

Code: Select all

Index: includes/acm/acm_memory.php
===================================================================
--- includes/acm/acm_memory.php	(revision 9588)
+++ includes/acm/acm_memory.php	(working copy)
@@ -281,6 +281,7 @@
 		// Remove extra spaces and tabs
 		$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
 		$hash = md5($query);
+		$time = time();
 
 		// determine which tables this query belongs to
 		// Some queries use backticks, namely the get_database_size() query
@@ -308,8 +309,12 @@
 			{
 				$temp = array();
 			}
+			else
+			{
+				$temp = array_filter($temp, array('acm_memory', '_expiration_filter'));
+			}
 
-			$temp[$hash] = true;
+			$temp[$hash] = $time + $ttl;
 
 			// This must never expire
 			$this->_write('sql_' . $table_name, $temp, 0);
@@ -331,6 +336,11 @@
 		$query_result = $query_id;
 	}
 
+	function _expiration_filter($expires)
+	{
+		return (time() < $expires) ? true : false;
+	}
+
 	/**
 	* Ceck if a given sql query exist in cache
 	*/
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image
davidyin
Registered User
Posts: 4
Joined: Wed Jun 10, 2009 2:13 am

Re: ACM Modules

Post by davidyin »

ToonArmy wrote:
davidyin wrote:
ToonArmy wrote:
naderman wrote:Chris started an article on caching: http://wiki.phpbb.com/Cache
Chris also forgot to press submit :roll:
Anyone knows which version of acm_xcache.php works with phpBB 3.0.5?
The modules in SVN should work fine with 3.0.5, you will need acm_xcache.php and acm_memory.php.

Thank you very much.
TerryE
Registered User
Posts: 95
Joined: Sat May 23, 2009 12:24 am
Contact:

Re: ACM Modules

Post by TerryE »

ToonArmy wrote:

Code: Select all

+            else
+            {
+                $temp = array_filter($temp, array('acm_memory', '_expiration_filter'));
+            } 
PHP is not the strongest of my languages, but isn't _expiration_filter a class method? In which case shouldn't this be coded as follows?

Code: Select all

+                $temp = array_filter($temp, array($this, '_expiration_filter')); 
The PHP spec is a bit woolly in this area. One of us would have to run a test to find out. That aside: 8-)
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: ACM Modules

Post by naderman »

Yes, that looks correct. I guess Chris would have noticed once he tried running his code ;-)
Post Reply