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

gf: cache cache_with_orig decision #48833

Merged
merged 1 commit into from
Mar 1, 2023
Merged

gf: cache cache_with_orig decision #48833

merged 1 commit into from
Mar 1, 2023

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Feb 28, 2023

Memoizing this can save a lot of repeated effort for queries such as @which eltype(String). Otherwise we repeatedly try to check if eltype(::Type) is a good way to cache that result, even though it never gets better the more we check it.

This can make a large difference for some common queries:

julia> @time Base._methods_by_ftype(Tuple{typeof(eltype), Type{Val{7}}}, -1, Base.get_world_counter())
  0.201521 seconds (523.29 k allocations: 27.287 MiB, 4.41% gc time) # before
  0.000111 seconds (38 allocations: 1.797 KiB) # after
1-element Vector{Any}:
 Core.MethodMatch(Tuple{typeof(eltype), Type{Val{7}}}, svec(), eltype(::Type) @ Base abstractarray.jl:234, true)

Memoizing this can save a lot of repeated effort for queries such as
`@which eltype(String)`. Otherwise we repeatedly try to check if
`eltype(::Type)` is a good way to cache that result, even though it
never gets better the more we check it.
@vtjnash vtjnash added backport 1.9 Change should be backported to release-1.9 compiler:latency Compiler latency labels Feb 28, 2023
Copy link
Member

@topolarity topolarity left a comment

Choose a reason for hiding this comment

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

Very nice! 👍

@vtjnash vtjnash added the status:merge me PR is reviewed. Merge when all tests are passing label Feb 28, 2023
@N5N3 N5N3 merged commit bdcd5e2 into master Mar 1, 2023
@N5N3 N5N3 deleted the jn/cache-cache_with_orig branch March 1, 2023 01:09
@N5N3 N5N3 removed the status:merge me PR is reviewed. Merge when all tests are passing label Mar 1, 2023
@KristofferC KristofferC mentioned this pull request Mar 3, 2023
50 tasks
KristofferC pushed a commit that referenced this pull request Mar 3, 2023
Memoizing this can save a lot of repeated effort for queries such as
`@which eltype(String)`. Otherwise we repeatedly try to check if
`eltype(::Type)` is a good way to cache that result, even though it
never gets better the more we check it.

(cherry picked from commit bdcd5e2)
KristofferC pushed a commit that referenced this pull request Mar 3, 2023
Memoizing this can save a lot of repeated effort for queries such as
`@which eltype(String)`. Otherwise we repeatedly try to check if
`eltype(::Type)` is a good way to cache that result, even though it
never gets better the more we check it.

(cherry picked from commit bdcd5e2)
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants