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

Jordan West edited comment on CASSANDRA-15213 at 1/13/20 9:27 PM:
------------------------------------------------------------------

Using {{addAndGet}} I see performance comparable to 3.0 and prior to 
CASSANDRA-14281.

{codee}
15213 (4 core, 4 stripes, striping & linear search, addAndGet):

     [java] Benchmark                                       Mode  Cnt        
Score        Error  Units
     [java] LatencyTrackingBench.benchInsertToDEHR         thrpt    5  
5742550.865 ± 256043.651  ops/s
     [java] LatencyTrackingBench.benchLatencyMetricsWrite  thrpt    5  
1979885.731 ± 117381.276  ops/s

{/code}

Here is how I implemented update bucket in case I missed something
{code:java}
    public void updateBucket(AtomicLongArray buckets, int index, long value)
    {
        int stripe = (int) (Thread.currentThread().getId() & (nStripes - 1));
        buckets.addAndGet(stripedIndex(index, stripe), value);
    }
{code}


was (Author: jrwest):
Using {{addAndGet}} I see performance comparable to 3.0 and prior to 
CASSANDRA-14281.

{codee}
15213 (4 core, 4 stripes, striping & linear search, addAndGet):

     [java] Benchmark                                       Mode  Cnt        
Score        Error  Units
     [java] LatencyTrackingBench.benchInsertToDEHR         thrpt    5  
5742550.865 ± 256043.651  ops/s
     [java] LatencyTrackingBench.benchLatencyMetricsWrite  thrpt    5  
1979885.731 ± 117381.276  ops/s

{/code}

Here is how I implemented update bucket in case I missed something
{code:java}
    public void updateBucket(AtomicLongArray buckets, int index, long value)
    {
        int stripe = (int) (Thread.currentThread().getId() & (nStripes - 1));
        buckets.addAndGet(stripedIndex(index, stripe), value);
    }
{/code}

> DecayingEstimatedHistogramReservoir Inefficiencies
> --------------------------------------------------
>
>                 Key: CASSANDRA-15213
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15213
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Observability/Metrics
>            Reporter: Benedict Elliott Smith
>            Assignee: Jordan West
>            Priority: Normal
>             Fix For: 4.0-beta
>
>
> * {{LongAdder}} introduced to trunk consumes 9MiB of heap without user 
> schemas, and this will grow significantly under contention and user schemas 
> with many tables.  This is because {{LongAdder}} is a very heavy class 
> designed for single contended values.  
>  ** This can likely be improved significantly, without significant loss of 
> performance in the contended case, by simply increasing the size of our 
> primitive backing array and providing multiple buckets, with each thread 
> picking a bucket to increment, or simply multiple backing arrays.  Probably a 
> better way still to do this would be to introduce some competition detection 
> to the update, much like {{LongAdder}} utilises, that increases the number of 
> backing arrays under competition.
>  ** To save memory this approach could partition the space into chunks that 
> are likely to be updated together, so that we do not need to duplicate the 
> entire array under competition.
>  * Similarly, binary search is costly and a measurable cost as a share of the 
> new networking work (without filtering it was > 10% of the CPU used overall). 
>  We can compute an approximation floor(log2 n / log2 1.2) extremely cheaply, 
> to save the random memory access costs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to