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 NMethod type check by apangin · Pull Request #1701 · async-profiler/async-profiler

Conversation

@apangin

@apangin apangin commented Mar 18, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator

Description

Currently, NMethod::isInterpreter, isNMethod, isStub and isVTableStub are implemented by comparing the name using strcmp/strncmp. We can make the check faster by inlining string comparison.

Also, for interpreted frames, instead of checking NMethod name we could check NMethod pointer itself, because Interpreter is a singleton.

On some benchmarks, improvement in average stack walking speed can reach 10% as measured by features=stats:

Benchmark Before After %
spring-petclinic 13042 11656 -10.6%
renaissance dotty 18490 16322 -11.7%

Related issues

#1662

Motivation and context

This change was inspired by @fandreuz's PR: #1662
However, what I'm not happy about in that implementation is that it makes isType methods stateful. I found that the actual performance issue was not in the string comparison itself, but rather in an indirect call to a standard library function. I went further and replaced isInterpreter with a single pointer comparison, since HotSpot has exactly one Code Blob with the name Interpreter.


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.

jbachorik reacted with hooray emoji
All reactions
  • 🎉 1 reaction
apangin added 3 commits March 18, 2026 01:45
@apangin
Improve stack walking speed by optimizing nmethod name comparison
06bf08a
@apangin
Updated includes
f22a28b
@apangin
Simplified condition
58c4aa3
@apangin apangin mentioned this pull request Mar 18, 2026
Optimize strcmp calls for VM stackwalker #1662
Closed
apangin
apangin commented Mar 18, 2026
View reviewed changes
Comment thread src/stackWalker.cpp
anchor = NULL;
}

if (nm->isNMethod()) {

@apangin apangin Mar 18, 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.

No actual changes; just swapped nm->isInterpreter() and nm->isNMethod() branches.

Sorry, something went wrong.

Uh oh!

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

fandreuz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
fandreuz
fandreuz approved these changes Mar 18, 2026
View reviewed changes
@apangin
apangin merged commit cc0eab1 into master Mar 18, 2026
78 of 79 checks passed

Uh oh!

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

@apangin
apangin deleted the nmethod-type branch March 18, 2026 18:06
@github-actions github-actions Bot mentioned this pull request Mar 19, 2026
Upstream async-profiler changes detected (2026-03-19) DataDog/java-profiler#421
Closed
@jbachorik jbachorik mentioned this pull request Mar 19, 2026
Port async-profiler#1701: optimize nmethod type checks DataDog/java-profiler#423
Merged
1 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@fandreuz fandreuz fandreuz approved these changes
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.

2 participants

@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.