-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-4053. Volume space: add quotaUsageInBytes and update it when write and delete key. #1296
Conversation
a00b566
to
fe3011b
Compare
fe3011b
to
07f7c17
Compare
642710a
to
ce40e90
Compare
@ChenSammi CC |
d200a65
to
20b4104
Compare
Hi @captainzmc , I would take a look on this. |
a8251c3
to
cc4327a
Compare
Thanks for yisheng's attention, PR has been updated. @cxorm Now this PR can be reviewed. |
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneVolume.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @captainzmc for the work.
Some comments are added inline.
- All variable-naming comments could be discussed if you have an idea.
- A little confuse on
OMKeyCommitRequest.java
should be addressed.
The test-part are not reviewed, if someone would take a look on this PR, you could start from here.
optional uint64 quotaUsageInBytes = 12; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional uint64 quotaUsageInBytes = 12; | |
optional uint64 quotaUsage = 12; |
@@ -269,6 +269,7 @@ private OzoneConsts() { | |||
public static final String KEY = "key"; | |||
public static final String SRC_KEY = "srcKey"; | |||
public static final String DST_KEY = "dstKey"; | |||
public static final String QUOTA_USAGE_IN_BYTES = "quotaUsageInBytes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we use QUOTA_USAGE = "quotaUsage"
here ?
Could you please update the rest part if you agree the idea ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using quotaUsage here may not be appropriate because it makes it impossible to distinguish between QuotaUsageInBytes and later QuotaUsageInCount.
Here we can use the usage in ContainerInfo, use usedBytes.
this(conf, proxy, name, admin, owner, quotaInBytes, quotaInCounts, | ||
creationTime, acls, metadata); | ||
this.modificationTime = Instant.ofEpochMilli(modificationTime); | ||
this.quotaUsageInBytes = quotaUsageInBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this(conf, proxy, name, admin, owner, quotaInBytes, quotaInCounts, | |
creationTime, acls, metadata); | |
this.modificationTime = Instant.ofEpochMilli(modificationTime); | |
this.quotaUsageInBytes = quotaUsageInBytes; | |
this(conf, proxy, name, admin, owner, quotaInBytes, quotaInCounts, | |
creationTime, modificationTime, acls, metadata); | |
this.quotaUsageInBytes = quotaUsageInBytes; |
@@ -46,6 +47,7 @@ | |||
private long quotaInBytes; | |||
private long quotaInCounts; | |||
private final OmOzoneAclMap aclMap; | |||
private LongAdder quotaUsageInBytes = new LongAdder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the LongAdder
here.
Out of curiosity,
Could you be so kind to tell me why we use it here ?
(Or please describe the bad pattern if we use just long
or Long
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QuotaUsageInBytes is a property of Volume that needs to be updated each time when CreateKey, AllocateBlock, CommitKey, DeleteKey. and at the beginning, we used the volume lock.
But, Previously, only Bucket locks were used for these operation, and use volume lock greatly affect the concurrency performance of different buckets under same volume.
So to avoid Volume locking for poor performance, LongAdder is used here to complete the atomic update of quotaUsageInBytes.
I did a performance test with freon. Multi-threading wrote different buckets under the same volume, and using LongAdder had little impact on the original performance.
@@ -222,6 +218,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, | |||
|
|||
acquireLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK, | |||
volumeName, bucketName); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long updateNum = omKeyInfo.getDataSize() * factor - | ||
locationInfoList.size() * scmBlockSize * factor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about the meaning of the variable.
(Please let me know the meaning of the variable if I miss something.)
Could you please add some comments about it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add comment to describe the calculation here.
@@ -292,14 +289,21 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, | |||
bucketName, Optional.absent(), Optional.of(missingParentInfos), | |||
trxnLogIndex); | |||
|
|||
long scmBlockSize = ozoneManager.getScmBlockSize(); | |||
omVolumeArgs = getVolumeInfo(omMetadataManager, volumeName); | |||
long updateNum = newLocationList.size() * scmBlockSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long updateNum = newLocationList.size() * scmBlockSize | |
long preAllocatedSpace = newLocationList.size() * scmBlockSize |
@@ -210,10 +206,17 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, | |||
new CacheKey<>(openKeyName), | |||
new CacheValue<>(Optional.of(openKeyInfo), trxnLogIndex)); | |||
|
|||
long scmBlockSize = ozoneManager.getScmBlockSize(); | |||
omVolumeArgs = getVolumeInfo(omMetadataManager, volumeName); | |||
long updateNum = newLocationList.size() * scmBlockSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long updateNum = newLocationList.size() * scmBlockSize | |
long preAllocatedSpace = newLocationList.size() * scmBlockSize |
long updateNum = omKeyInfo.getDataSize() * factor - | ||
keyArgs.getKeyLocationsList().size() * scmBlockSize * factor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as OMKeyCommitRequest
omVolumeArgs = getVolumeInfo(omMetadataManager, volumeName); | ||
long updateNum = newLocationList.size() * scmBlockSize | ||
* openKeyInfo.getFactor().getNumber(); | ||
// atom update quotaUsage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// atom update quotaUsage. | |
// update quotaUsage atomically. |
Thanks for @cxorm @xiaoyuyao to the review. The new commit has been updated. Could you help take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @captainzmc for working on this. The patch LGTM, +1. Only concern I have is the cost of volume usage update per key write/delete. If you can post the perf diff with/wo update using freon, that will be great.
@@ -46,6 +47,7 @@ | |||
private long quotaInBytes; | |||
private long quotaInCounts; | |||
private final OmOzoneAclMap aclMap; | |||
private LongAdder quotaUsageInBytes = new LongAdder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add final
return quotaUsageInBytes; | ||
} | ||
|
||
public void setQuotaUsageInBytes(long quotaUsageInBytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setQuotaUsageInBytes -> increase***
quotaInCounts, cloneMetadata, cloneAclMap, creationTime, | ||
modificationTime, objectID, updateID); | ||
quotaInCounts, cloneMetadata, quotaUsageInBytes.sum(), cloneAclMap, | ||
creationTime, modificationTime, objectID, updateID); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should getObjectInfo also be changed?
Thanks for @xiaoyuyao 's review. Here are the freon test results: |
411d86f
to
0117885
Compare
Had updated PR to fix review issues and resolve conflict. @ChenSammi Could you help take another look? |
0117885
to
c272d01
Compare
Thanks @captainzmc for the contribution and @cxorm @xiaoyuyao for review the patch. |
* master: (47 commits) HDDS-4104. Provide a way to get the default value and key of java-based-configuration easily (apache#1369) HDDS-4250. Fix wrong logger name (apache#1429) HDDS-4244. Container deleted wrong replica cause mis-replicated. (apache#1423) HDDS-4053. Volume space: add quotaUsageInBytes and update it when write and delete key. (apache#1296) HDDS-4210. ResolveBucket during checkAcls fails. (apache#1398) HDDS-4075. Retry request on different OM on AccessControlException (apache#1303) HDDS-4166. Documentation index page redirects to the wrong address (apache#1372) HDDS-4039. Reduce the number of fields in hdds.proto to improve performance (apache#1289) HDDS-4155. Directory and filename can end up with same name in a path. (apache#1361) HDDS-3927. Rename Ozone OM,DN,SCM runtime options to conform to naming conventions (apache#1401) HDDS-4119. Improve performance of the BufferPool management of Ozone client (apache#1336) HDDS-4217.Remove test TestOzoneContainerRatis (apache#1408) HDDS-4218.Remove test TestRatisManager (apache#1409) HDDS-4129. change MAX_QUOTA_IN_BYTES to Long.MAX_VALUE. (apache#1337) HDDS-4228: add field 'num' to ALLOCATE_BLOCK of scm audit log. (apache#1413) HDDS-4196. Add an endpoint in Recon to query Prometheus (apache#1390) HDDS-4211. [OFS] Better owner and group display for listing Ozone volumes and buckets (apache#1397) HDDS-4150. recon.api.TestEndpoints test is flaky (apache#1396) HDDS-4170 - Fix typo in method description. (apache#1406) HDDS-4064. Show container verbose info with verbose option (apache#1290) ...
…ponse * HDDS-4122-quota-attempt2: (51 commits) Remove redundant check status calls in children of AbstractOMOpenKeyDeleteRequest Remove unused inports and fix super constructor calls Move common volume byte usage update code to AbstractOMKeyDeleteResponse Add volume quota update to open key delete response, and group duplicate code HDDS-4104. Provide a way to get the default value and key of java-based-configuration easily (apache#1369) HDDS-4250. Fix wrong logger name (apache#1429) HDDS-4244. Container deleted wrong replica cause mis-replicated. (apache#1423) HDDS-4053. Volume space: add quotaUsageInBytes and update it when write and delete key. (apache#1296) HDDS-4210. ResolveBucket during checkAcls fails. (apache#1398) HDDS-4075. Retry request on different OM on AccessControlException (apache#1303) HDDS-4166. Documentation index page redirects to the wrong address (apache#1372) HDDS-4039. Reduce the number of fields in hdds.proto to improve performance (apache#1289) HDDS-4155. Directory and filename can end up with same name in a path. (apache#1361) HDDS-3927. Rename Ozone OM,DN,SCM runtime options to conform to naming conventions (apache#1401) HDDS-4119. Improve performance of the BufferPool management of Ozone client (apache#1336) HDDS-4217.Remove test TestOzoneContainerRatis (apache#1408) HDDS-4218.Remove test TestRatisManager (apache#1409) HDDS-4129. change MAX_QUOTA_IN_BYTES to Long.MAX_VALUE. (apache#1337) HDDS-4228: add field 'num' to ALLOCATE_BLOCK of scm audit log. (apache#1413) HDDS-4196. Add an endpoint in Recon to query Prometheus (apache#1390) ...
What changes were proposed in this pull request?
In addition, the current Quota setting does not take effect. HDDS-541 gives all the work needed to perfect Quota.
This PR is a subtask of HDDS-541.
First, we increase quotaUsageInBytes of volume. Later, we will judge whether the volume can be written based on this when we write the key.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-4053
How was this patch tested?
UT is added