<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq" -->

---
title: [Java][Profiling] Async-profiler - manual by use cases
description: A deep, use-case-driven manual on async-profiler covering how to run it (CLI, agentpath, Java API, JMH, AP-Loader, IntelliJ), interpreting flame graphs, and...
canonical: https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: [Java][Profiling] Async-profiler - manual by use cases | daily.dev
og:description: A deep, use-case-driven manual on async-profiler covering how to run it (CLI, agentpath, Java API, JMH, AP-Loader, IntelliJ), interpreting flame graphs, and...
og:url: https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq
og:image: https://api.daily.dev/og/posts/XD3XfauHQ.png
og:image:alt: [Java][Profiling] Async-profiler - manual by use cases
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# [Java][Profiling] Async-profiler - manual by use cases

**[Krzysztof Ślusarski](https://daily.dev/sources/krzysztofslusarski)** · 73 min read · 0 upvotes · 0 comments

## Summary

A deep, use-case-driven manual on async-profiler covering how to run it (CLI, agentpath, Java API, JMH, AP-Loader, IntelliJ), interpreting flame graphs, and diagnosing real problems: wall-clock vs CPU mode pitfalls, HTTP connection pool starvation, Hibernate eager-fetch dirty checking overhead, matrix-multiplication cache behavior, TLAB and humongous object allocation, memory leak detection via heap-after-GC charts and live object profiling, lock contention in ConcurrentHashMap, and time-to-safepoint analysis. Each section pairs a synthetic Spring Boot demo app with real JFR output and command-line examples.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://krzysztofslusarski.github.io/2022/12/12/async-manual.html>

## Questions this post answers

### Why does CPU profiling mode mislead me when diagnosing slow REST calls in a Spring Boot app?

CPU mode only shows time spent consuming the processor, so it misses time spent waiting on I/O like sockets or connection pools. In one demonstrated case, a method flagged as the top CPU consumer actually accounted for only about 4% of real request time, while over 95% was spent blocked in SocketInputStream.read() or waiting for a connection from an Apache HTTP Client pool. Wall-clock mode (-e wall) reveals the true time breakdown that CPU mode hides.

_Anyone chasing latency instead of CPU usage can dig into wall-clock profiling breakdowns like this via daily.dev._

### Why is Spring Data JPA's existsById() or findById() so CPU-heavy when an entity has eager-fetched collections?

When an entity uses fetch = FetchType.EAGER with @OneToMany, loading it by id also loads all sub-entities into the Hibernate session, and Hibernate's default AUTO flush mode then spends CPU time scanning all loaded entities for dirty-checking before flushing. This overhead showed up as 95% of CPU time in a profiled findById() call even though the code only toggled a boolean flag, and could be avoided with a targeted update query instead of loading the full entity graph.

_Developers debugging unexpected Hibernate CPU spikes can trace flush and fetch behavior using profiling breakdowns shared on daily.dev._

### How can I find where humongous object allocations are coming from in a G1 GC Java heap?

Use async-profiler's alloc mode to capture a JFR file, then filter jdk.ObjectAllocationOutsideTLAB events for objects sized at least half the G1 region size (regions range 1MB-32MB, capped near 2048 regions). Matching the allocationSize field against humongous region sizes reported in GC logs (via -Xlog:gc+humongous=trace) pinpoints the exact stack trace, such as a Spring CommonsRequestLoggingFilter allocating a fixed 5MB byte array per request regardless of actual payload size.

_Engineers tracking down G1 humongous allocation slowdowns can follow allocation-profiling workflows like this on daily.dev._

## Similar posts on daily.dev

- [foojay – a place for friends of OpenJDK](https://daily.dev/posts/foojay-a-place-for-friends-of-openjdk-lwyzoctef) · Foojay.io · 0 upvotes · 0 comments
- [Unbiased Java CPU profiling with JFR in JDK 25](https://daily.dev/posts/unbiased-java-cpu-profiling-with-jfr-in-jdk-25-q2jelifnz) · Datadog · 3 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#spring-boot](https://daily.dev/tags/spring-boot)

[View this post on daily.dev](https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"[Java][Profiling] Async-profiler - manual by use cases","url":"https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq"},"datePublished":"2026-09-27T07:26:30.701Z","dateModified":"2026-09-27T07:27:59.169Z","description":"A deep, use-case-driven manual on async-profiler covering how to run it (CLI, agentpath, Java API, JMH, AP-Loader, IntelliJ), interpreting flame graphs, and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0181ef3f6ce39dc3a902fed06952a04b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0181ef3f6ce39dc3a902fed06952a04b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Krzysztof Ślusarski","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Krzysztof Ślusarski","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/krzysztofslusarski"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,spring-boot","timeRequired":"PT73M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Krzysztof Ślusarski","item":"https://daily.dev/sources/krzysztofslusarski"},{"@type":"ListItem","position":3,"name":"[Java][Profiling] Async-profiler - manual by use cases"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/java-profiling-async-profiler---manual-by-use-cases-xd3xfauhq#faq","mainEntity":[{"@type":"Question","name":"Why does CPU profiling mode mislead me when diagnosing slow REST calls in a Spring Boot app?","acceptedAnswer":{"@type":"Answer","text":"CPU mode only shows time spent consuming the processor, so it misses time spent waiting on I/O like sockets or connection pools. In one demonstrated case, a method flagged as the top CPU consumer actually accounted for only about 4% of real request time, while over 95% was spent blocked in SocketInputStream.read() or waiting for a connection from an Apache HTTP Client pool. Wall-clock mode (-e wall) reveals the true time breakdown that CPU mode hides. Anyone chasing latency instead of CPU usage can dig into wall-clock profiling breakdowns like this via daily.dev."}},{"@type":"Question","name":"Why is Spring Data JPA's existsById() or findById() so CPU-heavy when an entity has eager-fetched collections?","acceptedAnswer":{"@type":"Answer","text":"When an entity uses fetch = FetchType.EAGER with @OneToMany, loading it by id also loads all sub-entities into the Hibernate session, and Hibernate's default AUTO flush mode then spends CPU time scanning all loaded entities for dirty-checking before flushing. This overhead showed up as 95% of CPU time in a profiled findById() call even though the code only toggled a boolean flag, and could be avoided with a targeted update query instead of loading the full entity graph. Developers debugging unexpected Hibernate CPU spikes can trace flush and fetch behavior using profiling breakdowns shared on daily.dev."}},{"@type":"Question","name":"How can I find where humongous object allocations are coming from in a G1 GC Java heap?","acceptedAnswer":{"@type":"Answer","text":"Use async-profiler's alloc mode to capture a JFR file, then filter jdk.ObjectAllocationOutsideTLAB events for objects sized at least half the G1 region size (regions range 1MB-32MB, capped near 2048 regions). Matching the allocationSize field against humongous region sizes reported in GC logs (via -Xlog:gc+humongous=trace) pinpoints the exact stack trace, such as a Spring CommonsRequestLoggingFilter allocating a fixed 5MB byte array per request regardless of actual payload size. Engineers tracking down G1 humongous allocation slowdowns can follow allocation-profiling workflows like this on daily.dev."}}]}
```

