[cl-emb-devel] cl-emb speedup
Tomasz Skutnik
tomasz.skutnik at gmail.com
Mon Jun 9 22:00:16 UTC 2008
Hi.
I've started some serious development using cl-emb, and found that
it's template parsing/compilation was unbearably slow. Even simple few
character template parsing and compilation results in massive CPU and
memory burn. So I've profiled it a bit using SBCL statistical profiler
and found that it was all due to very suboptimal use of
ppcre:regex-replace-all. Long story short (well, not so long)
regex-replace-all was alway passed strings, which resulted in very
costly ppcre scanner building every time any template was parsed.
Simple memoization in expand-template-tags did the trick - scanner
object is built only on first use.
Below you will find patch that modifies cl-emb accordingly. Code
heavily borrows from Edi Weitz's Hunchentoot's scanner-for-get-param
and Tim Bradshaw's memoize library. Thanks guys. Additionally patch
exports new external function clear-expand-template-tag-hash, that
clears internal cache. It's provided because template tags expansion
depends on *emb-start-marker* and *emb-end-marker* that potentially
can be modified during runtime, to there exist possibility that
someone might need to clear scanner cache after modifying start and
end marker values.
Hope that you'll find that patch useful.
Tomasz
P.S. When next cl-emb version will be released? Will my previous patch
be incorporated?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cl-emb-0.4.3.patch
Type: text/x-diff
Size: 2859 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cl-emb-devel/attachments/20080610/5bdbcc18/attachment.patch>
More information about the cl-emb-devel
mailing list