-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Slow calculation and memory leaking with 0.5.1 #401
Comments
It could be related to fixing ModelChain to actually use Is pvlib the only thing that's changed in your environment? |
Thanks for your suggestions! I will look into them. Updating pvlib was not the only change that occurred, but after reverting to 0.5.0 the behavior was normal again. |
Looks like you are using the single diode model, so it also could be my changes to support ideal devices. |
@jkfm did you get a chance to look into what might have caused the pvlib performance problem? |
Not yet :-( But I will report back. |
@jkfm any reports back from your investigation? We'd like to fix the issue you experienced, if we can narrow down the cause. |
Hey all, sorry for the delay. I am now looking into the problem. I wrote a script which replicates my actual use case but is much simpler: https://gist.github.com/jkfm/6c5668da8f28403bf37268cda4afeb05 The code for following memory usage is from here. With 30 iterations (my RAM can't handle more ;-) ), the code has the following stats: 0.5.1: I realise, that the memory usage is not really representative as such, but I guess the trend is clear. |
As the script with 0.5.1 also throws different warnings I suspected the reason for the lag to be in I manually changed only those two functions back to their state from 0.5.0 et voilà: So I guess the error has to do with changes in @wholmgren Some more information regarding the warnings: With the new code, I get this warning for each iteration: |
Confirmed. I get different numbers for |
Thanks @jkfm for this very detailed report! |
good candidate for #530 |
Looked into this a bit more with |
Interesting. I thought the earlier report put the blame on iv functions.
…On Tue, Nov 6, 2018 at 8:43 AM Cliff Hansen ***@***.***> wrote:
Looked into this a bit more with tracemalloc, the memory leak appears to
depend on using numba with spa, because the memory usage is stable with solar_position_method
= nrel_numpy. That is with pvlib v0.6.0.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#401 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AELiRw63XnnDQOzqd3ihJSj7qf3uWdhsks5usa4egaJpZM4RCDHw>
.
|
Looking at the v0.5.1 release notes, maybe the issue was obscured in earlier releases and exposed by #482 |
@cwhanse can you reproduce using only |
Doesn't leak when using |
Looking for other differences between the 3 scripts... I'll speculate that |
@wholmgren when the model chain script has |
Still leaks with |
I'm almost out of ideas.
Does it matter if it's called directly or as part of the def mc_loop(times):
system = get_system()
location = get_location()
mc = get_mc(system, location)
mc.solar_position = mc.location.get_solarposition(times) |
I think I know why this memory leak happens, and I think there's an issue for us but I haven't quite got the issue nailed down. In @jkfm script,
The memory leak only happens when both calculations are in the loop: comment either one out, and no leak. The leak appears to be caused by cycling between When
As a consequence, the first time solar position is calculated,
which passes the value The issue for us, is that |
Ah, that is very interesting. pvlib tells python to reload the An easy thing would be to emit a user warning each time the Also I have no idea why this leads to a memory leak, but I'm not shocked that it does. |
Cause confirmed. Adding the method argument
stops the leak. |
Maybe a I'm guessing @jkfm has the solar position computed explicitly because it's not obvious that
|
It also takes a few seconds for python to reload the spa module when jitting it. Users should be discouraged from doing this. I don't think this is a I once ran into a similar problem in some code in which I ran |
Yes, the performance hit for numpy/numba swapping is noticeable. Unless you object I'll prepare a PR with:
I thought better of an if/then around that statement in |
That's basically what @jkfm was doing. |
@cwhanse thanks for volunteering to make a PR.
+1. Warning should probably go here and here.
I moderately object to this because the reload problem would already be covered by the new warning and
I agree that this could easily lead to trouble and should be avoided. |
I agree with If there was an easy way to access the |
Hi all,
I am using pvlib to calculate many pv arrays and do this by looping over the individual system specs. Since updating on 0.5.1, I noticed much longer calculation times and a steady increase in memory usage.
From a quick glance at the changes from 0.5.0 I couldn't determine an obvious cause for this behavior. Did I miss something?
My parameters for the calculation are
ModelChain(system, location, dc_model='singlediode', ac_model='snlinverter', spectral_model='no_loss', temp_model='sapm', aoi_model='ashrae', solar_position_method='nrel_numba', transposition_model='haydavies', losses_model='pvwatts', clearsky_model='simplified_solis', orientation_strategy=None)
The text was updated successfully, but these errors were encountered: