commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucas Pouzac (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (POOL-277) Monitor contention at BaseGenericObjectPool
Date Fri, 19 Sep 2014 08:25:34 GMT

    [ https://issues.apache.org/jira/browse/POOL-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14140175#comment-14140175
] 

Lucas Pouzac commented on POOL-277:
-----------------------------------

Ok I try this. I update StatStore for mean calculation and I use lazySet because is not a
critical information.

{code:java}
        public void add(long value) {
            // lock free ringbuffer
            int i = index.getAndIncrement() & (size - 1);
            values.lazySet(i, value);
            ...
        }

        public long getMean() {
            long sum = 0;
            int counter = 0;
            for (int i = 0; i < size; i++) {
                long value = values.get(i);
                if (value != -1) {
                    sum += value;
                    counter++;
                }
            }
            return sum / counter;
        }
{code}

It's ok for you ?

> Monitor contention at BaseGenericObjectPool
> -------------------------------------------
>
>                 Key: POOL-277
>                 URL: https://issues.apache.org/jira/browse/POOL-277
>             Project: Commons Pool
>          Issue Type: Improvement
>    Affects Versions: 2.2
>            Reporter: Lucas Pouzac
>              Labels: concurrency, performance
>             Fix For: 2.3
>
>         Attachments: monitor_contention_basegenericobjectpool.png, monitor_contention_basegenericobjectpool_after_pull_request.png,
nonlockstats.diff
>
>
> Updating JMX causes synchronization while the service is secondary. See screenshot.
> I create a Pull Request [#1|https://github.com/apache/commons-pool/pull/1].



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message