Skip to content

Commit

Permalink
Remove @debug statements
Browse files Browse the repository at this point in the history
These cause a real slowdown in the runtime (~20% degradation)
even when DEBUG isn't enabled

There are quite a few complaints about this in the forums, e.g.,
JuliaLang/julia#28147. It does seem to have improved, but for code like this it's still a
serious regression
  • Loading branch information
graeme-a-stewart committed Apr 17, 2024
1 parent 8e37a6e commit 2e9c949
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ benchmark/*
.DS_Store
/notebooks/*
/profile/*
/statprof/*
/debug/*
12 changes: 8 additions & 4 deletions src/PlainAlgo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ function _plain_jet_reconstruct(;particles::Vector{PseudoJet}, p = -1, R = 1.0,
kt2_array::Vector{Float64} = pt2.(particles) .^ p
phi_array::Vector{Float64} = phi.(particles)
rapidity_array::Vector{Float64} = rapidity.(particles)
nn = Vector(1:N) # nearest neighbours
nndist = fill(float(R2), N) # geometric distances to the nearest neighbour
nn::Vector{Int} = Vector(1:N) # nearest neighbours
nndist::Vector{Float64} = fill(float(R2), N) # geometric distances to the nearest neighbour
nndij::Vector{Float64} = zeros(N) # dij metric distance

# Maps index from the compact array to the clusterseq jet vector
Expand All @@ -148,12 +148,16 @@ function _plain_jet_reconstruct(;particles::Vector{PseudoJet}, p = -1, R = 1.0,

iteration::Int = 1
while N != 0
@debug "Beginning iteration $iteration"
# Extremely odd - having these @debug statements present causes a performance
# degradation of ~140μs per event on my M2 mac (20%!), even when no debugging is used
# so they need to be completely commented out...

#@debug "Beginning iteration $iteration"
# Findmin and add back renormalisation to distance
dij_min, i = fast_findmin(nndij, N)
dij_min *= R2
j::Int = nn[i]
@debug "Closest compact jets are $i ($(clusterseq_index[i])) and $j ($(clusterseq_index[j]))"
#@debug "Closest compact jets are $i ($(clusterseq_index[i])) and $j ($(clusterseq_index[j]))"

if i != j # Merge jets i and j
# swap if needed
Expand Down
7 changes: 7 additions & 0 deletions src/TiledAlgoLL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ Main jet reconstruction algorithm, using PseudoJet objects
function tiled_jet_reconstruct(particles::Vector{PseudoJet}; p = -1, R = 1.0, recombine = +)
# Bounds
N::Int = length(particles)

# Extremely odd - having these @debug statements present causes a performance
# degradation of ~20μs per event on my M2 mac (12%!), even when no debugging is used
# so they need to be completely commented out...
#
# There are a few reports of this in, e.g., https://github.com/JuliaLang/julia/issues/28147
# It does seem to have improved, but it's far from perfect!
# @debug "Initial particles: $(N)"

# Algorithm parameters
Expand Down

0 comments on commit 2e9c949

Please sign in to comment.