[
https://issues.apache.org/jira/browse/HBASE-18085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16019282#comment-16019282
]
Yu Li commented on HBASE-18085:
-------------------------------
Here is the JMH result with command "java -jar benchmarks.jar -t 200 -i 10 -wi
10 AtomicLockBenchmark"
{noformat}
# JMH 1.12 (released 416 days ago, please consider updating!)
# VM version: JDK 1.7.0_91, VM 24.91-b01
# VM invoker:
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91-2.6.2.3.1.alios7.x86_64/jre/bin/java
# VM options: <none>
# Warmup: 10 iterations, 1 s each
# Measurement: 10 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 200 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
Benchmark Mode Cnt Score
Error Units
AtomicLockBenchmark.testAtomicBoolean thrpt 100 49970164.876 ±
1550159.062 ops/s
AtomicLockBenchmark.testLock thrpt 100 6449687494.203 ±
151151562.428 ops/s
AtomicLockBenchmark.testVolatileBoolean thrpt 100 45228262.106 ±
594889.926 ops/s
{noformat}
And the simple test code:
{code}
@State(Scope.Benchmark)
public class AtomicLockBenchmark {
AtomicBoolean purging = new AtomicBoolean(false);
Lock purgeLock = new ReentrantLock();
volatile boolean purgeInProgress = false;
@Benchmark
public void testAtomicBoolean() {
if (purging.compareAndSet(false, true)) {
// do purge
purging.set(false);
}
}
@Benchmark
public void testLock() {
if (purgeLock.tryLock()) {
try {
// do purge
return;
} finally {
purgeLock.unlock();
}
}
}
@Benchmark
public void testVolatileBoolean() {
if (!purgeInProgress) {
purgeInProgress = true;
// do purge
purgeInProgress = false;
}
}
}
{code}
> Prevent parallel purge in ObjectPool
> ------------------------------------
>
> Key: HBASE-18085
> URL: https://issues.apache.org/jira/browse/HBASE-18085
> Project: HBase
> Issue Type: Bug
> Reporter: Yu Li
> Assignee: Yu Li
> Attachments: e89l05465.st3.jstack, HBASE-18085.patch
>
>
> Parallel purge in ObjectPool is meaningless and will cause contention issue
> since {{ReferenceQueue#poll}} has synchronization (source code shown below)
> {code}
> public Reference<? extends T> poll() {
> if (head == null)
> return null;
> synchronized (lock) {
> return reallyPoll();
> }
> }
> {code}
> We observed threads blocking on the purge method while using offheap bucket
> cache, and we could easily reproduce this by testing the 100% cache hit case
> in bucket cache with enough reading threads.
> We propose to add a purgeLock and use tryLock to avoid parallel purge.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)