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 — #1406, #1756: Parse only essential libraries at load time by apangin · Pull Request #1769 · async-profiler/async-profiler

Conversation

@apangin

@apangin apangin commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Description

Symbols::parseLibraries() gets a new essential_only mode that parses only the libraries required at agent load time: libjvm, libj9*, and async-profiler itself.

Related issues

  • Fixes JVM application pauses when using asprof #1406
  • Fixes Runtime attach fails on JVMs with many native libraries #1756

Motivation and context

LateInitializer runs as part of dlopen() when the agent is loaded. Parsing all shared libraries there has two problems:

  • In a process with many/large libraries, dlopen() runs too long on a thread that cannot reach a safepoint, causing a long time-to-safepoint pause (JVM application pauses when using asprof #1406).
  • When more than MAX_NATIVE_LIBS (2048) libraries are loaded, the scan may exhaust the limit before reaching libjvm, so the agent fails to attach with "JVM does not support Tool Interface" (Runtime attach fails on JVMs with many native libraries #1756).

Parsing only the essential libraries makes agent load fast and guarantees libjvm is always parsed. Libraries parsed at load time are remembered, so Profiler::start() does not parse them again. libj9* is included so that OpenJ9 symbols remain available in VM::init() as before.

How has this been tested?

  • CI
  • Manual: dynamic attach and -agentpath at startup; no dynamic-agent warning on JDK 21+
  • Reproduced Runtime attach fails on JVMs with many native libraries #1756 with a test app that loads 2100 extra libraries: the old build fails to attach, the new build attaches instantly and profiles correctly

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.

All reactions
@apangin
#1406, #1756: Parse only essential libraries at load time
67d6f87
@apangin apangin mentioned this pull request Jul 12, 2026
Runtime attach fails on JVMs with many native libraries #1756
Closed
@github-actions

github-actions Bot commented Jul 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

linux-x64

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 81.72 81.72 +0.00 +0.00%
bin/jfrconv 136.40 136.40 +0.00 +0.00%
lib/libasyncProfiler.so 587.70 587.77 +0.06 +0.01%

linux-arm64

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 89.59 89.59 +0.00 +0.00%
bin/jfrconv 136.40 136.40 +0.00 +0.00%
lib/libasyncProfiler.so 610.06 606.09 -3.97 -0.65%

macos

File Base (KiB) Treatment (KiB) Delta (KiB) % Change
bin/asprof 116.74 116.74 +0.00 +0.00%
bin/jfrconv 136.40 136.40 +0.00 +0.00%
lib/libasyncProfiler.dylib 984.45 984.48 +0.03 +0.00%
All reactions

Sorry, something went wrong.

Uh oh!

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

@apangin apangin mentioned this pull request Jul 12, 2026
Fix issue where asprof prevents safe points for a long time #1423
Closed
Baraa-Hasheesh
Baraa-Hasheesh reviewed Jul 12, 2026
View reviewed changes

@Baraa-Hasheesh Baraa-Hasheesh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks good to me, one small suggestion related to zing support

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/symbols_linux.cpp Outdated
}

const char* base_name = strrchr(file, '/');
return base_name != NULL && (strncmp(base_name + 1, "libjvm.", 7) == 0 || strncmp(base_name + 1, "libj9", 5) == 0);

@Baraa-Hasheesh Baraa-Hasheesh Jul 12, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote to also give priority to some zing libs as well

https://github.com/async-profiler/async-profiler/blob/master/src/cpuEngine.cpp#L70

If the profiler is run with Zing it possible to hit the "Could not set pthread hook" error due to the fact that "libazsys" was never parsed

Sorry, something went wrong.

Uh oh!

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

All reactions

@apangin apangin Jul 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. I remember about Zing libraries, but they are not a problem as far as I can see, since CpuEngine::setupThreadHook() is called from Profiler::start -> _engine->start() after the full library scan is made in Profiler::start(). Or am I missing something?

Sorry, something went wrong.

Uh oh!

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

All reactions

@Baraa-Hasheesh Baraa-Hasheesh Jul 12, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that due to the 2048 lib limit it's possible that this library is never parsed & skipped due to the mentioned limit

So #1756 won't be fixed

Sorry, something went wrong.

Uh oh!

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

All reactions

@Baraa-Hasheesh Baraa-Hasheesh Jul 12, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean that in the full scan, this lib is at the end of the list so it might be skipped

Sorry, something went wrong.

Uh oh!

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

All reactions

@apangin apangin Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's true. I've added libazsys to the early parsing phase too. Thanks for the right call!

Sorry, something went wrong.

Uh oh!

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

Baraa-Hasheesh reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@apangin apangin Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in symbols_macos.cpp is not really needed (no Zing on macOS), but it's harmless - I added it to keep files in sync.

Sorry, something went wrong.

Uh oh!

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

All reactions

@Baraa-Hasheesh Baraa-Hasheesh Jul 12, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in symbols_macos.cpp is not really needed (no Zing on macOS), but it's harmless - I added it to keep files in sync.

Was going to raise that, but yes I agree keeping the files in sync looks better & easier to understand the overall purpose

Sorry, something went wrong.

Uh oh!

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

All reactions
@apangin
Pre-parse libazsys as an essential library
b998242
@apangin
apangin merged commit 589e9c8 into master Jul 13, 2026
92 of 97 checks passed

Uh oh!

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

@apangin
apangin deleted the load-time-parsing branch July 13, 2026 16:04
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
Upstream async-profiler changes detected (2026-07-14) DataDog/java-profiler#657
Open
@zhumengzhu zhumengzhu mentioned this pull request Sep 8, 2026
Upgrade the bundled async-profiler to v4.5 to fix long JVM pauses when loading/attaching the profiler (async-profiler issue 1406) alibaba/arthas#3266
Open
1 task done
@hengyunabc hengyunabc mentioned this pull request Sep 8, 2026
Upgrade async-profiler to 4.5 alibaba/arthas#3267
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@Baraa-Hasheesh Baraa-Hasheesh Baraa-Hasheesh 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.

Runtime attach fails on JVMs with many native libraries JVM application pauses when using asprof

Uh oh!

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

2 participants

@apangin @Baraa-Hasheesh
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.