Skip to content

Conversation

morrisonlevi
Copy link
Collaborator

@morrisonlevi morrisonlevi commented Sep 16, 2025

PROF-12543

Key Changes

New EnabledProfiles structure for faster hashing

Encodes the enabled profile and sample types into a single integer. It replaces SampleTypeFilter in the ProfileIndex and SampleTypeFilter is now unused so it's removed. This speeds up Hash + Eq when used inside of ProfileIndex as a key in the hash map by the processing thread.

Sample values are inline instead of a Vec to unblock sooner

This replaces the Vec<i64> of samples in SampleData with SampleValues. It's converted into a Vec in the other thread. This offloads the CPU and memory work to the processing thread, which unblocks the thread taking the sample sooner.

New data structures InlineVec and BitSet

InlineVec<T, N> is a custom stack-allocated vector implementation that stores elements inline without heap allocation, similar to the arrayvec crate but with const fn support.

BitSet is a simple stack-allocated bitset backed by an integer. This means it doesn't allocate memory and operations on it are quick and simple, notably Hash and Eq are much cheaper (no iteration required).

Additional Notes

  • A small number of allocation failures in the other thread were converted to non-panic versions, instead dropping the sample. This moves the needle a bit but it isn't comprehensive.
  • This work is a stepping stone towards using the new profiling API, which has multiple profiles with only 1-2 sample types per profile. This influences the shape of the new APIs.
  • This PR is an opportunity for me to run a performance benchmark with Florian's new benchmarking tool!

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

Adds inlinevec and bitset as helper datatypes.
@morrisonlevi morrisonlevi changed the title perf: sample filtering and hashing perf(prof): sample filtering and hashing Sep 16, 2025
@morrisonlevi morrisonlevi added cat:performance profiling Relates to the Continuous Profiler labels Sep 16, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.75%. Comparing base (b3136db) to head (4175238).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3416      +/-   ##
==========================================
- Coverage   61.90%   61.75%   -0.15%     
==========================================
  Files         141      141              
  Lines       12481    12481              
  Branches     1630     1630              
==========================================
- Hits         7726     7708      -18     
- Misses       4033     4051      +18     
  Partials      722      722              

see 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3136db...4175238. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link

pr-commenter bot commented Sep 16, 2025

Benchmarks [ profiler ]

Benchmark execution time: 2025-09-16 17:06:09

Comparing candidate commit 4175238 in PR branch levi/sample-types with baseline commit b3136db in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 28 metrics, 7 unstable metrics.

scenario:php-profiler-timeline-memory-with-profiler

  • 🟩 cpu_user_time [-87.421ms; -52.070ms] or [-7.295%; -4.345%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:performance profiling Relates to the Continuous Profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants