[
https://issues.apache.org/jira/browse/HDFS-17931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093123#comment-18093123
]
ASF GitHub Bot commented on HDFS-17931:
---------------------------------------
Hexiaoqiao commented on code in PR #8529:
URL: https://github.com/apache/hadoop/pull/8529#discussion_r3510521252
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingDataNodeMessages.java:
##########
@@ -109,7 +109,7 @@ void enqueueReportedBlock(DatanodeStorageInfo storageInfo,
Block block,
}
void removeQueuedBlock(DatanodeStorageInfo storageInfo, Block block) {
- if (storageInfo == null || block == null) {
+ if (count == 0 || storageInfo == null || block == null) {
Review Comment:
Great catch, `count <= 0` may be safer because there is no logic to void
`count` under 0 when run subtract. Thanks.
> Add early return in PendingDataNodeMessages.removeQueuedBlock when queue is
> empty
> ---------------------------------------------------------------------------------
>
> Key: HDFS-17931
> URL: https://issues.apache.org/jira/browse/HDFS-17931
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: Janus Chow
> Assignee: Janus Chow
> Priority: Major
> Labels: pull-request-available
>
> removeQueuedBlock() is called for every block in a block report. When the
> pending queue is empty (count == 0), the method still unconditionally
> allocates a new Block() and does a HashMap.get() before returning null. On
> large DataNodes this is millions of unnecessary allocations per report.
>
> This is especially costly under ZGC, where these operations trigger
> load/write barriers even on the no-op path. In practice, on a ZGC Observer
> NameNode, count is almost always 0 because ZGC's sub-millisecond pauses keep
> EditLogTailer current, so isGenStampInFuture() rarely triggers.
> Fix: add a count == 0 early return before the new Block() allocation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]