[
https://issues.apache.org/jira/browse/HDFS-17896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18070743#comment-18070743
]
ASF GitHub Bot commented on HDFS-17896:
---------------------------------------
CapMoon commented on code in PR #8360:
URL: https://github.com/apache/hadoop/pull/8360#discussion_r3031171649
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java:
##########
@@ -3111,14 +3112,20 @@ LocatedBlock getAdditionalBlock(
checkOperation(OperationCategory.WRITE);
writeLock(RwLockMode.GLOBAL);
LocatedBlock lb;
+ BlockInfo blockInfo;
try {
checkOperation(OperationCategory.WRITE);
- lb = FSDirWriteFileOp.storeAllocatedBlock(
+ Pair<LocatedBlock, BlockInfo> pair =
FSDirWriteFileOp.storeAllocatedBlock(
this, src, fileId, clientName, previous, targets);
+ lb = pair.getLeft();
+ blockInfo = pair.getRight();
} finally {
writeUnlock(RwLockMode.GLOBAL, operationName);
}
getEditLog().logSync();
+ if (blockInfo != null) {
Review Comment:
When `add new chosen targets to already allocated block or retry`,
`blockInfo` is null.
> Move logAllocatedBlock out of lock in FSNamesystem.getAdditionalBlock to
> reduce latency
> ---------------------------------------------------------------------------------------
>
> Key: HDFS-17896
> URL: https://issues.apache.org/jira/browse/HDFS-17896
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: hdfs
> Affects Versions: 3.4.3
> Reporter: yue.wang
> Priority: Major
> Labels: pull-request-available
> Attachments: logAllocatedBlock takes lots of time.png
>
>
> The {{logAllocatedBlock}} method in {{FSNamesystem.getAdditionalBlock}} is
> currently called while holding global lock. Flame graph analysis shows this
> logging path (via SLF4J/Log4j appenders) contributes non-trivial latency,
> blocking other NameNode operations.
>
> Since {{logAllocatedBlock}} is only for audit/diagnostic logging and does not
> modify shared state, we can safely move it after releasing global lock to
> reduce lock hold time and improve write throughput.
>
> This change preserves all existing logging behavior while eliminating
> unnecessary lock contention from I/O-bound logging operations.
>
> Flame graph:
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]