Can SoyTofu instance by stored?

108 views
Skip to first unread message

Tom Ball

unread,
Apr 2, 2010, 12:49:50 PM4/2/10
to Closure Templates Discuss
I'm working on an App Engine app that uses Closure Templates, with
templates kept in its datastore. To render, I need to first build and
compile a SoyFileSet, which takes up most of the request time. Since
these templates don't change very often, is there any way to persist
the SoyFileSet? I don't need java.io.Serialization support, just some
way of caching the file set to a blob in the datastore. Keeping the
SoyFileSet in memory helps for multiple requests with very short
intervals, but anything over a minute or two causes a cold start of
the request.

Tom

Kai Huang

unread,
Apr 2, 2010, 5:33:56 PM4/2/10
to Closure Templates Discuss
You should only compile the SoyFileSet once into a SoyTofu instance,
and then reuse the SoyTofu instance again and again.

Tom Ball

unread,
Apr 2, 2010, 5:51:21 PM4/2/10
to closure-temp...@googlegroups.com
I'm currently caching the SoyFileSet and reusing it, but on App Engine there's no guarantee that global state from one request will be available to another (in fact, if there is more than a second between requests, odds are the shared state is gone).  If a SoyFileSet could be persisted to the App Engine datastore, then it would be accessible by all requests.  It's not the end of the world if it can't be persisted, but if not, it's worth considering as a future enhancement to better support App Engine.

Tom

--
To unsubscribe, reply using "remove me" as the subject.

Kai Huang

unread,
Apr 2, 2010, 6:20:15 PM4/2/10
to Closure Templates Discuss
I'm not familiar with App Engine in Java. What's the requirement for
persistability? Does it have to be marked as Serializable or is it
something else?

Also, my previous comment still applies. If you're going to cache
something and reuse it, then it's much better to cache the SoyTofu
object than to cache the SoyFileSet (because the former is the result
of compiling the latter).


On Apr 2, 2:51 pm, Tom Ball <tb...@google.com> wrote:
> I'm currently caching the SoyFileSet and reusing it, but on App Engine
> there's no guarantee that global state from one request will be available to
> another (in fact, if there is more than a second between requests, odds are
> the shared state is gone).  If a SoyFileSet could be persisted to the App
> Engine datastore, then it would be accessible by all requests.  It's not the
> end of the world if it can't be persisted, but if not, it's worth
> considering as a future enhancement to better support App Engine.
>
> Tom
>

Tom Ball

unread,
Apr 2, 2010, 6:56:40 PM4/2/10
to closure-temp...@googlegroups.com
Sorry, my mistake: I cache the SoyTofu object, as building a SoyFileSet takes very little time.  Rendering a small template takes ~300 milliseconds on App Engine, 3/4 of which is compiling and the rest rendering.  I'm quite happy with Soy's performance, but you can see why I'm interested in avoiding unnecessary compiling. :-)

The App Engine datastore has two relevant types: Text for char arrays, and Blob for byte arrays (both unindexed).  Higher layers like JDO take Serializable instances and convert them to byte arrays, so if SoyTofu is serializable that's an easy option.  If not, any sort of pickling scheme to byte or char arrays will work.

Tom

Kai Huang

unread,
Feb 26, 2013, 7:16:55 AM2/26/13
to closure-temp...@googlegroups.com, tb...@google.com
We've never investigated it (not enough demand for serializable and/or pickling feature to push it up the priority queue).


On Mon, Feb 18, 2013 at 7:53 AM, <romain...@wozaik.fr> wrote:
Sorry to dig up this old topic, but i have exactly the same issue than Tom when using the closure templates on App Engine.
As Tom pointed out, SoyTofu objects are not Serializable which means they can't be persisted through App engine's datastore. That's an issue because cached SoyTofu objects are all lost when the App Engine's instance is "killed" (ie. after a couple seconds of inactivity or when an error occured).
Is there any plan of making SoyTofyu objects Serializable in a future release ?

Thanks,
Romain

--
 
---
You received this message because you are subscribed to the Google Groups "Closure Templates Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Marcel Overdijk

unread,
Apr 15, 2013, 2:40:54 AM4/15/13
to Closure Templates Discuss
I'm now also considering starting a project with Closure Templates on
Google App Engine.
Typically the compilation of the templates will happen once at startup
bus as others already mentioned Google spawns and kills instance
frequently, and hence this will cause the compilations of the
templates.

As we just started evaluating Closure Templates we don't know
performance benchmarks if you have let's say 1000 templates.
Does anyone have experience with this?
Reply all
Reply to author
Forward
0 new messages