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

only cache concrete types #57442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adienes
Copy link
Contributor

@adienes adienes commented Feb 17, 2025

I believe too many types are being constructed (causing allocations) when nonconcrete hash entries collide with the desired concrete type

appears to fix #57434 (at least back to <=1.9 performance)

I will admit I am not 100% sure I understand why this works, nor am I sure what the best way to add a test is besides add this example as a benchmark.

@adienes adienes requested a review from vtjnash February 17, 2025 17:50
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with this, if it passes CI here. It may expose some unsoundness more, but I think those cases would already have been more problematic elsewhere, so this doesn't seem likely to make it worse, and it makes sense this should fix this case.

@adienes
Copy link
Contributor Author

adienes commented Feb 17, 2025

awesome, thanks for the fast review

do you have any suggestions for a good test? I could do something like

foo(T, arr) = T.(arr)
@allocated foo(Float32, [1]) <= 240

but I'm worried this is too high-level (it technically depends on broadcast implementation as well)

@adienes
Copy link
Contributor Author

adienes commented Feb 17, 2025

failure is legit and comes from @test (Type{Base.Broadcast.Broadcasted}).hash != 0

although maybe this is expected? since isconcretetype(Base.Broadcast.Broadcasted) == false

}
else {
jl_datatype_t *dtuw = (jl_datatype_t*)uw;
if (!dtuw->isconcretetype || dtuw->name->wrapper != p)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!dtuw->isconcretetype || dtuw->name->wrapper != p)
if (!dtuw->isconcretetype && dtuw->name->wrapper != p)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change appears to reintroduce the performance problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3x regression in broadcast with fused outer constructor
2 participants