Skip to content

cache Type{wrapper} for faster lookups#44704

Merged
JeffBezanson merged 1 commit intomasterfrom
jb/consttype
Apr 13, 2022
Merged

cache Type{wrapper} for faster lookups#44704
JeffBezanson merged 1 commit intomasterfrom
jb/consttype

Conversation

@JeffBezanson
Copy link
Copy Markdown
Member

Benchmark from #44402:

julia> @btime Core.Compiler.widenconst(c1)
  98.999 ns (0 allocations: 0 bytes)
Type{Base.RefValue}

julia> @btime Core.Compiler.widenconst(c2)
  25.269 ns (0 allocations: 0 bytes)

alternative to #44447

mostly fixes #44402

@JeffBezanson JeffBezanson added types and dispatch Types, subtyping and method dispatch latency Latency labels Mar 23, 2022
@aviatesk
Copy link
Copy Markdown
Member

@nanosoldier runbenchmarks("inference", vs=":master")

@nanosoldier
Copy link
Copy Markdown
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

Comment thread src/julia.h Outdated
@JeffBezanson JeffBezanson force-pushed the jb/consttype branch 4 times, most recently from baa70a4 to fe34430 Compare April 6, 2022 19:25
Comment thread src/jltypes.c
Comment thread src/jltypes.c
Comment thread src/jltypes.c
Comment thread src/staticdata.c
Comment on lines +571 to 573
jl_serialize_value(s, tn->Typeofwrapper);
jl_serialize_value_(s, (jl_value_t*)tn->cache, 0);
jl_serialize_value_(s, (jl_value_t*)tn->linearcache, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
jl_serialize_value(s, tn->Typeofwrapper);
jl_serialize_value_(s, (jl_value_t*)tn->cache, 0);
jl_serialize_value_(s, (jl_value_t*)tn->linearcache, 0);
jl_serialize_value(s, jl_atomic_load_acquire(&tn->Typeofwrapper));
jl_serialize_value_(s, (jl_value_t*)jl_atomic_load_acquire(&tn->cache), 0);
jl_serialize_value_(s, (jl_value_t*)jl_atomic_load_acquire(&tn->linearcache), 0);

(I don't yet have this file enabled for this static-analysis check, since there are other similar updates missing too)

mostly fixes #44402

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

latency Latency types and dispatch Types, subtyping and method dispatch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

widenconst of a Const(::Type) can be quite slow

4 participants