[pmwiki-users] Speed tips?

Kathryn Andersen kat_lists at katspace.homelinux.org
Fri Feb 16 23:58:31 CST 2007


On Fri, Feb 16, 2007 at 08:02:24AM -0600, Patrick R. Michaud wrote:
> On Sat, Feb 17, 2007 at 12:12:13AM +1100, Kathryn Andersen wrote:
> > Are there some tips for speeding things up?
> > If you say "don't use pagelists", then suggest something to use instead,
> > please?
> 
> If you're running 2.2.0-beta30 or later, you could try enabling
> the experimental pagelist cache (and thereby test it :-).  
> Simply create a directory for PmWiki to store the cache files
> (I'm currently using "work.d/" in the pmwiki dir), give it
> write permissions, and then set
> 
>     $PageListCacheDir = "work.d";

Ah.  I couldn't see any information about how to *activate* the pagelist
cache; thanks!
 
> Also, it would probably be very helpful (to me and possibly others)
> if you could post the (:pagelist:) commands you're using.  We might
> see some obvious speedups, or I might be able to optimize the
> (:pagelist:) directive a bit.  (Or perhaps I can just look the markups
> on the site directly.)

Here's some examples...

(:pagelist group={$Group} name=-{$Group},-{$DefaultName},-Author-* list=normal
order=title idprefix=auth fmt=#titleAtoc:)
----
(:pagelist group={$Group} name=-{$Group},-{$DefaultName},-Author-* list=normal
order=title idprefix=auth fmt=#titleA:)


The formats are as follows: (they take advantage of a page-variable
called $TitleA, which takes the first letter of the title)

fmt=#titleA

Title, grouped by alpha
Pass in idprefix= to determine the prefix for the anchors.

[[#titleA]]
(:if ! equal {=$TitleA} {<$TitleA}:)
!![[#{$$idprefix}{=$TitleA}]] {=$TitleA}
(:ifend:)
* [[{=$FullName}|{=$Title}]]
[[#titleAend]]

fmt=#titleAtoc

ToC links for #summaryA and #titleA
Pass in idprefix= to determine the prefix for the anchors.

[[#titleAtoc]]
(:if ( ! equal {=$TitleA} {>$TitleA} and ! equal {>$Group} ) :)
[[#{$$idprefix}{=$TitleA}|{=$TitleA}]] | \
(:if ( ! equal {=$TitleA} {>$TitleA} and equal {>$Group} ) :)
[[#{$$idprefix}{=$TitleA}|{=$TitleA}]]

(:ifend:)
[[#titleAtocend]]


Here's an example of a GroupFooter which does some pagelisting:

(:if name -{*$Group}*:)
(:pagelist list=stories link={*$Group}.{*$Name} order=title idprefix=id
fmt=#summaryA:)
(:div1 class="bottom":)
>>trail<<
(:pagelist group={*$Group} name=-{*$Group}* list=content order=title
fmt=#grouptrail:)
>><<
(:div1end:)
(:ifend:)

Here are the #summaryA and #grouptrail formats; the #summaryA format
makes use of a lot of page-text variables.
 
fmt=#summaryA

Title, (Universe, Genre), Author, Size, Date, Description, grouped by
alpha. Pass in idprefix= to determine the prefix for the anchors.

[[#summaryA]]
(:if ! equal {=$TitleA} {<$TitleA}:)
!![[#{$$idprefix}{=$TitleA}]] {=$TitleA}
(:ifend:)
*\
(:if !equal "{=$:Series}" "":)'''{=$:Series}''' \
(:if !equal "{=$:SeriesOrder}" "":)'''({=$:SeriesOrder})''' (:ifend:) \
[[{=$FullName}|{=$:Title}]] \
(:if !equal "{=$:Universe}" "":)({=$:Universe})(:ifend:) \
(:if !equal "{=$:Genre}" "":)({=$:Genre})(:ifend:) \
by {=$:Author} ({=$:Size}) [{=$Date}]\\
'-{=$Description}-'
[[#summaryAend]]

fmt=#grouptrail

Dynamic group trail of form <<prev.Name | Group | next.Name>> (based on
Cookbook:DynamicTrails)

[[#grouptrail]]
(:if equal "{*$FullName}" "{=$FullName}" :)<<[[{<$FullName}|{<$Title}]] | [[{*$Group}|{*$GroupTitlespaced}]] | [[{>$FullName}|{>$Title}]]>>(:ifend:)
[[#grouptrailend]]

> > - in the sidebar to list all the groups
> 
> I've been thinking we may need an option to sidebar that says
> "just return the homepages for each group".  That could speed
> things up.  However, you later indicate that you have built
> a trail for this, so that should speed things up a fair bit.

Yeah, I didn't think that new groups would be created all that
frequently, so I didn't begrudge having to add them by hand if that
would speed things up.
 
> > - on most pages to have a "grouptrail" (which is a pseudo Trail which
> >   links to the next and previous pages in that group)
> 
> If the group is large, this could be somewhat slow to render.

Yep.
 
> > - in some groups, most of the pages are just pagelists (which use
> >   link={*$FullName} like the Category group does)
> 
> As long as pageindexes are working, this should be relatively quick.

So it's likely that it's just a problem that there are lots of pages?
 
> > - I have quite a few custom pagelist templates (and I make use of
> >   page-text variables quite heavily)
> 
> This is likely part of what is slowing things down -- if the
> (:pagelist:) command is sending a lot of pages to the template,
> then all of the pages have to be read for the pagetext variables.

Ah.
 
> > - I have a few custom $SearchPatterns to help with the pagelists
> 
> This generally helps speed things up.

I use the following to list only group home pages: (not that I need it
as much now that I've got Main.GroupList)

$SearchPatterns['group'][] = '/([-\w]+)\.\1$|\.' . "$DefaultName" . '$/';

I use the following to list only "story" pages; the major part of the
site is in a large personal private fiction archive (everything from
favourite fanfic, books from the Baen Free Library, stuff from Project
Gutenberg, and e-books I've bought).  Story-pages are "normal" pages in
the Fiction-Stories-* groups.

$SearchPatterns['stories']['storygroup'] = '/^Fiction-Stories-/';
$SearchPatterns['stories']['nonhome'] = '!\.Fiction-Stories-!';
$SearchPatterns['stories']['nonhome2'] = '!\.' . $DefaultName . '!';
$SearchPatterns['stories']['nonprefix'] = '!\.Stories-!';
$SearchPatterns['stories']['recent'] = '!\.(All)?Recent(Changes|Uploads)$!';
$SearchPatterns['stories']['group'] = '!\.Group(Print)?(Header|Footer|Attributes)$!';
$SearchPatterns['stories']['side'] = '!\.(Side|Menu)Bar$!';
$SearchPatterns['stories']['breadcrumb'] = '!\.BreadCrumb!';
$SearchPatterns['stories']['template'] = '!Template$!';
$SearchPatterns['stories']['comment'] = '!-Comment(s)?$!';

> Yes, the documentation is all wrong.  The way I've been producing a
> stopwatch lately is:
> 
>     $HTMLFooterFmt['stopwatch'] = 'function:StopWatchHTML 1';
 
> This will add stopwatch information at the bottom of the page.

Ah, thanks!
 
> > Would it be faster if:
> > - I stopped using pagelist templates and wrote formatting functions in
> >   PHP?  (as I gather was used before pagelist templates were introduced)
> 
> Pagelist templates can indeed be very slow... if only because the
> resulting markup can become quite huge.   A custom PHP-based
> formatting function can be far faster.  However, once you get
> the stopwatch running, we can see if it's the template that
> is eating up all of the time (MarkupToHTML).

Hmmm, could well be...
 
> > - I wrote sorting functions instead of sorting by page-text-variables?
> 
> Depending on the size of the pagelists being generated, sorting
> by page-text-variables ought to be about as fast as any other
> sort we can come up with.  
 
Okay.

Kathryn Andersen
-- 
 _--_|\     | Kathryn Andersen	<http://www.katspace.com>
/      \    | 
\_.--.*/    | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
      v     | 
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha!  |	-> Earth -> Sol -> Milky Way Galaxy -> Universe



More information about the pmwiki-users mailing list