Skip to content

Avoid costly stack walk on every task start in AxonTimeLimitedTask#4635

Open
hjohn wants to merge 1 commit into
mainfrom
enhancement/avoid-stack-walk-timeout-task
Open

Avoid costly stack walk on every task start in AxonTimeLimitedTask#4635
hjohn wants to merge 1 commit into
mainfrom
enhancement/avoid-stack-walk-timeout-task

Conversation

@hjohn

@hjohn hjohn commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thread.getStackTrace() was called on every start() to capture the caller class name for log trimming, even though that information is only used when a timeout fires. Callers already know their own class, so the name is now passed as a Class<?> constructor parameter and stored once. The stack frame comparison is also tightened from a substring search on toString() to an exact match on getClassName().

Resolves #4637

@hjohn hjohn requested a review from a team as a code owner June 4, 2026 15:40
@hjohn hjohn requested review from CodeDrivenMitch, MateuszNaKodach, hatzlj and smcvb and removed request for a team June 4, 2026 15:40
@hjohn hjohn self-assigned this Jun 4, 2026
@hjohn hjohn added the Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. label Jun 4, 2026
@hjohn hjohn added this to the Release 5.2.0 milestone Jun 4, 2026
int warningThreshold,
int warningInterval) {
int warningInterval,
Class<?> callerClass) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is technically a breaking change as this class is not marked internal. Maybe we should overload this and use a sensible default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can, except no default will work to cut the stack trace short I think, so if you fail to specify a suitable value, you'll get the whole trace :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's fair. It's just to not break the contract, but I don't think it will actually happen

Thread.getStackTrace() was called on every start() to capture the caller
class name for log trimming, even though that information is only used
when a timeout fires. Callers already know their own class, so the name
is now passed as a Class<?> constructor parameter and stored once.
The stack frame comparison is also tightened from a substring search on
toString() to an exact match on getClassName().
@hjohn hjohn force-pushed the enhancement/avoid-stack-walk-timeout-task branch from c92ba6c to 41f7e85 Compare June 5, 2026 08:50

@CodeDrivenMitch CodeDrivenMitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance regression AxonTimeLimitedTask

2 participants