[pmwiki-users] Blog proposal

Patrick R. Michaud pmichaud at pobox.com
Fri Dec 16 12:56:03 CST 2005


On Fri, Dec 16, 2005 at 11:50:59AM -0500, Martin Fick wrote:
> 
>   1) Cache the directory reads so that they do not get
>      reread on consecutive pagelists, (they will never
>      change in a way that we would care during page display
>      would they)?  I know, this will raise the memory
>      consumption.   

Yes, and I'm very concerned about memory consumption at the moment.
I really wish PHP provided more functions that would allow a script
to monitor its memory use and possibly adjust its behavior accordingly.
(Yes, PHP has a get_memory_usage() function, but it's only available
after PHP 4.3.2, and then only if memory_limits are enabled.)

Anyway, we could make caching an option.  It's also possible to
derive a PageStore class that caches the ls() results and use
that instead.

>   For both of these it helps to split this into two separate
> non nested main loops, one to read the files and one to
> check for globbing (pattern matching).  

I think I'll probably hybridize this, so that I use preg_grep
on all of the entries in a single directory (for those who have
wiki.d/ segregated into per-group directories).  Or perhaps 
use preg_grep on every hundred entries or so, instead of 
preg_match on every entry.  That would get a significant
speedup while also preventing us from eating up a huge chunk
of memory with page names just to throw them away again.  :-)

Lastly, I'm thinking that the match against a valid page name
pattern ought to go at the end of the pattern list instead of 
the beginning, since it'll be the least restrictive of any patterns 
passed in to the ls() function.

Pm




More information about the pmwiki-users mailing list