-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Non-deterministic allocations in function call #27768
Comments
Seems to be a type inference issue that has to do with precompilation. 10k allocations (no precompile):
Every argument inferred 20k allocations (after first precompile)
Some arguments not inferred 40k allocations (recompile):
Some other arguments not inferred... Very nice MWE Even something even smaller like
can show this:
note, |
Nice! Thanks for looking into it @KristofferC. So it's got to do with inference, but do you know why it fails randomly? It does seem to be related to the tuple destructuring. |
I don't think it has to do anything with the tuple, since I can get the Also, cannot reproduce on 0.6. |
Uhm, I do see how your ultraminimalistic example fails to be inferred, but it doesn't seem to allocate randomly for me. It always behaves the same in that regard.
Do you see the inference failure with your MWE always, or randomly? |
It's a bit random, sometimes the first argument fails to infer aswell
|
cc @vtjnash |
May be fixed (at least the inference failure problems) by 4562ae2 |
Amazing, absolutely genius @vtjnash. Completely solved AFAICT! Not only the MWE, but the real world case too, it seems. It may be too complicated to explain briefly, but did you understand the root cause (the non-deterministic behaviour in particular)? |
Yeah, I saw some uninitialized memory when doing some unrelated work, and traced it back to here. |
I've run into a very annoying problem whereby a certain package I'm writing would be fast on a fresh REPL, showing few allocations, and them on a different fresh REPL, it would be very very slow, with a huge number of allocations... without touching the code! This is an effort to isolate the problem into a MWE (not sure if it can be made even smaller). To reproduce the issue you will likely need to try several times. For me the behaviour is highly erratic.
So: the following module
elsa
, when developed in./julia/dev
, produces non-deterministic allocations when runningtest()
in current 0.7-beta (I'm not sure when this began)First run in a fresh REPL
Subsequent runs in a fresh REPL (no recompile)
Note the change in execution time and allocations.
Sometimes, on a subsequent run, we again get 40k allocations
If one modifies the code with e.g. some whitespace to force a recompile, I can trigger a change of allocations much more frequently.
Fresh REPL after adding whitespace to force recompile
Second run in a fresh REPL (no recompile)
Third run
You get the idea.
Incidentally, if one runs the
module
straight at the REPL, I never see the problem, and allocations are just 10k (half of the minimum above)X-ref: #25900 (I'm not sure it is related, though, as the
using elsa
itself is deterministic in this example)The text was updated successfully, but these errors were encountered: