raoul2000 / yii2-workflow

A simple workflow engine for Yii2
BSD 3-Clause "New" or "Revised" License
171 stars 48 forks source link

performance question #27

Closed cornernote closed 8 years ago

cornernote commented 8 years ago

Hello @raoul2000,

I used your simpleWorkflow extension for a Yii1 application I developed a few years back. Overall I was really impressed with your work, however it did seem like it added a performance hit when dealing with many models. I don't have any actual benchmark data to back this up as it was something that kind of crept up on me.

The use case was complex, but let me give you an example of some of the transition callbacks that were used...

There are 5 models in a kind of chain:

Job < Item < Unit > Package > Pickup

The chain works like this (as a simple example):

If you then change the Pickup to be a status other than Done it has to again work it's way through the chain to eventually change the Job to not be Done.

There is more to it than this, but it gives you an overview of the number of models I could be dealing with in a single status change. Basically one status change could lead to dozens (or sometimes hundreds) of models being loaded.

The same app is now being redeveloped in Yii2 and I am considering using your yii2-workflow extension, however my primary hesitation is the performance hit that it may incur. I looked at cebe's lifecycle behavior, and it looked very light, but also a little too simple for the task at hand. The extension seems very feature rich, but this comes with complexity, and probably a performance hit.

I was wondering what your thoughts were on performance of yii2-workflow compared to simpleWorkflow.

Thanks again for sharing this great extension!

raoul2000 commented 8 years ago

Hi @cornernote, and thanks for your nice comments about yii2-workflow.

The use case you described is indeed quite complex and I understand that the status change propagation trough this kind of data structure may lead to a lot of processing. Regarding performance comparison between yii2-workflow and simpleWorkflow I would says that they are equivalent and even if there has been changes, the base principle that drives them is the same. Unfortunately I have no benchmark to rely on, but let's says that I would be surprised if a big performance gap would exist between these 2 extensions.

For a personal project I had to deal with the same kind of use case, but with only 2 levels of propagation and not so many models. Until now I didn't find a convenient way to optimize the status change cascade ... (and the query optimization I tried, increased code complexity).

Of course, if you have any proposition for optimization I'll be glad to hear them ...

ciao :sunglasses:

cornernote commented 8 years ago

I am hoping that because of changes in the frameworks for Yii2 vs Yii1, as well as the addition of handling via events that performance will be better. I'll close this, but I'll keep you posted if I hit any performance issues that I have suggestions for.