You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2015/03/27 17:16:53 UTC
[jira] [Comment Edited] (SLING-4544) Performance: MessageFormat
shouldn't be used for logging in SlingRequestProgressTracker
[ https://issues.apache.org/jira/browse/SLING-4544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14384065#comment-14384065 ]
Felix Meschberger edited comment on SLING-4544 at 3/27/15 4:16 PM:
-------------------------------------------------------------------
The API defines MessageFormat pattern is supported. So to comply with the contract we have to do this.
Now, an option would be to have a private simple implementation for the 80-90% use case of just having \{9} style place holders. Once extending formatting is encountered the simple implementation could fall back to the real MessageFormat.
As to lazy formatting: Easy to do, but please don't. The reason is that you keep references to the args which may be objects. And by keeping them you prevent them from being garbage collected. And yes, I have been thinking about lazy formatting before and dropped the idea exactly for that reason.
was (Author: fmeschbe):
The API defines MessageFormat pattern is supported. So to comply with the contract we have to do this.
Now, an option would be to have a private simple implementation for the 80-90% use case of just having {9} style place holders. Once extending formatting is encountered the simple implementation could fall back to the real MessageFormat.
As to lazy formatting: Easy to do, but please don't. The reason is that you keep references to the args which may be objects. And by keeping them you prevent them from being garbage collected. And yes, I have been thinking about lazy formatting before and dropped the idea exactly for that reason.
> Performance: MessageFormat shouldn't be used for logging in SlingRequestProgressTracker
> ---------------------------------------------------------------------------------------
>
> Key: SLING-4544
> URL: https://issues.apache.org/jira/browse/SLING-4544
> Project: Sling
> Issue Type: Improvement
> Components: Engine
> Affects Versions: Engine 2.4.0
> Reporter: Joel Richard
> Labels: performance
> Attachments: Screen Shot 2015-03-25 at 10.42.05.png
>
>
> I am profiling an application where up to 5% of the rendering time is spent in MessageFormat.format for SlingRequestProgressTracker.log (see attached screenshot). Since the advanced capabilities of MessageFormat are not required here, it should be rather easy to implement a utility which supports \{x} as well but is much faster.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)