You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been running some hundreds of millions of iterations of pvmismatch calculations and am interested in optimizing for calculation speed. I noticed that some of the PVcell property methods get called many times for each calcCell() invocation, and it seems to me that all but one of each is redundant. For the test script
importpvmismatchcell=pvmismatch.PVcell()
here is the profiler results for master:
For instance, Isat1 is called 18 times. I tried out a simple caching mechanism that intercepts property calls and only runs the calculations once:
Which, after adding a _cache = {} definition to the PVcell class and self._cache.clear() to its __setattr__ method, lets you decorate property methods like this:
@property@cacheddefIsat1(self):
...
Profiler results using the cache on each of the properties (except looks like I forgot Vt):
I haven't spent enough time with pvmismatch to be sure of all the conditions where the cache should be invalidated, but it seems like there's some potential for speedup with minimally invasive surgery. The code I used for these tests is here: https://github.com/kanderso-nrel/PVMismatch/tree/pvcell_cache
I wanted to get some feedback on the idea before going too far with it. If folks are in support, I'm happy to open a PR.
The text was updated successfully, but these errors were encountered:
I've been running some hundreds of millions of iterations of pvmismatch calculations and am interested in optimizing for calculation speed. I noticed that some of the PVcell property methods get called many times for each
calcCell()
invocation, and it seems to me that all but one of each is redundant. For the test scripthere is the profiler results for
master
:For instance,
Isat1
is called 18 times. I tried out a simple caching mechanism that intercepts property calls and only runs the calculations once:Which, after adding a
_cache = {}
definition to the PVcell class andself._cache.clear()
to its__setattr__
method, lets you decorate property methods like this:Profiler results using the cache on each of the properties (except looks like I forgot
Vt
):And some timings:
I haven't spent enough time with pvmismatch to be sure of all the conditions where the cache should be invalidated, but it seems like there's some potential for speedup with minimally invasive surgery. The code I used for these tests is here: https://github.com/kanderso-nrel/PVMismatch/tree/pvcell_cache
I wanted to get some feedback on the idea before going too far with it. If folks are in support, I'm happy to open a PR.
The text was updated successfully, but these errors were encountered: