Skip to content

HDFS-17896. Move logAllocatedBlock out of lock to reduce latency#8360

Merged
ayushtkn merged 1 commit intoapache:trunkfrom
CapMoon:HDFS-17896
Apr 15, 2026
Merged

HDFS-17896. Move logAllocatedBlock out of lock to reduce latency#8360
ayushtkn merged 1 commit intoapache:trunkfrom
CapMoon:HDFS-17896

Conversation

@CapMoon
Copy link
Copy Markdown
Contributor

@CapMoon CapMoon commented Mar 20, 2026

HDFS-17896. Move logAllocatedBlock out of lock in FSNamesystem.getAdditionalBlock to reduce latency

Description of PR

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.

Performance improvement:
getAdditionalBlock

@hadoop-yetus
Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 21s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 26m 54s trunk passed
+1 💚 compile 0m 57s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 1m 0s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 0m 59s trunk passed
+1 💚 mvnsite 1m 9s trunk passed
+1 💚 javadoc 0m 53s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 54s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
-1 ❌ spotbugs 1m 4s /branch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in trunk failed.
+1 💚 shadedclient 19m 56s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 44s the patch passed
+1 💚 compile 0m 42s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 42s the patch passed
+1 💚 compile 0m 45s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 45s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 44s /results-checkstyle-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs-project/hadoop-hdfs: The patch generated 1 new + 137 unchanged - 0 fixed = 138 total (was 137)
+1 💚 mvnsite 0m 50s the patch passed
+1 💚 javadoc 0m 36s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 37s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
-1 ❌ spotbugs 0m 42s /patch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
+1 💚 shadedclient 19m 12s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 184m 45s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 27s The patch does not generate ASF License warnings.
257m 16s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/2/artifact/out/Dockerfile
GITHUB PR #8360
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux e6de501340d0 5.15.0-141-generic #151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 80bd94e
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/2/testReport/
Max. process+thread count 4218 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/2/console
versions git=2.43.0 maven=3.9.11
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@CapMoon CapMoon force-pushed the HDFS-17896 branch 3 times, most recently from 42c5193 to 7c07491 Compare March 24, 2026 01:11
@hadoop-yetus
Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 20s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 27m 49s trunk passed
+1 💚 compile 1m 1s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 1m 3s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 1m 3s trunk passed
+1 💚 mvnsite 1m 10s trunk passed
+1 💚 javadoc 0m 53s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 54s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
-1 ❌ spotbugs 1m 4s /branch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in trunk failed.
+1 💚 shadedclient 21m 12s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 45s the patch passed
+1 💚 compile 0m 43s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 43s the patch passed
+1 💚 compile 0m 45s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 45s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 43s the patch passed
+1 💚 mvnsite 0m 46s the patch passed
+1 💚 javadoc 0m 34s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 37s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
-1 ❌ spotbugs 0m 43s /patch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
+1 💚 shadedclient 19m 57s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 181m 53s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 31s The patch does not generate ASF License warnings.
257m 28s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/5/artifact/out/Dockerfile
GITHUB PR #8360
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 4ea6e9da06db 5.15.0-171-generic #181-Ubuntu SMP Fri Feb 6 22:44:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 7c07491
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/5/testReport/
Max. process+thread count 4294 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/5/console
versions git=2.43.0 maven=3.9.11
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@CapMoon CapMoon force-pushed the HDFS-17896 branch 2 times, most recently from 7a9cb73 to 60e1c6c Compare March 30, 2026 02:11
@hadoop-yetus
Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 20s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 25m 46s trunk passed
+1 💚 compile 0m 57s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 1m 0s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 1m 0s trunk passed
+1 💚 mvnsite 1m 3s trunk passed
+1 💚 javadoc 0m 53s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 55s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 17s trunk passed
+1 💚 shadedclient 17m 2s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 50s the patch passed
+1 💚 compile 0m 40s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 40s the patch passed
+1 💚 compile 0m 45s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 45s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 43s /results-checkstyle-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs-project/hadoop-hdfs: The patch generated 3 new + 137 unchanged - 0 fixed = 140 total (was 137)
+1 💚 mvnsite 0m 52s the patch passed
+1 💚 javadoc 0m 35s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 35s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 4s the patch passed
+1 💚 shadedclient 16m 33s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 186m 33s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 30s The patch does not generate ASF License warnings.
261m 6s
Reason Tests
Failed junit tests hadoop.hdfs.server.balancer.TestBalancerWithHANameNodes
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/8/artifact/out/Dockerfile
GITHUB PR #8360
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux a0c1aed6749f 5.15.0-141-generic #151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 60e1c6c
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/8/testReport/
Max. process+thread count 4166 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/8/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 27s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 26m 34s trunk passed
+1 💚 compile 0m 52s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 0m 57s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 1m 0s trunk passed
+1 💚 mvnsite 1m 3s trunk passed
+1 💚 javadoc 0m 48s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 52s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 27s trunk passed
+1 💚 shadedclient 17m 38s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 47s the patch passed
+1 💚 compile 0m 44s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 44s the patch passed
+1 💚 compile 0m 46s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 46s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 46s the patch passed
+1 💚 mvnsite 0m 50s the patch passed
+1 💚 javadoc 0m 37s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 40s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 30s the patch passed
+1 💚 shadedclient 17m 28s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 179m 28s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 29s The patch does not generate ASF License warnings.
256m 16s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/9/artifact/out/Dockerfile
GITHUB PR #8360
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 9e021712105f 5.15.0-141-generic #151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / ba6dbf9
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/9/testReport/
Max. process+thread count 5018 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8360/9/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 1, 2026

Failed UTs are not relevant to this pr.

Copy link
Copy Markdown
Contributor

@ZanderXu ZanderXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CapMoon Thanks for your report.

LGTM + 1.

What kind of performance improvements have you achieved? Can you share some details?

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 2, 2026

yeah, added in description

writeUnlock(RwLockMode.GLOBAL, operationName);
}
getEditLog().logSync();
if (blockInfo != null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when will be blockInfo null? I don't see any null check earlier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When add new chosen targets to already allocated block or retry, blockInfo is null.

Copy link
Copy Markdown
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ayushtkn
Copy link
Copy Markdown
Member

ayushtkn commented Apr 4, 2026

@CapMoon I am gonna hit the merge button, can you help me confirm your jira id or assign the ticket to your name. is it :
https://issues.apache.org/jira/secure/ViewProfile.jspa?name=buddh1stvvy

So, you have due credits in the Jira, in case you don't have a jira id or access to the assign, let me know, I will sort it out for you

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 8, 2026

@CapMoon I am gonna hit the merge button, can you help me confirm your jira id or assign the ticket to your name. is it : https://issues.apache.org/jira/secure/ViewProfile.jspa?name=buddh1stvvy

So, you have due credits in the Jira, in case you don't have a jira id or access to the assign, let me know, I will sort it out for you

@ayushtkn This is my first time to contribute to community, so i don't have a jira id or access to the assign, plz help me to get them, thx :)

@ayushtkn
Copy link
Copy Markdown
Member

ayushtkn commented Apr 8, 2026

@CapMoon Just fill this for with project as Hadoop, can mention this PR in the description & let me know once you are done with it I will approve & get you the required permissions to assign the ticket
https://selfserve.apache.org/jira-account.html

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 9, 2026

@ayushtkn Thx master, I have finished submitting the request on https://selfserve.apache.org/jira-account.html

@ayushtkn
Copy link
Copy Markdown
Member

ayushtkn commented Apr 9, 2026

@CapMoon I don't see any request submitted. Can you double check if you selected Hadoop as the project and actually clicked submit & it did succeed

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 9, 2026

@ayushtkn I did submit the request, when submit again, it remind me there already has a pending request with email: wangyue19997053@gmail.com

image

@ayushtkn
Copy link
Copy Markdown
Member

ayushtkn commented Apr 9, 2026

@CapMoon Did you verify your email after that. I checked with folks from Infra, They say unless you verify your email, we won't get the request to approve

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 10, 2026

@ayushtkn Already verified my email, thx for your notice

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 15, 2026

@ayushtkn Hi master, what is the update?

@ayushtkn ayushtkn merged commit 1d1a18f into apache:trunk Apr 15, 2026
3 of 4 checks passed
@ayushtkn
Copy link
Copy Markdown
Member

I have merged it, for your JIRA id reach out private@infra.apache.org with the details, once you have the jira id, let me know I will assign the ticket

@CapMoon
Copy link
Copy Markdown
Contributor Author

CapMoon commented Apr 15, 2026

@ayushtkn Hi master, my jira id is: buddhistvvy

@ayushtkn
Copy link
Copy Markdown
Member

I have added you as HDFS Contributor & assigned the ticket. Welcome to Hadoop!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants