Skip to content
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

adding a method to Base.Int can result in (seemingly) unrelated recompilation #29166

Closed
rfourquet opened this issue Sep 13, 2018 · 1 comment
Closed
Assignees
Labels
compiler:latency Compiler latency regression Regression in behavior compared to a previous version

Comments

@rfourquet
Copy link
Member

This is a MWE:

struct X <: Integer end
Base.Int(::X) = 0

After entering this in the REPL, it becomes annoyingly slow (even for simple things as entering 1+2), while Julia apparently recompiles a bunch of functions. This problem apparently disappears for other Base builtin integers, or when using e.g. Real instead of Integer as the supertype.
Also, this doesn't happen on 0.7, so I will label as a regression.

@rfourquet rfourquet added the regression Regression in behavior compared to a previous version label Sep 13, 2018
@JeffBezanson JeffBezanson added the compiler:latency Compiler latency label Sep 13, 2018
@JeffBezanson JeffBezanson self-assigned this Jan 24, 2019
JeffBezanson added a commit that referenced this issue Jan 24, 2019
reuse `Base._array_for` in lowering instead of manually inlining it
@JeffBezanson
Copy link
Member

I'll note that this is not really a bug --- AFAICT we were not invalidating any methods incorrectly --- but it did point to some places we could improve the typing of Base code. This new definition invalidates anything that calls Int(x::Integer). In general it is not easy to guess how many inferred methods might contain that, or any other function/type pair.

JeffBezanson added a commit that referenced this issue Jan 25, 2019
reuse `Base._array_for` in lowering instead of manually inlining it
JeffBezanson added a commit that referenced this issue Jan 28, 2019
reuse `Base._array_for` in lowering instead of manually inlining it

[ci skip]
JeffBezanson added a commit that referenced this issue Feb 7, 2019
reuse `Base._array_for` in lowering instead of manually inlining it
JeffBezanson added a commit that referenced this issue Feb 7, 2019
reuse `Base._array_for` in lowering instead of manually inlining it
Keno pushed a commit that referenced this issue Jun 5, 2024
reuse `Base._array_for` in lowering instead of manually inlining it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

2 participants