-
-
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
function is mysteriously slow unless a second (irrelevant) method is defined #52020
Comments
Maybe related to the nondeterminism in type inference #35800 or #50735?
You could start by copying all code required for the MWE into a single file (without package imports), then removing irrelevant code while checking that the issue still reproduces. |
Not sure. In those issues,
Also, I've created a single file (no modules besides BenchmarkTools and Test) that reproduces the error, in case that helps. single file
|
Changing the line It's curious that defining the other method somehow results in the first method being specialized afterwards, though. |
Thanks! I've run the file posted in my previous comment with Julia 1.10.0-beta3 and |
This seems to be a weird bug: A function with a single method that should be fast is instead slow and allocates. However, once a second method is defined (but not used), the first method suddenly becomes fast. Unfortunately, I haven't managed to create a MWE that doesn't need additional packages. Here is the example I have:
The output is
(for master). I see no reason why the timings for the two calls to
g
should be different. The second one is as expected; the first one is mysteriously slow. I get essentially the same timings for Julia 1.9.0 and 1.10.0-beta3. If the line labeledA
above is removed, both calls are fast. The same is true if insteadB1
andB2
are removed.The example uses the package SmallTypes.jl (which is not registered) and the module JuliaBug.jl.
Code for JuliaBug.jl
I've had some other weird effects with functions similar to
g
. However, I couldn't make them reproducible.The text was updated successfully, but these errors were encountered: