You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by franz1981 <gi...@git.apache.org> on 2017/08/21 13:19:11 UTC

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

GitHub user franz1981 opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1477

    ARTEMIS-1356 Avoid allocations and atomic operations to recognize handler's thread

    Uses a cached marker instance to recognize an handler's thread, avoiding allocations and atomic operations.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/franz1981/activemq-artemis gc_free_recursion

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/1477.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1477
    
----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1477#discussion_r134460108
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java ---
    @@ -159,7 +158,11 @@
     
        private final boolean direct;
     
    -   private static final ThreadLocal<AtomicBoolean> inHandler = ThreadLocal.withInitial(AtomicBoolean::new);
    +   //marker instance used to recognize if a thread is performing a packet handling
    +   private static final Object DUMMY = Boolean.TRUE;
    --- End diff --
    
    Why not make this a Boolean type?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1477: ARTEMIS-1356 Avoid allocations and atomic oper...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1477
  
    @clebertsuconic 
    Here:
    https://github.com/apache/activemq-artemis/blob/e81c8c26d02f156e75fe03cb8cc8ad92e4bca30e/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java#L231
    
    On each first ThreadLocal::get call from a different thread, the ThreadLocal allocates and cache (locally to the thread) a new AtomicBoolean.
    In addition, the AtomicBoolean::get and AtomicBoolean::set operations can be avoided to "mark" the handler thread...



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1477#discussion_r134469939
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java ---
    @@ -159,7 +158,11 @@
     
        private final boolean direct;
     
    -   private static final ThreadLocal<AtomicBoolean> inHandler = ThreadLocal.withInitial(AtomicBoolean::new);
    +   //marker instance used to recognize if a thread is performing a packet handling
    +   private static final Object DUMMY = Boolean.TRUE;
    +
    +   //a thread that has its thread-local map populated with DUMMY is performing a packet handling
    +   private static final ThreadLocal<Object> inHandler = new ThreadLocal<>();
    --- End diff --
    
    Fair doosies. Maybe a nit if that's the case why not make it Object() this way stops any inference the boolean is being used as a true false flag. Which I'll be honest is what I was thinking this was.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1477#discussion_r134460501
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java ---
    @@ -159,7 +158,11 @@
     
        private final boolean direct;
     
    -   private static final ThreadLocal<AtomicBoolean> inHandler = ThreadLocal.withInitial(AtomicBoolean::new);
    +   //marker instance used to recognize if a thread is performing a packet handling
    +   private static final Object DUMMY = Boolean.TRUE;
    +
    +   //a thread that has its thread-local map populated with DUMMY is performing a packet handling
    +   private static final ThreadLocal<Object> inHandler = new ThreadLocal<>();
    --- End diff --
    
    ditto re Boolean


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1477#discussion_r134461348
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java ---
    @@ -159,7 +158,11 @@
     
        private final boolean direct;
     
    -   private static final ThreadLocal<AtomicBoolean> inHandler = ThreadLocal.withInitial(AtomicBoolean::new);
    +   //marker instance used to recognize if a thread is performing a packet handling
    +   private static final Object DUMMY = Boolean.TRUE;
    +
    +   //a thread that has its thread-local map populated with DUMMY is performing a packet handling
    +   private static final ThreadLocal<Object> inHandler = new ThreadLocal<>();
    --- End diff --
    
    Because it is not needed to be a Boolean: it is just a marker, so even a DUMMY = new Object() could be used instead of Boolean to make it works.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1477: ARTEMIS-1356 Avoid allocations and atom...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/1477


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---