You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Platon Potapov (JIRA)" <ji...@apache.org> on 2011/06/13 15:00:51 UTC

[jira] [Created] (DIRMINA-838) Redundant AttributeKey allocation resulting in high garbage collector activity

Redundant AttributeKey allocation resulting  in high garbage collector activity
-------------------------------------------------------------------------------

                 Key: DIRMINA-838
                 URL: https://issues.apache.org/jira/browse/DIRMINA-838
             Project: MINA
          Issue Type: Improvement
          Components: Filter
    Affects Versions: 2.0.3
         Environment: java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
            Reporter: Platon Potapov


The classes CumulativeProtocolDecoder and ProtocolCodecFilter (there are others too, but these two are the important ones for our project) have members of type AttributeKey declared as:
    private final AttributeKey ENCODER = new AttributeKey(ProtocolCodecFilter.class, "encoder");

As can be seen, these are not static, so each time ProtocolCodecFilter is created, AttributeKey objects get created as well, which in turn involves creation of a lot of String and char[] objects. jProfiler indicates that AttributeKey is accountable for creation of about 85% of all Strings and char[] in runs of our project, so it makes a significant difference for us.

Is it OK for these attribute key objects to be singletons? If not, what would take to make them singletons?
Some of other MINA filters have AttributeKeys as static members (e.g. MdcInjectionFilter, SslFilter).

To summarize: the improvement being requested is to make the pre-defined AttributeKey objects static within classes such as CumulativeProtocolDecoder and ProtocolCodecFilter.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRMINA-838) Redundant AttributeKey allocation resulting in high garbage collector activity

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13048784#comment-13048784 ] 

Emmanuel Lecharny commented on DIRMINA-838:
-------------------------------------------

I have to check what kind of errors I had when I made this field a singleton. I must admit we were more focused on sme other major bugs in MINA, so I cowardly reverted my change...

In any case, we should be able to make this optionnal.

i'll investigate this point this week.

> Redundant AttributeKey allocation resulting  in high garbage collector activity
> -------------------------------------------------------------------------------
>
>                 Key: DIRMINA-838
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-838
>             Project: MINA
>          Issue Type: Improvement
>          Components: Filter
>    Affects Versions: 2.0.3
>         Environment: java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
>            Reporter: Platon Potapov
>
> The classes CumulativeProtocolDecoder and ProtocolCodecFilter (there are others too, but these two are the important ones for our project) have members of type AttributeKey declared as:
>     private final AttributeKey ENCODER = new AttributeKey(ProtocolCodecFilter.class, "encoder");
> As can be seen, these are not static, so each time ProtocolCodecFilter is created, AttributeKey objects get created as well, which in turn involves creation of a lot of String and char[] objects. jProfiler indicates that AttributeKey is accountable for creation of about 85% of all Strings and char[] in runs of our project, so it makes a significant difference for us.
> Is it OK for these attribute key objects to be singletons? If not, what would take to make them singletons?
> Some of other MINA filters have AttributeKeys as static members (e.g. MdcInjectionFilter, SslFilter).
> To summarize: the improvement being requested is to make the pre-defined AttributeKey objects static within classes such as CumulativeProtocolDecoder and ProtocolCodecFilter.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRMINA-838) Redundant AttributeKey allocation resulting in high garbage collector activity

Posted by "Platon Potapov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13048696#comment-13048696 ] 

Platon Potapov commented on DIRMINA-838:
----------------------------------------

AttributeKeys do get discarded; MINA leaks no memory. But our project creates a lot of connections (thousands per second), so the overhead of creating/discarding many AttributeKeys is tangible. In case AttributeKeys do not need to be unique per ProtocolCodecFilter, this hurts performance for no benefit.

However, I am not familiar with MINA well enough to assert that AttributeKeys can by design be singletons in this place - can they?
You said there were failures with having these being static - could it have been because AttributeKeys were being incorrectly used elsewhere (a latent bug)?


> Redundant AttributeKey allocation resulting  in high garbage collector activity
> -------------------------------------------------------------------------------
>
>                 Key: DIRMINA-838
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-838
>             Project: MINA
>          Issue Type: Improvement
>          Components: Filter
>    Affects Versions: 2.0.3
>         Environment: java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
>            Reporter: Platon Potapov
>
> The classes CumulativeProtocolDecoder and ProtocolCodecFilter (there are others too, but these two are the important ones for our project) have members of type AttributeKey declared as:
>     private final AttributeKey ENCODER = new AttributeKey(ProtocolCodecFilter.class, "encoder");
> As can be seen, these are not static, so each time ProtocolCodecFilter is created, AttributeKey objects get created as well, which in turn involves creation of a lot of String and char[] objects. jProfiler indicates that AttributeKey is accountable for creation of about 85% of all Strings and char[] in runs of our project, so it makes a significant difference for us.
> Is it OK for these attribute key objects to be singletons? If not, what would take to make them singletons?
> Some of other MINA filters have AttributeKeys as static members (e.g. MdcInjectionFilter, SslFilter).
> To summarize: the improvement being requested is to make the pre-defined AttributeKey objects static within classes such as CumulativeProtocolDecoder and ProtocolCodecFilter.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRMINA-838) Redundant AttributeKey allocation resulting in high garbage collector activity

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13048584#comment-13048584 ] 

Emmanuel Lecharny commented on DIRMINA-838:
-------------------------------------------

Interestng question. It has been changed a while back to be static, but we gor some failures back then. 

Any reason why you have so any AttributeKeys stuck in memory ? They should be discarded as soon as the session is terminated.

> Redundant AttributeKey allocation resulting  in high garbage collector activity
> -------------------------------------------------------------------------------
>
>                 Key: DIRMINA-838
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-838
>             Project: MINA
>          Issue Type: Improvement
>          Components: Filter
>    Affects Versions: 2.0.3
>         Environment: java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
>            Reporter: Platon Potapov
>
> The classes CumulativeProtocolDecoder and ProtocolCodecFilter (there are others too, but these two are the important ones for our project) have members of type AttributeKey declared as:
>     private final AttributeKey ENCODER = new AttributeKey(ProtocolCodecFilter.class, "encoder");
> As can be seen, these are not static, so each time ProtocolCodecFilter is created, AttributeKey objects get created as well, which in turn involves creation of a lot of String and char[] objects. jProfiler indicates that AttributeKey is accountable for creation of about 85% of all Strings and char[] in runs of our project, so it makes a significant difference for us.
> Is it OK for these attribute key objects to be singletons? If not, what would take to make them singletons?
> Some of other MINA filters have AttributeKeys as static members (e.g. MdcInjectionFilter, SslFilter).
> To summarize: the improvement being requested is to make the pre-defined AttributeKey objects static within classes such as CumulativeProtocolDecoder and ProtocolCodecFilter.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira