Performance: make renderer a singleton

Description

In our application, we can potentially have hundreds of RenderView() calls in a request. With the Renderer.cfc service being transient, this severely slows down the request. For ~4 years we've been running a modified Renderer.cfc that does a little trick to make view rendering thread safe while being a singleton (a shallow Duplicate()) when running renderViewComposite).

Pull request incoming.

Activity

Show:
Brad Wood
November 15, 2018, 9:47 PM

I thought your trick also precludes the use of the "variables" scope in your views. I don't think that's something we can get away with.

Dominic Watson
November 15, 2018, 10:37 PM

It doesn't preclude the use of variables scope, no. From the view's perspective, everything is the same - it is being included from an instance of the RendererService just as it was before. The change is to how that instance is produced - it is produced as a clone of the singleton, rather than a complete rebuild through Wirebox.

Brad Wood
November 15, 2018, 10:42 PM

Ahh, I see. You're actually duplication the CFC itself, not a scope within. This seems problematic in general that it takes so long to build a CFC and makes me wonder if there should be a way built into CFML to accomplish the same thing. That said, I'm also curious if Wirebox could make use of this method internally to have a template object for creating new instances. , and I were just discussing this yesterday I think in regards to creating a large number of the same CFC instance via Wirebox.

Luis Majano
November 16, 2018, 3:39 AM

I am curious of using struct copy because it only copies the this scope. What about all private scoped variables and injections?

Assignee

Luis Majano

Reporter

Dominic Watson

Labels

None

Fix versions

Priority

Major
Configure