-
Notifications
You must be signed in to change notification settings - Fork 108
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
ENH: Refactor solver and improve solver performance #360
ENH: Refactor solver and improve solver performance #360
Conversation
An alternative to this could be to just have one |
Codecov Report
@@ Coverage Diff @@
## develop #360 +/- ##
========================================
Coverage 89.75% 89.75%
========================================
Files 44 44
Lines 4275 4275
========================================
Hits 3837 3837
Misses 438 438
Continue to review full report at Codecov.
|
This approach is fine. |
Below are some profiling runs from a 10 iteration ESPEI run of a binary system (with Cython These changes give ~30% performance improvement. I did a couple of runs with Cython profiling on and off and the improvement in the I also tried annotating the Cythonized output and playing with some Cython optimizing directives, which didn't seem to make much measurable difference. DevelopThis branchIn the fourth row, the fourth box to the right are calls to |
Wow, copying |
Copying the state is about half the overall speedup (it's the labeled box in the fourth row of the develop branch benchmarks, accounting for 82 seconds). The other half comes from refactoring the allocations and calls to But yeah, almost 20% of the current solver time is just copying the State object |
Fresh benchmarks on e20464f |
The bigger step size and new Gibbs phase rule code calls |
The benchmark above was for a binary case. I also ran a benchmark equilibrium calculation in a 5 component system and can verify the performance holds up compared to In the 5 component benchmark, each call to |
I noticed that Lowering to 50 gives no noticeable regression in the plotting except for some narrow regions are missed (proper mapping will solve this), so it should be safe to do. |
…rule" This reverts commit d9ff9de.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
If any iteration triggered a change of phases, then the while loop would run for all 10 iterations because nothing reset changed_phases to False
This reverts commit 93df7e6.
I have noticed in benchmarking that roughly 1/3 of the time in the solver is spent performing this copy operation on the
state
. We don't do anything meaningful with the old state except for using its data, so I propose to remove it and replace the couple instances with explicitly storing the relevant variables before taking a step.If we want to do more advanced things with the previous state(s) later, that's definitely something we could do, but I think all the memory allocations in one of the innermost loops is probably not worth it compared to copying the values we need out.
This change could probably use a more real benchmark to justify it, but I wanted to get it posted for feedback before I invest much more time into it.