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

Yu Li commented on HBASE-18085:
-------------------------------

bq. In ur test method for tryLock, there is no logic other than just try lock 
and release. If that is been removed as dead code by compiler?
Ok got your point now.

Have changed the testLock method to use Blackhole like:
{code}
  @Benchmark
  public void testLock(Blackhole bh) {
    if (purgeLock.tryLock()) {
      try {
        // do purge
        bh.consume(0);
        return;
      } finally {
        purgeLock.unlock();
      }
    }
    bh.consume(1);
  }
{code}
and the result turned out:

{noformat}
Benchmark                                 Mode  Cnt           Score          
Error  Units
AtomicLockBenchmark.testAtomicBoolean    thrpt  100    47677994.547 ±  
1295778.841  ops/s
AtomicLockBenchmark.testLock             thrpt  100  2277364613.072 ± 
49185975.985  ops/s
AtomicLockBenchmark.testVolatileBoolean  thrpt  100    44386308.984 ±   
644407.794  ops/s
{noformat}

Checking the compiled class:
{noformat}
  public void testLock(org.openjdk.jmh.infra.Blackhole);
    Code:
       0: aload_0
       1: getfield      #7                  // Field 
purgeLock:Ljava/util/concurrent/locks/Lock;
       4: invokeinterface #11,  1           // InterfaceMethod 
java/util/concurrent/locks/Lock.tryLock:()Z
       9: ifeq          39
      12: aload_1
      13: iconst_0
      14: invokevirtual #12                 // Method 
org/openjdk/jmh/infra/Blackhole.consume:(I)V
      17: aload_0
      18: getfield      #7                  // Field 
purgeLock:Ljava/util/concurrent/locks/Lock;
      21: invokeinterface #13,  1           // InterfaceMethod 
java/util/concurrent/locks/Lock.unlock:()V
      26: return
      27: astore_2
      28: aload_0
      29: getfield      #7                  // Field 
purgeLock:Ljava/util/concurrent/locks/Lock;
      32: invokeinterface #13,  1           // InterfaceMethod 
java/util/concurrent/locks/Lock.unlock:()V
      37: aload_2
      38: athrow
      39: aload_1
      40: iconst_1
      41: invokevirtual #12                 // Method 
org/openjdk/jmh/infra/Blackhole.consume:(I)V
      44: return
    Exception table:
       from    to  target type
          12    17    27   any
{noformat}

Let me know your thoughts sir [~anoop.hbase]

> 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)

Reply via email to