Comments (4)
You can call jl_normalize_to_compilable_sig
to get the signature that we would compile for.
from alloccheck.jl.
This leads to another case where using check_allocs(...)
can be misleading.
You might expect that check_allocs(sum_args, (Int, Int, Int))
would check allocations for a call like sum_args(1,2,3)
:
julia> check_allocs(sum_args, (Int, Int, Int))
Any[] # Hooray, no allocations! ...Right?
In reality, the correct signature to check allocations for sum_args(1,2,3)
is:
julia> check_allocs(sum_args, (Int, Vararg{Int}))
2-element Vector{Any}:
Allocating runtime call to "jl_f_tuple" in unknown location
Dynamic dispatch to function sum in ./REPL[82]:1
That signature depends on how the Julia compiler chooses to monomorphize though, which is neither stable nor documented. So you can't really anticipate this as a user, except in cases where the compiler is reasonably expected to fully monomorphize.
from alloccheck.jl.
Could check_allocs
somehow be taught
how the Julia compiler chooses to monomorphize
?
which is neither stable nor documented
Can this choice vary in-between julia sessions on the same julia version, or even within the same Julia session?
from alloccheck.jl.
Can this choice vary in-between julia sessions on the same julia version, or even within the same Julia session?
Yeah, in general it can even depend on nearby methods:
julia> @noinline foo(args...) = error(args)
julia> bar1(x) = foo(x+1,x+2,x+3)
julia> bar1(0)
ERROR: (1, 2, 3)
Stacktrace:
[1] error(s::Tuple{Int64, Int64, Int64})
@ Base ./error.jl:44
[2] foo(::Int64, ::Vararg{Int64})
@ Main ./REPL[1]:1
[3] bar1(x::Int64)
@ Main ./REPL[2]:1
[4] top-level scope
@ REPL[3]:1
julia> foo(x::Int64, y::Int64) = error((x, y)) # Add an explicitly-expanded definition
julia> bar2(x) = foo(x+1,x+2,x+3)
julia> bar2(0)
ERROR: (1, 2, 3)
Stacktrace:
[1] error(s::Tuple{Int64, Int64, Int64})
@ Base ./error.jl:44
[2] foo(::Int64, ::Int64, ::Int64) # foo was more heavily-specialized now
@ Main ./REPL[1]:1
[3] bar2(x::Int64)
@ Main ./REPL[5]:1
[4] top-level scope
@ REPL[6]:1
The explicitly-expanded definition affects specialization, even though it's never called.
from alloccheck.jl.
Related Issues (20)
- Adjust to `Memory{T}` changes HOT 1
- Merge allocation sites per callstack
- Pipeline discrepancies + Inference instability under recursion
- Add documentation to clarify that calling an allocation-free function can still allocate
- Find a way to get source excerpts for REPL code? HOT 1
- [Feature] Warning output instead of error HOT 2
- Call-site macro HOT 3
- TagBot trigger issue HOT 3
- @check_allocs interacts badly with splatted args and kwargs
- Error from within AllocCheck when calling @check_allocs function HOT 1
- Kwargs in anonymous function
- Inconsistent with `@allocations` (Bug?) HOT 2
- Similar Package - TestNoAllocations.jl - Crossreference or Merging? HOT 6
- on Julia v1.11 non-allocating internal functions are reported as allocating HOT 3
- design of `@check_allocs` for static compilation
- ERROR: '@check_allocs' not documentable
- crashes Julia HOT 2
- Add semi-dynamic `ccall` support HOT 1
- Bug: ccall method definition: return type doesn't correspond to a C type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alloccheck.jl.