Result: Recursion here isn't terrible for performance.
Yaron kindly set "SMWResultPrinter::$maxRecursionDepth = 40" on
http://scratchpad.referata.com and I did some testing.
For some reason, the level of recursion now stops at level 20 (??).
I'm doing everything as before:
Pages higher in the tree don't hit this limit, and the template
'terminates' correctly, e.g.
I benchmarked the performance hit due to recursion by requesting each
page in the tree 20 times using curl, and parsing out the '<!-- Served
in 0.451 secs. -->' string in the returned URL. Every page request was
done with the 'action=purge' CGI setting.
The results are quite interesting, suggesting that each recursion adds
0.02 seconds to the 'serve time' on scratchpad.referata.com:
* http://oi56.tinypic.com/2gx41oy.jpg # duplicate upload
About the above plot, upper and lower triangles are +/- s.d. of the
mean load time (squares) in 20 trials. After depth 20 the behaviour
changes because the template doesn't deal well with this limit
condition and a large (null) results set is generated each time (see
the bottom of the 'Piston' page linked above). The 'solid' regression
includes just the points up to and including depth 20, the 'dashed'
regression includes the points above 20.
On 10 March 2011 13:54, Dan Bolser <dan.bolser@...> wrote:
> On 10 March 2011 12:27, Alex M. Hendler <amh.public@...> wrote:
>> Hi Dan,
>> I am not sure what "your own risk!" means, but whenever I see an
>> exclamation point in the body of a comment that is not telling you how
>> super-cool a feature is, I get a bit scared.
> I don't see that online here:
> Perhaps it's a version issue, but in any case, I take your point.
>> That said, I can foresee a problem if you set recursion depth too high
>> and someone made an error such that a page that gets returned by the
>> query is "part of" the querying page, then you just end up with loopy
>> (literally) query results.
> Yeah, of course a page shouldn't be 'part of' itself, but there is
> nothing to stop a user doing that.
>> As for performance, in my experience (still yet to be confirmed by
>> others) maxRecursionDepth > 2 may cause odd property inheritance
>> behavior if you embed or transclude pages. See
> Weird bug! Seems to be a 'feature' of the embed format only with nested queries?
>> I hope this helps point you in the right direction in terms of doing
>> what you need to do (it looks like maybe a template with known levels of
>> properties, e.g., [[-Part of::x]] passed through sufficient levels of
>> arrays/arraymaps and #if: statements would be a good bet); hopefully
> Yeah, I don't have a fixed number of levels.
>> someone else will be able to better answer your performance question.
>> As for SemanticTreeView, it looks like it must be installed with Halo,
>> but the Ontoprise folks may have a different view of that.
> Did you get this from the docs, or have you tried installing?
> Thanks for your help,
>> ----Original Message-----
>> From: Dan Bolser <dan.bolser@...>
>> To: Alex M. Hendler <amh.public@...>
>> Cc: Semantic MediaWiki Users <semediawiki-user@...>
>> Subject: Re: [Semediawiki-user] Recursive ask using format=template,
>> stuck at depth of 3?
>> Date: Thu, 10 Mar 2011 10:00:32 +0000
>> Thanks Alex.
>> I read the document you suggested:
>> but I expected to see why the settings are what they are (i.e. why so
>> low), which I don't see.
>> Do you think those 'odd' issues that you mention would to this simple
>> recursive query? Perhaps I'm being naive, but it seems to work so well
>> up to the given depth... would performance degrade super-linearly with
>> increased depth?
>> Alternatively, the Semantic TreeView extension looks promising:
>> * http://smwforum.ontoprise.com/smwforum/index.php/Help:Description_of_the_tree_parser_function
>> * http://smwforum.ontoprise.com/smwforum/index.php/Help:Description_of_the_generateTree_parser_function
>> but it isn't clear from the documentation if you need to install halo
>> or not (some places state halo as a requirement, while other
>> information suggests that it isn't) ... I guess I'll just suck it and
>> see... The biggest problem is that it expects a tree while I have a
>> DAG... Not sure what that'll do to it.
>> Any other suggested extensions for navigating relations? (Other than
>> Special:Browse of course!)
>> On 10 March 2011 07:39, Alex M. Hendler <amh.public@...> wrote:
>>> I believe the setting you're looking for is
>>> SMWResultPrinter::$maxRecursionDepth = x;
>>> Place that after your enableSemantics statement in LocalSettings.php,
>>> where x = [desired depth]-1.
>>> The reason you can't get beyond 3 levels on Referata is that (I believe)
>>> it uses the default max. depth of 2. includes/SMW_QueryPrinter.php
>>> explains the recursion settings very well.
>>> The developers can correct me if I am wrong, but I believe that
>>> recursion is intentionally not more publicly documented (i.e., outside
>>> of source code) because it can do odd and perhaps unpredictable things
>>> to semantics as well as performance if you increase it above 2.
>>> You can sometimes fool the system into recursing beyond
>>> maxRecursionDepth, but that is not something I would encourage anyone to
>>> do intentionally (it also prints out very messy results).
>>> Hope this helps,
>>> ----Original Message-----
>>> From: Dan Bolser <dan.bolser@...>
>>> To: Semantic MediaWiki Users <semediawiki-user@...>
>>> Subject: [Semediawiki-user] Recursive ask using format=template, stuck
>>> at depth of 3?
>>> Date: Wed, 9 Mar 2011 23:58:14 +0000
>>> I wrote a nice 'recursive' template to traverse a DAG here:
>>> It works by calling itself with an ask using it's given input and then
>>> the result of the ask and so on up the DAG ... (recursion always makes
>>> me a little dizzy).
>>> It works great except it only calls itself a maximum of 3 times, as
>>> evidenced by comparing the results of these two pages:
>>> * http://scratchpad.referata.com/wiki/Piston
>>> * http://scratchpad.referata.com/wiki/Engine
>>> I couldn't find the appropriate setting in the manual to bump this
>>> 'maximum recursion' value. The equivalent value for MediaWiki can be
>>> found here, but note the default setting is a whopping 40:
>>> Any tips appreciated.
>>> Colocation vs. Managed Hosting
>>> A question and answer guide to determining the best fit
>>> for your organization - today and in the future.
>>> Semediawiki-user mailing list