#92: Lazy initialization of TAL expressions in global_defines
- Proposed by
- Christian Heimes
- Proposal type
- Architecture
- Repository branch
- plip92-lazy-initialization
- State
- rejected
Definitions
lazy initialization: http://www.absoluteastronomy.com/encyclopedia/L/La/Lazy_initialization.htm
Motivation
global_defines slows down Plone because it defines lot's of vars which are used rarly
Assumptions
defer works well. Maybe it's undocumented for a reason?
Note: ZPT's engine needs a fix to make defer: work like expected. It's already fixed in the tiran-zpt-pydefer branch of zope
Proposal
Add defer: to all var definitions to use lazy initialization
Note: Because defer: in Zope 2.7.5 doesn't work as expected (broken inside python expressions, no caching after first evalution) I'm proposing a reimplementation with a new expression type "lazy:" based in defer
Deliverables
A fixed version of Zope (2.7.6/2.8?) or our own fixed implementation
Risks
defer: might break - needs testing
2-4% speed up is not worth it
we punt on this. we need to look for gains of 50% and above. We reject this.
Speed up
My bench marks are showing a general speed up of about 3-4%. I've used ab2 with 2000 requests and 2 concurrent requests. While the speed up itself isn't large the feature itself could be useful for other templates.