-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allocations and GC being ignored? #26
Comments
Here I use
Now we see GC (it seems in many case it doesn't run, so the median doesn't detect it) but it really doesn't agree with my benchmark (more GC for |
The BenchmarkTools results seem correct to me; it makes sense that the in-place matrix multiply isn't allocating, and that memory usage is small for small arrays. Also, it seems that you're directly comparing aggregate measurements vs. BenchmarkTool's individual execution estimates, which are totally different measurements (e.g. these numbers seem to be comparing estimates of a single matmul with direct measurements of a large number of matmuls). I might be missing something though, since I don't have the actual code. If you believe this is unexpected behavior, can you share the actual code used to generate these numbers (preferably self-contained + whatever packages are required)? |
I still don't know about the OP here, but found a case where this issue is real (JuliaLang/julia#19257). It comes from the |
By resolves the issue, do you mean reports more allocations and longer run-times? EDIT: Yes, I see that in the PR. Looks great. |
I don't know how #28 affects the issue in the OP here because I can't verify the issue in the OP (I don't have the code). #28 fixes an issue where the function BenchmarkTools was constructing was "overly" amenable to code ellision (either from LLVM or Julia). Even after that PR, however, it's still simple to construct cases where the ellision will occur (see that PR for an example). I think in such cases, BenchmarkTools is correct to report no allocation, since running such a function "in the wild" should have the same effect given a similar calling environment. |
So #28 doesn't seem to affect my results in any meaningful way. I'm going to have a deeper look sometime but I can't right now. The code is at https://github.com/JuliaArrays/StaticArrays.jl/blob/use-size/perf/benchmark3.jl but that might not be too useful to you (I'll try make a minimal example when I have more time). |
Just a note that #28 fixes a problem we had where some functions were being completely elided. Was just going to file an issue and then it is already fixed. What a luxury. |
Is this bug still relevant? |
I'm finding different results using BenchmarkTools as opposed to my own loops and
@time
, particularly regarding allocating operations.I'm benchmarking
Base.Array
vs the types in StaticArrays.jl. Some of these arrays are immutable, and don't perform GC allocations, and others are mutable. If you are doing lots of small, e.g., matrix multiplications, then the allocations and GC can dominate the cost, and an immutable array is much faster. I have a non-allocatingSArray
and a (mutable) allocatingMArray
.The typical results I were getting using loops and
@time
showed that when new copies ofArray
orMArray
were created, a lot of time was spent on allocation and GC (but not forSArray
):However, I switched my tests to BenchmarkTools.jl and now the difference between
SArray
andMArray
has disappeared. It appears almost like the allocating costs have been ameliorated somehow. Perhaps I'm using the package wrong, but I get:The two calls I make are
@benchmark *($(copy(m)), $(copy(m)))
and@benchmark A_mul_B!($(copy(m)), $(copy(m)), $(copy(m)))
, wherem
is some random matrix 4x4 I made out of the above types. Is that the right way to use@benchmark
?The text was updated successfully, but these errors were encountered: