Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to improve performance optimization of AbstractHandlerMethodMapping mapping matching #34461

Open
conneyjoo opened this issue Feb 20, 2025 · 4 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@conneyjoo
Copy link

Hello

First of all, thank you for your great work on Spring-WebMVC. The request mapping mechanism has served developers well over the years, and I really appreciate the thoughtfulness behind its design.

In a project with a large number of variable-style APIs, i am observed performance bottlenecks due to the linear search approach in RequestMappingHandlerMapping. To address this issue, I tried a hierarchical path matching mechanism that organizes the path in a structured way to narrow the search scope by splitting the path into multiple layers using the "/" symbol and utilizing the hierarchical structure to optimize the lookup process. This approach showed good results in optimizing lookup performance.

I am looking forward to whether this approach is in line with Spring's design principles, and if so, I will cooperate on how to improve it together to ensure that it fits well with the existing ecosystem. If this idea resonates, I will be happy to further refine the proposal based on feedback.

Thank you.

This is the detailed design document, which contains the code implementation, unit test, AbstractHandlerMethodMapping and optimized comparison JHM Report

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 20, 2025
@bclozel
Copy link
Member

bclozel commented Feb 20, 2025

Hello @conneyjoo and thanks for the detailed proposal.
At one point I had an implementation for this but decided to not pursue because the performance degradation was too high when the application had fewer and simpler endpoints. I'm happy to revisit that decision. Did you compare against this case as well in your benchmarks?

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue in: web Issues in web modules (web, webmvc, webflux, websocket) labels Feb 20, 2025
@conneyjoo
Copy link
Author

Hello @conneyjoo and thanks for the detailed proposal. At one point I had an implementation for this but decided to not pursue because the performance degradation was too high when the application had fewer and simpler endpoints. I'm happy to revisit that decision. Did you compare against this case as well in your benchmarks?

Thank you very much for your attention. In this document, I have listed benchmarks for two different specifications. I'm not sure if they match the "fewer and simpler endpoints" scenario you mentioned. If not, I can easily run another benchmark based on your specifications.

The link above section 4 of the document.
4. Performance Testing
Test Specifications:
A: 2 controllers, 64 mappings
B: 5 controllers, 156 mappings

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 20, 2025
@bclozel
Copy link
Member

bclozel commented Feb 20, 2025

Can you share the implementation and JMH benchmark?

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 20, 2025
@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

3 participants