New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance question #12
Comments
Hi, thank you very much for reporting this. You are right, there is a performance issue. But let me first clarify something. On ComplexityYou will never get any benefits from pyknow for this kind of one-shot, trivial programs. You can easily implement that example in pure python like this: matched = not_matched = 0
for i in range(fact_count):
# rule1
if i == i % 10:
matched += 1
# rule2
if i != i % 10:
not_matched += 1 There are two mayor differences with the code you provided:
Maybe that was clear to you, but I think it is not for everybody. A little pyknow historyIn the past we put all our efforts on making the implementation correct, postponing optimizations until they were absolutely needed. At the beginning pyknow wasn't even based on the RETE algorithm! Now that we reached a point of stability on the implementation we can start thinking on making things faster. About the issueAfter doing some profiling on pyknow and an equivalent test on Clips I think we can reach the same level of complexity that Clips (but not the same performance, of course) without making too many changes. I will start working on the performance issues I've seen after testing and profiling with your sample code. So, thank you again for opening this issue and please stay tuned to see some performance improvements over the following days/weeks. |
Hi, Thanks for your reply. Yes, I was expecting that there must be some complexity issue which plays part here and true this is quite trivial example and does not really need pyknow to solve the problem. What I am doing is to evaluate possible solutions for experts systems which our team could use when doing fault analysis. We potentially may have quite lot of facts so that's why I have done some performance measurements. However as said, cleaning up of facts can be done without pyknow before actually feeding the facts to pyknow. I have been testing some time ago PyKE as well but what I really like about pyknow compared to PyKE is that you can easily integrate it to python code and you can feed facts easily from all sorts of sources and it nicely work with it interactively top of Jupyter. Since not all in my team are fluent with python I think Jupyter based interactive python interpreter and system like pyknow would perhaps lower the bar for them and still allow very flexible way of working with problem analysis. |
Hi, I finished implementing the first batch of optimizations. The time complexity drop dramatically after fixing issues #17 and #18 (light-blue line) which affected a really old part of the project, the conflict resolution strategy system. I changed the way it internally works and now the numbers are much better. This is the result of executing your code now (# facts / seconds):
Now 10k facts are processed in ~2 seconds. You can check the progress in the I will release a new version with this changes in the following days and keep working on further optimizations. |
Hi, Tested the branch and it is lightning fast :) Thank you! |
Pyknow v1.6.0 is out. Enjoy :) |
Thank you! |
how i can obtain policy proccessing time? |
I have implemented following test application for measuring performance of pyknow.
When I run it with following fact counts:
I am getting these results for execution time in seconds:
The problem is that the execution time becomes a bottleneck very quickly in my case when there are around 10000 facts. This was simplified example (and in principle this could be easily implemented without pyknow) but I would think that 10000 facts should not be a big issue when the rules are so simple.
If I remove
@Rule(Fact(MATCH.a, ~MATCH.a))
which is fired more often than the other one, then execution time stays quite short (max 11 seconds).So is this known issue or do I just misunderstanding something?
The text was updated successfully, but these errors were encountered: