9 Jun 23:56
cl-emb speedup
From: Tomasz Skutnik <tomasz.skutnik@...>
Subject: cl-emb speedup
Newsgroups: gmane.lisp.cl-emb.devel
Date: 2008-06-09 22:00:16 GMT
Subject: cl-emb speedup
Newsgroups: gmane.lisp.cl-emb.devel
Date: 2008-06-09 22:00:16 GMT
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?(Continue reading)
RSS Feed