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

Hiroshi Ikeda commented on HBASE-14268:
---------------------------------------

bq. Nice numbers. Out of interest, do you see weak references being collected 
in non-full GC?

By the new KeyLocker's outputs in my previously added comment, non-full GC 
collects much memory, which is no doubt used for weak references and their 
referents.

{quote}
Why do this and not just Iterate the passed in Set?

Object[] keyArray = keys.toArray();
{quote}

The elements are required to sort before locking in order to avoid deadlock. 
There are several ways to do this, but I think using array is simpler and 
faster than using {{TreeSet}} or {{Collections.sort(List)}}.

{quote}
Why loop twice and not lock as you go: i.e. is this needed:

for (Lock lock : locks.values())
{ 97 lock.lock(); 134 }

98 }
{quote}

That is because the range under the locks should be as small as possible.


> Improve KeyLocker
> -----------------
>
>                 Key: HBASE-14268
>                 URL: https://issues.apache.org/jira/browse/HBASE-14268
>             Project: HBase
>          Issue Type: Improvement
>          Components: util
>            Reporter: Hiroshi Ikeda
>            Assignee: Hiroshi Ikeda
>            Priority: Minor
>             Fix For: 2.0.0, 1.3.0
>
>         Attachments: 14268-V5.patch, HBASE-14268-V2.patch, 
> HBASE-14268-V3.patch, HBASE-14268-V4.patch, HBASE-14268-V5.patch, 
> HBASE-14268-V5.patch, HBASE-14268-V6.patch, HBASE-14268-V7.patch, 
> HBASE-14268-V7.patch, HBASE-14268.patch, KeyLockerPerformance.java
>
>
> 1. In the implementation of {{KeyLocker}} it uses atomic variables inside a 
> synchronized block, which doesn't make sense. Moreover, logic inside the 
> synchronized block is not trivial so that it makes less performance in heavy 
> multi-threaded environment.
> 2. {{KeyLocker}} gives an instance of {{RentrantLock}} which is already 
> locked, but it doesn't follow the contract of {{ReentrantLock}} because you 
> are not allowed to freely invoke lock/unlock methods under that contract. 
> That introduces a potential risk; Whenever you see a variable of the type 
> {{RentrantLock}}, you should pay attention to what the included instance is 
> coming from.



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

Reply via email to