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

Logging performance bottleneck in DispatcherServlet / UrlPathHelper [SPR-7269] #11928

Closed
spring-projects-issues opened this issue Jun 7, 2010 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kenny MacLeod opened SPR-7269 and commented

DispatcherServlet.getLastModified constructs a new UrlPathHelper object each time it is called, which in turn calls LogFactory.getLog. Considering that DispatcherServlet.getLastModified is on the critical execution path, this adds up to a small but significant performance bottleneck.

From what I can see of UrlPathHelper, it should be threadsafe, and the DispatcherServlet should be able to keep a single instance as an object field, rather than instantiating a new one each time.


Affects: 3.0.2

Referenced from: commits eb3a3a6

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Fortunately we already changed that Log field to static for 3.0.3, so the overhead shouldn't be too bad anymore. We can certainly also use a shared UrlPathHelper in DispatcherServlet. That said - we're only creating UrlPathHelpers for debug logging as far as I can see, i.e. only when debug logging is enabled - so is it really a bottleneck in production?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Kenny MacLeod commented

Ah yes, I didn't notice the isDebugEnabled() condition. You're quite right, this is only causing me a bottleneck because I was profiling in development, with debug enabled,w hich is rather self-deteating :)

Anyway, the static field in 3.0.3 should achieve the same end result.

Thanks.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

In any case, we are reusing a shared UrlPathHelper instance in DispatcherServlet now. Makes sense even for debug logging.

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.3 milestone Jan 11, 2019
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) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants