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 — Profile CPU + Wall clock together · Issue #740 · async-profiler/async-profiler

Profile CPU + Wall clock together #740

New issue
Copy link
New issue
Copy link
Closed
Closed
Profile CPU + Wall clock together#740
Copy link
Labels
enhancement

Description

@apangin
apangin
opened on Apr 1, 2023
Issue body actions

Background

There are two commonly used profiling modes: cpu that samples actively running threads and wall that gets stack traces of all threads, whether they are running, sleeping or blocked. cpu mode works best for highlighting hot spots, while wall can be useful for analyzing latency issues.

Wall clock mode can replace CPU profiling to some extent. With jfr output, async-profiler records thread state for each execution sample: STATE_RUNNABLE or STATE_SLEEPING. If we filter only STATE_RUNNABLE samples, we will get a CPU-like profile. This can be achieved by using --cpu option in jfr2flame converter. However, there are several downsides of this approach:

  • kernel stack traces are not available in wall clock mode;
  • wall mode generally has higher overhead than cpu;
  • this approach is less accurate comparing to perf_events based sampling.

Proposal

This is a proposal to make joint cpu and wall profiling possible. Async-profiler already supports profiling multiple events together (cpu+alloc+lock), if the output format is set to jfr. We will add an option to include wall in the set of profiled events. The interval of wall clock profiling can be set independently of cpu interval, e.g.

-e cpu -i 10ms --wall 200ms -f out.jfr

Agent arguments equivalent:

event=cpu,interval=10ms,wall=200ms,file=out.jfr

Joint output

cpu and wall can be profiled together only with jfr output.

Both modes produce events of the same jdk.ExecutionSample type. Events coming from wall profiling have STATE_RUNNABLE or STATE_SLEEPING thread state. Events from other modes now have STATE_DEFAULT thread state.

There is no more --cpu option in jfr2flame converter. It has been replaced with --state option that accepts a comma separated list of filtered event types. E.g.

  • --state default extracts execution samples produced by cpu (perf) engine;
  • --state runnable,sleeping shows only wall clock samples.

Notes

  1. The new feature has effect on Linux only. CPU profiling engine on macOS is already based on the wall clock mode - there is no additional gain comparing to the existing -e wall option.
  2. Enabling wall profiling in addition to cpu results in higher overhead. It makes sense to increase wall interval when profiling both events together.
Reacted by Krzysztof Ślusarski, Long Yang, Grzegorz Budzyński, Dmytro Vyazelenko, Behrooz Nobakht and Artyom Drozdov

Activity

  1. apangin
    added
    enhancement
    on Apr 1, 2023
  2. apangin commented on Apr 1, 2023

    @apangin
    apangin
    on Apr 1, 2023
    CollaboratorAuthor
    More actions

    Linking #311 and #334

  3. apangin
    added a commit that references this issue on Apr 2, 2023

    #740: Profile CPU + Wall clock together

    ac2eabf
  4. apangin
    closed this as completedon Apr 4, 2023
  5. bric3 commented on Dec 11, 2025

    @bric3
    bric3
    on Dec 11, 2025
    More actions

    Linking this discussion : #1557

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.