Skip to content

Commit

Permalink
Merge pull request #3757 from DataDog/ivoanjo/avoid-code-provenance-a…
Browse files Browse the repository at this point in the history
…llocations

[NO-TICKET] Optimize CodeProvenance#record_loaded_files to avoid allocations
  • Loading branch information
ivoanjo authored Jul 8, 2024
2 parents e378928 + f0be554 commit cf1f062
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/datadog/profiling/collectors/code_provenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ def record_loaded_files(loaded_files)

seen_files << file_path

_, found_library = libraries_by_path.find { |library_path, _| file_path.start_with?(library_path) }
seen_libraries << found_library if found_library
# NOTE: Don't use .find, it allocates a lot more memory (see commit that added this note for details)
libraries_by_path.any? do |library_path, library|
seen_libraries << library if file_path.start_with?(library_path)
end
end
end

Expand Down

0 comments on commit cf1f062

Please sign in to comment.