[dokuwiki] Re: Performance issues

  • From: Andreas Gohr <andi@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 12 Mar 2006 21:41:07 +0100

On Sun, 12 Mar 2006 19:55:26 +0100
Yann <yann.hamon@xxxxxxxxx> wrote:

> // common.php, line 943
> function getRevisions($id){
> 
> 
> There is the :
> 
>     while (($file = readdir($dh)) !== false) {
>       if (is_dir($revd.'/'.$file)) continue;
>       if
>       (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){
>         $revs[]=$match[1];
>       }
>     }
> 
> part, that collects all revisions of a given file.
> 
> /htdocs/data/attic$ ls -l | wc -l
> 2766
> 
> That part of the code is doing the preg_match 2800 time if I want the
> list of revisions of a file that is in the / of my wiki.

Hmm we should make some tests... Maybe it is more efficient to first
read the whole directory (creating an array of 2766 items) and then
doing a preg_grep on it. Another alternative could be the glob function
which is unfortunately only available from PHP 4.3

BTW. I recommend to use a cron job to clean the attic from time to
time...

>   - display by default only the last $conf['recent'] modifications,
>   and
> another page to see all the modifications...
>   - Replace the getRevisions and the loop calling getRevisionInfo by a
> single function, well, getLastRevisionsInfo (?), which would open
> changes.log a single time, and instead of grepping n times the whole
> changes.log, grep the lines concerning the page asked all at once.

Makes both sense. 

> What do you think? I can try implement these ideas if you think the
> idea is ok.

Would be great.

Andi
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: