GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Scale counter in case of multiplexing (#1585) by vish-chan · Pull Request #1631 · async-profiler/async-profiler

Conversation

@vish-chan

@vish-chan vish-chan commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

Description

If there are more events than counters, the kernel uses time multiplexing to give each event (only PMU events) a chance to access monitoring hardware. With multiplexing, an event is not measured all the time. We need to scale the counter value based on total time enabled vs time running to estimate what the count would have been, had the event been measured during the entire run.

Related issues

  • Running perf stat and ap -e cycles --total in parallel, make them to disagree #1585

Motivation and context

  • Concurrent profilers interfere with each other's PMU access, causing incorrect measurements. While concurrent profiler usage isn't typical in most applications, it's a legitimate use case. This change improves the correctness of async-profiler's measurements by properly handling multiplexed profiling scenarios, ensuring accurate metrics regardless of other active profilers.

How has this been tested?

  • Local tests executed via make test:
Total test duration: 298.367 s
Results Summary:
PASS: 132 (100.0%)
FAIL: 0
SKIP (disabled): 0
SKIP (config mismatch): 4
SKIP (missing JAR): 5
TOTAL: 141
  • Verified the change on the reproducer mentioned in 1585.
# jbang VolatileSpin.java 2
perf stat -d -p 61571 sleep 10 & build/bin/asprof --total -e cycles -d 10 -t 61571 & wait | less

Results of perf stat: Scaling ratio = ~1.49 (100/66.90)

 Performance counter stats for process id '61571':
    48,625,772,042      cycles                    #    2.447 GHz                      (66.90%)
 10.006516992 seconds time elapsed

Results of async-profiler: Scaling ratio = ~1.54 (41455/26785)

       total  percent  samples  top
  ----------  -------  -------  ---
 41455746368   99.84%    26785  VolatileSpin.lambda$main$0

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

franz1981 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
apangin
apangin reviewed Dec 24, 2025
View reviewed changes
Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz
fandreuz reviewed Dec 29, 2025
View reviewed changes
Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vish-chan
vish-chan force-pushed the ap-1585 branch 3 times, most recently from 933a299 to 27e5536 Compare January 22, 2026 17:52
@vish-chan
vish-chan marked this pull request as ready for review January 22, 2026 17:55
apangin
apangin reviewed Jan 22, 2026
View reviewed changes
Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vish-chan
vish-chan force-pushed the ap-1585 branch 2 times, most recently from bff3a9e to 25be7b7 Compare January 23, 2026 14:06
apangin
apangin reviewed Jan 23, 2026
View reviewed changes
Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

apangin
apangin reviewed Jan 23, 2026
View reviewed changes
Comment thread src/perfEvents_linux.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vish-chan
Scale counter in case of multiplexing (async-profiler#1585)
67e9d7c
@vish-chan
vish-chan force-pushed the ap-1585 branch from 25be7b7 to 67e9d7c Compare January 23, 2026 15:01
@apangin
Formatting
f97fbcd
@apangin
apangin merged commit dc88d3f into async-profiler:master Jan 23, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@apangin apangin apangin left review comments
+1 more reviewer
@fandreuz fandreuz fandreuz left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vish-chan @apangin @fandreuz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.