You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/06/23 00:09:28 UTC

[GitHub] [hadoop-ozone] runzhiwang edited a comment on pull request #1028: HDDS-3735. Improve SCM performance with 3.7% by remove unnecessary lock and unlock

runzhiwang edited a comment on pull request #1028:
URL: https://github.com/apache/hadoop-ozone/pull/1028#issuecomment-647830265


   @elek Thanks for review. You are right, if the write code like following, maybe after  `currentInfo.setState(newState)` and before `currentInfo.setOwner(owner)`, we read the currentInfo, so we read a half write ContainerInfo. 
   ```
   lock.writeLock().lock();
   final ContainerInfo currentInfo = containerMap.get(containerID);
   currentInfo.setState(newState);
   currentInfo.setOwner(owner);
   lock.writeLock().unlock();
   ```
   
   I think we can avoid this by the following code. Though write become more complicated because it needs to new an object, but read is pretty more than write, so it's worth. What do you think ?
   ```
   lock.writeLock().lock();
   final ContainerInfo currentInfo = containerMap.get(containerID);
   ContainerInfo newInfo = new ContainerInfo(currentInfo);
   newInfo.setState(newState);
   newInfo.setOwner(owner);
   containerMap.put(containerID, newInfo);
   lock.writeLock().unlock();
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org