Skip to content

HBASE-29218: Reduce calls to Configuration#get() in decompression path - #6857

Merged
ndimiduk merged 4 commits into
apache:masterfrom
HubSpot:HBASE-29218/hfile-decompressing-context
Apr 24, 2025
Merged

HBASE-29218: Reduce calls to Configuration#get() in decompression path#6857
ndimiduk merged 4 commits into
apache:masterfrom
HubSpot:HBASE-29218/hfile-decompressing-context

Conversation

@charlesconnell

Copy link
Copy Markdown
Contributor

Use of the org.apache.hadoop.conf.Configuration class to look up values is not super fast. It's fine most of the time, but in a very hot code path, it takes up noticeable CPU time.

ByteBuffDecompressor's are pooled and reused to avoid garbage collection churn. This means that sometimes their settings are not right for the block they're being asked to decompress. To handle this, before every decompression action, we call ByteBuffDecompressor#reinit(Configuration), so it can pull settings from the Configuration in preparation for the decompression it's about to do. The Configuration#get() inside reinit() happens once per block, even though the settings it deals with are consistent across an entire table.

Because the settings used by a ByteBuffDecompressor don't actually change within a table, we can pull the settings it needs from a Configuration when opening the HFile, and then not check again.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@charlesconnell
charlesconnell marked this pull request as ready for review March 26, 2025 16:28
@charlesconnell
charlesconnellforce-pushed the HBASE-29218/hfile-decompressing-context branch 2 times, most recently from d424ae6 to e8f9f96CompareApril 15, 2025 14:11
@charlesconnell
charlesconnellforce-pushed the HBASE-29218/hfile-decompressing-context branch from e8f9f96 to 99f82e4CompareApril 15, 2025 14:17
@charlesconnell

charlesconnell commented Apr 15, 2025

Copy link
Copy Markdown
ContributorAuthor

I've added a commit to switch uses of the Caffeine cache back to Guava, in modules that leak into the client. I should have considered that using an un-shaded Caffeine would pollute client classpaths.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@ndimidukndimiduk left a comment

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.

Some questions / nits. Otherwise looks good to me.

Comment threadhbase-common/pom.xml
<groupId>org.apache.commons</groupId>
<artifactId>commons-crypto</artifactId>
</dependency>
<dependency>

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.

Thanks for fixing this.

public static final String ZSTD_DICTIONARY_KEY = "hbase.io.compress.zstd.dictionary";

private static final Cache<String, Pair<ZstdDictDecompress, Integer>> DECOMPRESS_DICT_CACHE =
CacheBuilder.newBuilder().maximumSize(100).expireAfterAccess(10, TimeUnit.MINUTES).build();

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.

Should the details of this cache be user-configurable?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

My preference is for less low-value configuration options. But, I'm happy to do it either way, what do you prefer?

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.

Nope, I'm fine with leaving them as hard-coded for now. Just asking the question to prompt the discussion.

@ndimiduk

Copy link
Copy Markdown
Member

Oh sorry. Please also address the checkstyle nits. Thanks @charlesconnell !

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 50sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ master Compile Tests _
+0 🆗mvndep0m 12sMaven dependency ordering for branch
+1 💚mvninstall4m 46smaster passed
+1 💚compile5m 6smaster passed
+1 💚checkstyle1m 19smaster passed
+1 💚spotbugs3m 26smaster passed
+1 💚spotless1m 9sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗mvndep0m 16sMaven dependency ordering for patch
+1 💚mvninstall4m 45sthe patch passed
+1 💚compile5m 27sthe patch passed
+1 💚javac5m 27sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
+1 💚checkstyle1m 42sthe patch passed
+1 💚xmllint0m 0sNo new issues.
+1 💚spotbugs4m 33sthe patch passed
+1 💚hadoopcheck16m 20sPatch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚spotless0m 56spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 37sThe patch does not generate ASF License warnings.
61m 52s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6857/5/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#6857
JIRA IssueHBASE-29218
Optional Testsdupname asflicense javac codespell detsecrets xmllint hadoopcheck spotless compile spotbugs checkstyle hbaseanti
unameLinux af3550b1c32f 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 835b934
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count83 (vs. ulimit of 30000)
modulesC: hbase-common hbase-server hbase-compression/hbase-compression-zstd U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6857/5/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3 xmllint=20913
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec5m 49sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+0 🆗mvndep1m 3sMaven dependency ordering for branch
+1 💚mvninstall3m 51smaster passed
+1 💚compile1m 40smaster passed
+1 💚javadoc1m 6smaster passed
+1 💚shadedjars6m 19sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗mvndep0m 13sMaven dependency ordering for patch
+1 💚mvninstall5m 57sthe patch passed
+1 💚compile1m 35sthe patch passed
+1 💚javac1m 35sthe patch passed
+1 💚javadoc0m 56sthe patch passed
+1 💚shadedjars6m 18spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit3m 13shbase-common in the patch passed.
-1 ❌unit398m 20s/patch-unit-hbase-server.txthbase-server in the patch failed.
+1 💚unit9m 20shbase-compression-zstd in the patch passed.
459m 55s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6857/5/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#6857
JIRA IssueHBASE-29218
Optional Testsjavac javadoc unit shadedjars compile
unameLinux d9c61612bc3a 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 835b934
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6857/5/testReport/
Max. process+thread count4329 (vs. ulimit of 30000)
modulesC: hbase-common hbase-server hbase-compression/hbase-compression-zstd U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6857/5/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@ndimidukndimiduk changed the title HBASE-29218: Pass around an HFileDecompressionContext to reduce calls to Configuration.get()HBASE-29218: Reduce calls to Configuration#get() in decompression pathApr 24, 2025
@ndimiduk
ndimiduk merged commit 763093a into apache:masterApr 24, 2025
@ndimiduk
ndimiduk deleted the HBASE-29218/hfile-decompressing-context branch April 24, 2025 09:13
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 24, 2025
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 24, 2025
ndimiduk pushed a commit that referenced this pull request Apr 24, 2025
ndimiduk added a commit that referenced this pull request Apr 25, 2025
#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
apache#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
ndimiduk added a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
apache#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
ndimiduk added a commit that referenced this pull request Apr 26, 2025
#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
ndimiduk added a commit that referenced this pull request Apr 26, 2025
#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
mokai87 pushed a commit to mokai87/hbase that referenced this pull request Aug 7, 2025
apache#6857)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Charles Connell <cconnell@hubspot.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@charlesconnell@Apache-HBase@ndimiduk