Skip to content

Avoid unconditional spinlock bounce in AllocationSampleList::ReportMalloc. - #1328

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_995150742
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_995150742

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Avoid unconditional spinlock bounce in AllocationSampleList::ReportMalloc.

Previously, AllocationSampleList::ReportMalloc unconditionally acquired the global AllocationSampleList::lock_ spinlock on every sampled allocation in SampleifyAllocation, even when no AllocationSample profiler was active (first_ == nullptr).

Make first_ a std::atomic<AllocationSample* absl_nullable> and check first_.load(std::memory_order_acquire) == nullptr before acquiring lock_, matching DeallocationProfilerList::ReportMalloc.

@google-cla

google-cla Bot commented Oct 7, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service copybara-service Bot changed the title Avoid unconditional spinlock acquisition in AllocationSampleList::ReportMalloc when empty Avoid unconditional spinlock bounce in AllocationSampleList::ReportMalloc. Oct 12, 2026
…lloc.

Previously, `AllocationSampleList::ReportMalloc` unconditionally acquired the global `AllocationSampleList::lock_` spinlock on every sampled allocation in `SampleifyAllocation`, even when no `AllocationSample` profiler was active (`first_ == nullptr`).

Make `first_` a `std::atomic<AllocationSample* absl_nullable>` and check `first_.load(std::memory_order_acquire) == nullptr` before acquiring `lock_`, matching `DeallocationProfilerList::ReportMalloc`.

PiperOrigin-RevId: 995150742

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants