speed improvement idea: path caching

From: Date: Fri, 20 Jun 2003 21:07:11 +0000
Subject: speed improvement idea: path caching
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1635@lists.php.net to get a copy of this message
I'd like to throw out a speed improvement idea and get feedback. One thing Smarty does is assembles the paths to plugins and compiled files. These paths should presumably always be the same, so why not "cache" them for re-use instead of re-assembling them? The difficulty will be in implementation. We could have a $this->_file_paths() array which keeps track of plugin paths, compiled file paths (and others?). This file is loaded upon an invocation to find the path to a file or assemble one, and looked for here first. You can think of it as a cache, although it might be more appropriate to put into the compile_dir since it will be a compiled php file with an array of data that just gets included. The tricky part is to figure out how to prune it or update it. I think updating should be obvious, you don't. Anytime you move a plugin file or resource, you should take care to wipe the compile_dir clean anyways. As for pruning, this I'm a bit hazy on. If we store the paths to all compiled resources, this array could get HUGE, which would eventually have a negative impact. Maybe just keep the most-often used resources? So, set a limit to the number of resource paths that are "cached", and if that limit is reached, start removing the oldest entries? Anyways, this would need some thinking/testing, because they're may be a fine line when the benefits of path caching would outweigh calculating the path in the first place. Thoughts? Monte

« previous php.smarty.dev (#1635) next »