I’m still working on the Bible wiki I’ve been discussing. This latest version is having performance problems. I used the performance tool to isolate the two problematic filters, which were totally unsurprising. And I was wondering if anyone had a good way to improve them.
For this version, I wanted the books to have the contents of all their chapters transcluded. I was able to do so like this:
<% if [<currentTiddler>tag[Book]] %>
<$list filter="[tag[Chapter]] :filter[get[book]match<..currentTiddler>] +[nsort[seq]]">
<h2><$link>Chapter {{!!chapter}}</$link></h2>
<$transclude $tiddler="$:/_/bible/templates/chapter" />
</$list>
<% endif %>
which transcludes this tiddler:
<div class="chapter">
<$let book={{{ [<currentTiddler>get[book]] }}} chapter={{{ [<currentTiddler>get[chapter]] }}} >
<$list filter="[tag[Verse]] :filter[book<book>] :filter[chapter<chapter>] :map[get[para]] +[unique[]] +[nsort[]]" variable="para">
<p>
<$list filter="[tag[Verse]] :filter[book<book>] :filter[chapter<chapter>] :filter[para<para>] +[nsort[seq]]">
<span class="verse">
<sup class="verse-number"><$link>{{!!verse}}</$link></sup>
<span class="text">{{!!text}}</span>
</span>
</$list>
</p>
</$list>
</$let>
</div>
And it’s too slow.
Far too slow.
To load the book Genesis, on my moderately configured laptop it takes 10 - 12 seconds, and on my much more powerful work machine, about 10. Genesis has 50 chapters containing 1,533 verses. It’s one of the larger ones, but far from the largest (Psalms has 150 / 2461 and takes long enough that browsers warn about long-running scripts.
The performance tool made it clear that two filters were the main culprits:
-
[tag[Verse]] :filter[book<book>] :filter[chapter<chapter>] :filter[para<para>] +[nsort[seq]]
runs 239 times for a total of 8.1 seconds -
[tag[Verse]] :filter[book<book>] :filter[chapter<chapter>] :map[get[para]] +[unique[]] +[nsort[]]
runs 50 times for a total of 1.7 seconds.
(on the powerful work machine.)
I’m not sure how to interpret the performance result. Are those numbers the runtimes of the filters themselves or of the entire list widgets based on them?
In either case, does anyone have suggestions for improving these filters? (I did try combining filter steps, (e.g. [tag[Verse]] :filter[book<book>chapter<chapter>para<para>] +[nsort[seq]]
), but there was no noticeable difference.)
Or is this simply fundamental? If I try to transclude that many tiddlers, will it simply take that long to render? (I can live with that. The previous versions, without trying to render entire chapters are fast enough.)
If you want to look at the raw tiddler data it’s at
http://scott.sauyet.com/Tiddlywiki/Demo/KingJamesBible/perf1/sources/TW5-KJV.json
and it’s structured like this:
[
{"title": "Genesis", "tags": "Book", "book-seq": "1", "seq": "1"},
{"title": "Genesis 1", "tags": "Chapter [[Genesis]]", "book": "Genesis", "chapter": "1", "seq": "2"},
{"title": "Genesis 1:1", "tags": "Verse [[Genesis 1]]", "book": "Genesis", "chapter": "1",
"verse": "1", "text": "In the beginning...", "seq": "3", "para": "1"
},
{"title": "Genesis 1:2", "tags": "Verse [[Genesis 1]]", "book": "Genesis", "chapter": "1",
"verse": "2", "text": "And the earth was without form...", "seq": "4", "para": "1"},
{"title": "Genesis 1:3", "tags": "Verse [[Genesis 1]]", "book": "Genesis", "chapter": "1",
"verse": "3", "text": "And God said...", "seq": "5", "para": "2"},
{"title": "Genesis 1:4", "tags": "Verse [[Genesis 1]]", "book": "Genesis", "chapter": "1",
"verse": "4", "text": "And God saw the light...", "seq": "6", "para": "2"},
{"title": "Genesis 1:5", "tags": "Verse [[Genesis 1]]", "book": "Genesis", "chapter": "1",
"verse": "5", "text": "And God called the light Day...", "seq": "7", "para": "2"},
...
]
I am in charge of this structure, so if there is a reconfiguration that would help here, it’s certainly doable, but I would like to keep the one-tiddler-per-verse design if at all possible.