Rules of thumb for optimizing TW code and content

146 views
Skip to first unread message

Mat

unread,
Jun 10, 2016, 8:14:51 PM6/10/16
to TiddlyWikiDev
Are there any useful rules of thumb for optimization when using native TW components? Perhaps also concerning html+css.

For example;
  • In a filter, does it make significant difference to put the cruder operators+operands first/leftmost? 
  • And particularly, does a filter with one compound expression ever stop mid filter e.g if the expression that far results in empty and the rest of the expression operators need input to be meaningfully run? I think this would require a kind of meta evaluation first to decide what type of an expression the argument is.
  • Does a ViewTemplate tax the system more than the average tiddler considering how viewtemplates are transcluded into all other tiddlers? 
  • Or does a viewtemplate only cost when a tiddler is actually open (and in viewmode)?
  • ...and does the viewtemplate only cost in that particular tiddler or does it cost globally? For example, if I open a stylesheet that is NOT tagged $:/tags/Stylesheet, then these styles are active globally for as long as the tiddler is open. A macro on the other hand, has to be called (and I must assume it doesn't cost anything more than plain text before that).
  • Do local style blocks cost differently than dedicated stylesheet tiddlers?
  • Are wikitext solutions different in cost from their eventual widget/html/css counterparts? (e.g curly bracket transclusion vs transcludewidget, pipe characters vs html table, @@ vs wrapping in a span to style...)
  • Do the cost for keeping (plain text) tiddlers open increase linearly or perhaps exponentially?
  • Tiddlers in view mode vs in edit mode? For example, why do things slow down substantially when the vanilla stylesheet is in edit mode? Is it the mere size of it? Does an editview tiddler affect the actual tiddler content which slows rendering?
  • And apropos (something like) the vanilla stylesheet - if it were split up into multiple tiddlers, e.g one tiddler per style definition, how would that affect wiki performance? I keep hearing about TWs with X thousand tiddlers and "it works fine", so is tiddler length a sensitive issue?
  • What tiddlers or types of tiddlers, if any, or what type of content, is constantly taxing the system? Pagetemplate tiddlers? Macros? Anything tagged X?
  • Are there ways to ensure lazy loading of stuff? For example, it is known that long lists in the sidebar tabs can cause slowness (...or is it only for some of those tabs?) - but to prevent it, you can simply switch tab to a short list... so does that mean that content in non-active tabs are "turned off"?
  • ...same question for reveal widgets; Is their content inactive when it is not revealed? Or does it perhaps keep on running until tiddler is closed? or even after that?

I'm guessing the common answer to all the above example(!) questions is "it depends on [specifics]" - but, I'm asking for general rules of thumb.

Thank you!


<:-)

Jeremy Ruston

unread,
Jun 11, 2016, 4:04:30 AM6/11/16
to TiddlyWikiDev
Hi Mat

A great list of questions, thanks for sharing.

I'll give some response to each, but overall I'd strongly urge you to *measure* things yourself. TiddlyWiki is a sufficiently complex system that its emergent behaviour is sometimes hard to predict, even for me. The community regularly demonstrates this by developing techniques that I haven't anticipated, and have taken me by surprise (the good kind!).

  • In a filter, does it make significant difference to put the cruder operators+operands first/leftmost? 
Each operator will run faster the fewer items that are being considered, so you should indeed put the operators first that select fewer items. 
  • And particularly, does a filter with one compound expression ever stop mid filter e.g if the expression that far results in empty and the rest of the expression operators need input to be meaningfully run? I think this would require a kind of meta evaluation first to decide what type of an expression the argument is.
No, an empty intermediate result will still be passed to the remaining operators in the filter expression. I'd be surprised if such an optimisation had much impact: most filter operators perform well with an empty item list.
  • Does a ViewTemplate tax the system more than the average tiddler considering how viewtemplates are transcluded into all other tiddlers? 
