# Performance decrease after renaming functions

**URL:** <https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577>\
**Category:** Performance\
**Created:** [May 21, 2021, 11:39am UTC](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577 "2021-05-21T11:39:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tusike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tusike/32/36610_2.png) [@Tusike](https://discourse.julialang.org/u/Tusike)\
**Post date:** [May 21, 2021, 11:39am UTC](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577/1 "2021-05-21T11:39:43Z")

</div>

Hi!

A have a function AND which takes a pre-allocated vector and writes in the result of some operations. Following the julia naming convention, I wanted to change its name to AND! so that this behavior is reflected compared to the versions of this AND function which do not take a pre-allocated result vector as an input. Then I noticed that the performance drops significantly if I perform this change of function name, and also if I change the function name to anything else, e.g. WOOHOO. I do not understand why changing the name of a function results in decreased performance and increased allocation, nor do I know what type of things to check to see what I am doing incorrectly.

I posted a video on slack of this, it is shown after 1:05 following the initial compilation of the code: [Slack](https://files.slack.com/files-pri/T68168MUP-F022U070E4U/julia_fnc_renaming_issue.mp4)

Does anyone have any ideas?

Best,  
-Tusike

Some additional notes:

1. I was advised to check @code\_warntype, it returns that everything is fine.
2. I know I am not interpolating variables in @btime, but I have checked since and it changes nothing.
3. –track-allocation shows that after the name change, significant allocations take place:

```julia
        - function WOOHOO(resTrace::T, rm::AbstractRobustnessMetric, childTraces::T...) where {T<:AbstractTrace}
     3200 resBuffer = Zygote.bufferfrom(getTrajectory(resTrace))
    11200 childTrajectories = [getTrajectory(c) for c in childTraces]
        0 @inbounds for k in eachindex(resBuffer)
 38404800 resBuffer[k] = AND(rm, map(t -> t[k], childTrajectories))
        - end
        0 copyWithNewData(resTrace, copy(resBuffer))
        0 return nothing
        - end

```

compared to the original

```julia
- function AND(resTrace::T, rm::AbstractRobustnessMetric, childTraces::T...) where {T<:AbstractTrace}
        0 resBuffer = Zygote.bufferfrom(getTrajectory(resTrace))
        0 childTrajectories = [getTrajectory(c) for c in childTraces]
        0 @inbounds for k in eachindex(resBuffer)
        0 resBuffer[k] = AND(rm, map(t -> t[k], childTrajectories))
        - end
        - copyWithNewData(resTrace, copy(resBuffer))
        0 return nothing
        - end

```

(Note that there is no recursion here and the inner AND function that is being called has different parameters than the one posted here.)

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [May 21, 2021, 1:50pm UTC](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577/3 "2021-05-21T13:50:11Z")

</div>

one of those is a recursive function the other is not

---

<div class="post-metadata">

**Author:** ![Tusike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tusike/32/36610_2.png) [@Tusike](https://discourse.julialang.org/u/Tusike)\
**Post date:** [May 21, 2021, 2:04pm UTC](https://discourse.julialang.org/t/performance-decrease-after-renaming-functions/61577/4 "2021-05-21T14:04:09Z")

</div>

If you mean the AND function called inside the for loop, it is not the same AND function as the one I am examining and renaming. So there is no recursion going on. The code runs exactly the same in both cases, and the same results are returned when I test them in my larger code.
