Closed antoniogamiz closed 4 years ago
Thank you very much for opening this issue.
I've pushed some changes in version 1.2.0 which may help, caching parsed templates which were not being cached before. If you are re-using the same template files over and over (as I suspect you are), this should be much faster now. Just make sure that you keep a single Template::Mustache instance, as the cache is stored as a member and not shared between instances.
my $stache = Template::Mustache.new: from<path/to/templates>;
for @documentables -> $doc {
# This will look up the 'document.mustache' template in the cache, and
# any of the templates it references
$stache.render: '{{< document }}', { 'title' => $doc.title, 'body' => $doc.body };
}
That being said, I am sure the Grammar for Template::Mustache is not efficient. It probably backtracks a lot more than it should. I have some ideas on fixing that, but haven't gotten to them. Hopefully the caching will be sufficient for your needs now. Please let me know how it goes!
Tim
Where could I see those changes? I don't see new commits in this repo. Thanks for the fast reply!
Yes, it is here on this repo (now renamed to raku-Template-Mustache
on Github). They were committed a few days ago now: https://github.com/softmoth/raku-Template-Mustache/commit/4811aadd403403c182245674f1d8b044594f075a
The 1.2.0 release on CPAN has it (current version is 1.2.1, with some logging features refactored).
Oh here is why I have not seen the speed changes:
https://github.com/Raku/Pod-To-HTML/blob/00d1130391a38d5a0b1b13a15738bfa889726c54/lib/Pod/To/HTML.pm#L273-L280 (preview code is not working for some reason) I suppose literals are not being cached, or cannot be cached?
Mm, after taking a look at the code it looks like that literals
are indeed cached.
Thank you, Antonio.
Yes, explicitly marked :literal
s were already being cached, after finanalyst added caching. Recent changes expanded caching to all templates, literals and non-literals alike. The :literal
hack you pointed to is no longer needed (we can just point :from
at the templates directory and let Template::Mustache
find the partials); but having it in there won't slow things down noticeably, I guess.
I'm curious what the speed difference is with the updated to Pod-To-HTML. I honestly haven't put much effort into benchmarking and optimizing. I would like to do that eventually, but have other things that are a higher priority. If the speed with caching is still a major hurdle for you, I can change my priorities.
I think after these changes (https://github.com/Raku/Documentable/issues/117) it will be enough :-). As always, thanks for your help!
Hi, first of all, thanks for your work @softmoth. After updating
documentable
to use Mustache templates, I have noticed a huge increase in the execution time ofdocumentable
. In the previous versions (without templates), generate the documentation would take no more than 6-10 minutes. After using templates, this is the time it takes:Around 30 minutes. This problem was also found by @finanalyst when he tried to remake the
Pod::To::HTML
module.I don't know if this is the usual time any other implementation of
Mustache
(in a different language) would take to do the same. Any ideas on how to solve this?