Yes; put more clearly: the view template is highly critical to performance since it impacts each tiddler displayed in the story river.
  • Or does a viewtemplate only cost when a tiddler is actually open (and in viewmode)?
Not exactly. Conversely, the view template has no impact on performance when no tiddlers are displayed.
 
  • ...and does the viewtemplate only cost in that particular tiddler or does it cost globally? For example, if I open a stylesheet that is NOT tagged $:/tags/Stylesheet, then these styles are active globally for as long as the tiddler is open. A macro on the other hand, has to be called (and I must assume it doesn't cost anything more than plain text before that).
The view template impacts performance in each tiddler displayed in the story river. There is an impact to global macros that are not invoked, because the macro definition still needs to be processed.
  • Do local style blocks cost differently than dedicated stylesheet tiddlers?
It depends. A local style block in the view template will have an impact for each tiddler in the story river.
  • Are wikitext solutions different in cost from their eventual widget/html/css counterparts? (e.g curly bracket transclusion vs transcludewidget, pipe characters vs html table, @@ vs wrapping in a span to style...)
I wouldn't have thought it would make much difference: both curly bracket transclusion and the transclude widget need parsing, and the result of the parsing is the same.
 
  • Do the cost for keeping (plain text) tiddlers open increase linearly or perhaps exponentially?
I would expact it to be linear.
  • Tiddlers in view mode vs in edit mode? For example, why do things slow down substantially when the vanilla stylesheet is in edit mode? Is it the mere size of it? Does an editview tiddler affect the actual tiddler content which slows rendering?
The edit template is much more complex than the view template (particularly when using the new editor).
  • And apropos (something like) the vanilla stylesheet - if it were split up into multiple tiddlers, e.g one tiddler per style definition, how would that affect wiki performance? I keep hearing about TWs with X thousand tiddlers and "it works fine", so is tiddler length a sensitive issue?
In the case of stylesheets I wouldn't expect one big tiddler to have a significantly different performance than lots of little ones. Tiddler length is only a sensitive issue for certain operations, like rendering and searching.
  • What tiddlers or types of tiddlers, if any, or what type of content, is constantly taxing the system? Pagetemplate tiddlers? Macros? Anything tagged X?
I think that's the wrong question. There is just one widget tree, generated from the page template.
 
  • Are there ways to ensure lazy loading of stuff? For example, it is known that long lists in the sidebar tabs can cause slowness (...or is it only for some of those tabs?) - but to prevent it, you can simply switch tab to a short list... so does that mean that content in non-active tabs are "turned off"?
Please don't use the term "lazy loading" here; it already has a precise, specific meaning within tiddlywiki.

By default, the reveal widget (which is used in the tabs macro) completely removes hidden content from the widget tree. That speeds the refresh cycle, but means that the entire content must be re-rendered when the content is revealed. A "retain" attribute is supported which causes the reveal widget to maintain it's content even when hidden, so that it can be revealed more efficiently.

  • ...same question for reveal widgets; Is their content inactive when it is not revealed? Or does it perhaps keep on running until tiddler is closed? or even after that?
As above: the reveal widget is the mechanism by which tabs hide and show their content, so it's the same as the previous question.
 
Hope that helps, feel free to ask if anything isn't clear,

Best wishes

Jeremy

I'm guessing the common answer to all the above example(!) questions is "it depends on [specifics]" - but, I'm asking for general rules of thumb.

Thank you!


<:-)

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/c9ab977d-00ac-4c8b-9dd6-1e91666b4a3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Mat

unread,
Jun 11, 2016, 12:40:56 PM6/11/16
to TiddlyWikiDev, jeremy...@gmail.com
It'll take me some time to process this info but just want to say thank you for your answers Jeremy!

If anyone has thoughts on "general rules-of-thumb" or strategies please feel free to post. (Is this what programmers call "patterns" perhaps?)

<:-)
Reply all
Reply to author
Forward
0 new messages