[
https://issues.apache.org/jira/browse/HBASE-16648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15505739#comment-15505739
]
Duo Zhang edited comment on HBASE-16648 at 9/20/16 6:20 AM:
------------------------------------------------------------
https://github.com/Apache9/microbench/tree/master/src/main/java/com/xiaomi/infra/microbench/compute
There is no contention for the first run, and may have some contentions for the
second 10 threads run.
{noformat}
./bin/run.sh -f 1 .*IATest.*
Benchmark Mode Cnt Score Error Units
CIATest.test thrpt 20 867.720 ± 0.233 ops/s
PIATest.test thrpt 20 1796.693 ± 39.908 ops/s
./bin/run.sh -f 1 -t 10 .*IATest.*
Benchmark Mode Cnt Score Error Units
CIATest.test thrpt 20 3452.054 ± 44.537 ops/s
PIATest.test thrpt 20 12101.279 ± 7.215 ops/s
{noformat}
The putIfAbsent version of computeIfAbsent is much faster. So I think we should
use the computeIfAbsent in ConcurrentMap instead of ConcurrentHashMap as for us
the creation is usually cheap.
And in fact, it does not recommend to do a heavy operation in the
mappingFunction of computeIfAbsent.. Then I do not see the necessity of
reimplementing this method in ConcurrentHashMap...
was (Author: apache9):
https://github.com/Apache9/microbench/tree/master/src/main/java/com/xiaomi/infra/microbench/compute
{noformat}
./bin/run.sh -f 1 .*IATest.*
Benchmark Mode Cnt Score Error Units
CIATest.test thrpt 20 867.720 ± 0.233 ops/s
PIATest.test thrpt 20 1796.693 ± 39.908 ops/s
./bin/run.sh -f 1 -t 10 .*IATest.*
Benchmark Mode Cnt Score Error Units
CIATest.test thrpt 20 3452.054 ± 44.537 ops/s
PIATest.test thrpt 20 12101.279 ± 7.215 ops/s
{noformat}
The putIfAbsent version of computeIfAbsent is much faster. So I think we should
use the computeIfAbsent in ConcurrentMap instead of ConcurrentHashMap as for us
the creation is usually cheap.
And in fact, it does not recommend to do a heavy operation in the
mappingFunction of computeIfAbsent.. Then I do not see the necessity of
reimplementing this method in ConcurrentHashMap...
> [JDK8] Use computeIfAbsent instead of get and putIfAbsent
> ---------------------------------------------------------
>
> Key: HBASE-16648
> URL: https://issues.apache.org/jira/browse/HBASE-16648
> Project: HBase
> Issue Type: Sub-task
> Components: Performance
> Affects Versions: 2.0.0
> Reporter: Duo Zhang
> Assignee: Duo Zhang
> Fix For: 2.0.0
>
> Attachments: HBASE-16648-v1.patch, HBASE-16648-v2.patch,
> HBASE-16648.patch
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)