Skip to content

AntPathMatcher creates many temporary objects [SPR-11258] #15883

@spring-projects-issues

Description

@spring-projects-issues

Robert Gay opened SPR-11258 and commented

AntPathMatcher.doMatch appears to get called many times on each request, and it makes two calls to StringUtils.tokenizeToStringArray on each call. It looks like (but I'm admittedly not 100% sure) that at least some of the tokenizing work is being duplicated on every request, and could be precomputed at startup, or cached as it is used.

The two screenshots show the number of objects collected by the garbage collector during the loading of a single url and all associated AJAX requests (some of which result in multiple callbacks to the server). Both loads were primed once without the profiler running so that the difference between the caching version and the non-caching version would be clearer.

single-page-load-unmodified-spring.png shows the results running an unmodified version of Spring 3.1.4.RELEASE, the modified version incorporates the included patch file AntPathMatcher.java.patch.

The patch is pretty naive, and just throws everything into the same cache - I expect there's a better way to achieve a similar result.

I haven't directly tested this against 3.2.x or 4.0.x, but I did visually examine the AntPathMatcher.doMatch code and this part of it seems to have not changed since 3.1.4.


Affects: 3.1.4, 3.2.6, 4.0 GA

Attachments:

Referenced from: commits ff26dfd

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions