spring-projects / spring-webflow

Spring Web Flow
https://spring.io/projects/spring-webflow
Apache License 2.0
326 stars 231 forks source link

Serialization improvements [SWF-1624] #791

Closed spring-operator closed 10 years ago

spring-operator commented 10 years ago

Karl Trumstedt opened SWF-1624 and commented

When starting a flow, the statements in on-start (and everything up until we come to a view state) are executed. This then gets serialized and a redirect is made with the flowExecutionKey. This request deserialized everything and then serializes it all again when the view has been rendered. Does it really have to work this way? It seems like a lot of wasted performance. Would be great if the execution of on-start etc could be delayed until the redirected request to avoid unnecessary serialization. Maybe use the FlowStatus variable to know if the on-start should be executed in the following redirect request?

Also, I wonder, does the flow state needs to be saved seperatly for each snapshot? Shouldn't it be saved globally for the flow, so it's shared between snapshots?


No further details from SWF-1624

spring-operator commented 10 years ago

Rossen Stoyanchev commented

When starting a flow, the statements in on-start (and everything up until we come to a view state) are executed. This then gets serialized and a redirect is made with the flowExecutionKey. This request deserialized everything and then serializes it all again when the view has been rendered. Does it really have to work this way? It seems like a lot of wasted performance. Would be great if the execution of on-start etc could be delayed until the redirected request to avoid unnecessary serialization.

I'm not sure if your question is about the first redirect or more about redirect before rendering in general. As you probably know whether to redirect before rendering can be configured. I don't think it's necessary to split this into a more fine-grained choice of whether to redirect before the 1st rendering.

Also, I wonder, does the flow state needs to be saved seperatly for each snapshot?

This is configurable. See the docs on max-execution-snapshots.

spring-operator commented 10 years ago

Karl Trumstedt commented

Maybe I didn't explain clearly enough. I'm not talking about wether or not a redirect should be made when starting a flow. I guess it's quite necessary to get the es query parameter on the URL. When you start a flow, two requests are made. First myFlow.xhtml which is a 302 and then myFlow.xhtml?e1s1 or something like that. Everything in my on-start and on-entry tags in the flow gets executed AND SERIALIZED in the first request. Then it immediatly gets deserialized in the second request to render the view. This is just a waste of performance? If you have a big page which loads lots of data, several hundreds of ms are wasted. Instead, maybe the flow should delay executing on-start and on-entry to the second request (and changing flow status so it doesn't gets reexecuted if you refresh).

RE- max-execution-snapshots. If I have max-execution-snapshots to 5, doesn't e1s1, s2, s3, s4 etc all save and serialize everything in the flowstate seperatly? This seems to be a waste of storage when you could reuse it over all snapshot views? that view-state is serialized and saved seperatly for each snapshot makes sense, but not flowstate?

spring-operator commented 10 years ago

Rossen Stoyanchev commented

Maybe I didn't explain clearly enough. I'm not talking about wether or not a redirect should be made when starting a flow.

That is exactly the reason for serialization and it is fundamentally how Web Flow works. It captures all state in the form of a continuation that is saved between requests. This behavior is configurable but generally speaking it is what makes Web Flow.

RE- max-execution-snapshots. If I have max-execution-snapshots to 5, doesn't e1s1, s2, s3, s4 etc all save and serialize everything in the flowstate seperatly?

Yes, so set it 0.