Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Avoid using ThreadMXBean to retrieve the name of the thread #214

Closed

Conversation

loicmathieu
Copy link
Contributor

Fixes #213

I didn't do any performance test, I would assume that as the name of the threads are cached it's OK to gather them in a slower manner.

I didn't check all the code for possible usage of JMX so this PR will not make the full library GraalVM compliant. Only the JUL Handler (as I use it) works.

if (threadInfo != null) {
threadName = threadInfo.getThreadName();
}
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
Copy link
Owner

Choose a reason for hiding this comment

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

getAllStackTraces() is quite expensive. Given that we have a cache in place, we should soften the actual impact.

We should be able to optimize for the default logger arrangement. Typically, log handlers are called on the same thread as the logging happens. Therefore, we should call Thread.currentThread().getId() first to inspect whether we need to obtain all threads or whether we can resolve the thread without further do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mp911de mp911de added this to the 1.14.0 milestone Dec 3, 2019
@mp911de mp911de added the type: enhancement A general enhancement label Dec 3, 2019
mp911de pushed a commit that referenced this pull request Dec 3, 2019
mp911de added a commit that referenced this pull request Dec 3, 2019
Add author tags. Move currentThread lookup to caching section.

Original pull request: #214.
@mp911de
Copy link
Owner

mp911de commented Dec 3, 2019

Thanks for your contribution. That's merged and polished now.

@mp911de mp911de closed this Dec 3, 2019
@loicmathieu loicmathieu deleted the feat/remove-jmx-usage branch December 5, 2019 14:29
@mp911de mp911de changed the title feat: avoid using ThreadMXBean to retrieve the name of the thread Avoid using ThreadMXBean to retrieve the name of the thread Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for GraalVM Native Image using java.util.logging
2 participants