-
2010-02-16
keylevel
If a page contains a large number of headings then the PHP processing time for the page (e.g. when saved) increases nearly exponentially with the number of headings.
A crude test using a number of headings reveals:
Headings | Time (s)
---------+---------
256 | 4
512 | 24
1024 | 185
This does not happen for pages containing the same number of text paragraphs or <code> blocks, so it does seem to be related to the processing of headings.
While this may not generally cause problems, it does if long pages are produced - e.g. when the include plugin is used to pull lots of pages together to allow the export of a complete document (e.g. OpenOffice).
-
2010-02-16
keylevel
Using the htag plugin to create the headings gives the same results.
-
2010-02-16
andi
Can you provide a test script?
Are we talking about headlines here? Or is this related to $conf['useheading']?
What did your test headlines look like? If they where all the same text, then each headline takes one loop more to find a free ID to assign. Please try with more real life like data.
Additionally, a page with >100 headlines is far beyond what any wiki page should have.
-
2010-02-16
keylevel
These are headlines of the form
==== Headline ====
My test data was not representative of a real document as all the headline texts were the same. However, I created this after a real document was exhibiting similar behaviour as I added more content.
I actually use Dokuwiki to develop various books. The wiki structure allows many people to contribute and then pull everything together in to a single page so that it can be exported using the odt plugin. This seemed like a good use for a document wiki ;-)
My latest project creates a document with lots of sections (and therefore lots of headlines). Where are the ID assigned? Is it in the sectionID() call from the xhtml renderer?
-
2010-02-16
keylevel
It seems as if about 25% of the time is taken up with the ID calculation. I'll have a look and see if I can find a faster solution, even if it's only suitable for my needs (happy to share, if appropriate!).
Which other bits of dokuwiki are involved in header processing? The handler code doesn't look as if it should use lots of CPU time.
-
2010-02-17
keylevel
The free ID assignment can be made faster by changing sectionID() so that the line
$num = '';
becomes
$num = mt_rand();
This ensures that the chance of an initial clash is low. As you point out, any page with many repeated headings ("Example", in my case) is going to suffer due to the linear search that's currently used to generate the IDs.
-
2010-02-18
andi
Assigning a random ID defeats the purpose of section headers. When the section header gets a different ID on each rendering you can no longer reliably link to it.
-
2010-02-19
keylevel
Oh yes - I didn't consider linking from other pages. Sorry about that. How about this instead?
if ( is_array ( $check ) ) {
// make sure tiles are unique
if ( !array_key_exists ( $title, $check ) )
{
$check [ $title ] = 0;
} else {
$title .= ++ $check [ $title ];
}
}
-
2010-02-28
andi
That works. Applied your suggestion.