Skip to content

Optimize DefaultUserDestinationResolver.resolveDestination() [SPR-15602] #20161

@spring-projects-issues

Description

@spring-projects-issues

Christoph Dreis opened SPR-15602 and commented

Hey,

I noticed in some of my stresstests that DefaultUserDestinationResolver.resolveDestination() was popping up quite often as a hot method and found some possible improvements.

The attached PR restructures the code of DefaultUserDestinationResolver.resolveDestination() or more correctly DefaultUserDestinationResolver.parse() in the following ways:

  • Allow parse() to be inlined by extracting the logic of parsing subscription messages and normal messages to dedicated private methods.
    • (Previous) DefaultUserDestinationResolver::parse (458 bytes) hot method too big
    • (After) DefaultUserDestinationResolver::parse (95 bytes) inline (hot)
  • Make the sourceDestination of a message part of the ParseResult in order to avoid getting it twice in the chain
  • Move the call to fetch the Principal of a Message only to the parts where it is needed
  • ...

Please find the results of the JMH benchmarks attached. In a nutshell, we can see no regression (on the contrary) for messages of type SUBSCRIBE/UNSUBSCRIBE/MESSAGE and almost doubled performance for HEARTBEAT messages.

Let me know what you think.

Cheers,
Christoph


Affects: 4.3.8

Attachments:

Referenced from: pull request #1439, and commits d3e3365, 0ef1623, 6aeb8ef

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions