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 — Optimize wall clock profiling · Issue #1007 · async-profiler/async-profiler

Optimize wall clock profiling #1007

New issue
Copy link
New issue
Copy link
Closed
#1008
Closed
Optimize wall clock profiling#1007
#1008
Copy link
Labels
enhancement

Description

@apangin
apangin
opened on Sep 25, 2024
Issue body actions

Describe the feature

Wall clock profiling mode (-e wall) is currently implemented by a dedicated thread periodically sampling all application threads, regardless of their status. This means, if an application has 1000 threads and wall clock profiler runs with 100ms interval, profiler will record 10K samples per second, sending 10K signals and writing about 150kB data every second. This may cause notable performance overhead, both in CPU usage (signals are expensive) and in JFR file size.

In wall clock mode, most of the sampled threads are sleeping, e.g., idle thread pools waiting for incoming tasks. Signals will awake them, causing even more overhead by letting kernel manage threads that would be otherwise intact.

We can significantly reduce impact of wall clock profiling if we skip sampling threads that are known to be idle.

Use Case

  • Lower wall clock profiling overhead for applications with thousands of threads.
  • Make smaller wall clock intervals feasible, thus improving profile accuracy.
  • Reduce size of JFR recordings when wall clock mode is enabled.

Proposed Solution

After sampling a thread in IDLE state, record its total CPU usage.
Next time, if CPU usage of this thread has not changed, we will not sample it again, considering the thread stays IDLE at the very same location we've seen it before. We will start sampling this thread again if its CPU time changes or after 1000 skipped iterations, whatever occurs first.

Introduce new JFR event profiler.WallClockSample having all the fields of jdk.ExecutionSample event plus a new int samples field containing a counter for skipped samples. Instead of recording 500 similar ExecutionSample events for a sleeping thread, we will issue only one ExecutionSample event and one WallClockSample event with samples=499.
Amend JfrReader to seamlessly handle WallClockSample events as if there was a single event per sample as before. Nothing should change from user's perspective; all implementation details should be encapsulated.

If for some reason previous behavior is desired, wall clock optimization can be disabled by adding nobatch profiler argument.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change
Reacted by Okada Haruki, KUBOTA Yuji, Sergey Tselovalnikov, Steve Rao, Petr Portnov | PROgrm_JARvis and Ivo Anjo

Activity

  1. apangin
    added
    enhancement
    on Sep 25, 2024
  2. apangin
    added 2 commits that reference this issue on Sep 25, 2024

    #1007: Optimize wall clock profiling

    48def27

    #1007: Optimize wall clock profiling

    f53bfd4
  3. apangin
    closed this as completedin #1008on Sep 26, 2024
  4. apangin
    added a commit that references this issue on Nov 2, 2024

    #1007: Use ExecutionSample event for CPU profiling and WallClockSampl…

    870833b
  5. zhangzhen91 commented on Apr 20, 2025

    @zhangzhen91
    zhangzhen91
    on Apr 20, 2025
    More actions

    Understood. Thank you for these optimizations - they've been very helpful.

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.