Skip to content

Conversation

@charlesconnell
Copy link
Contributor

@charlesconnell charlesconnell commented Apr 11, 2025

I've looked at a lot of allocation profiles of RegionServers doing a read-heavy workload. Some allocations that dominate the chart can be easily avoided.

The following code in the main decode method

currentBuffer.asSubByteBuffer(currentBuffer.position(), current.keyLength, tmpPair);
ByteBuffer key = tmpPair.getFirst().duplicate();
key.position(tmpPair.getSecond()).limit(tmpPair.getSecond() + current.keyLength);
current.keyBuffer = key; 

results in a new ByteBuffer for every cell. The reason to have this duplicate ByteBuffer is to hold the result of tmpPair.getSecond() as its position state. But this is just an integer that can be more cheaply stored in a different way. We can introduce a current.keyOffset variable and do this instead:

currentBuffer.asSubByteBuffer(currentBuffer.position(), current.keyLength, tmpPair);
current.keyBuffer = tmpPair.getFirst();
current.keyOffset = tmpPair.getSecond();

and then reference current.keyOffset where we previously referenced current.keyBuffer.position().

Additionally, RowIndexSeekerV1.SeekerState contains a ByteBufferKeyOnlyKeyValue field that is replaced on every cell read. This object can be reset and re-used instead.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache9 Apache9 requested a review from Copilot April 12, 2025 06:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

@charlesconnell charlesconnell force-pushed the HBASE-29252/row-index-v1-allocations branch from 05789be to 22e8d01 Compare April 12, 2025 17:54
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@charlesconnell
Copy link
Contributor Author

test failures are unrelated

protected int nextKvOffset;
// buffer backed keyonlyKV
// buffer backed keyonlyKV, reset and re-used as necessary to avoid allocations
private ByteBufferKeyOnlyKeyValue currentKey = new ByteBufferKeyOnlyKeyValue();
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it final if we do not need to recreate it?


protected ByteBuff currentBuffer;
protected int startOffset = -1;
protected int keyOffset = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Better add some comments to explain what do these offsets and lengths mean?

Copy link
Member

Choose a reason for hiding this comment

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

I won't request further changes, but for future reference, these comments would ideally be javadoc and then this additional information would be more readily onhand for folks pursuing the code in an IDE environment.

protected int valueLength;
// Tags start after values and end after tagsLength
protected int tagsLength = 0;
protected int tagsOffset = -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that tagsOffset was effectively unused so I've removed it

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 29s 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 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+0 🆗 mvndep 0m 15s Maven dependency ordering for branch
+1 💚 mvninstall 5m 10s master passed
+1 💚 compile 5m 30s master passed
+1 💚 checkstyle 1m 17s master passed
+1 💚 spotbugs 3m 18s master passed
+1 💚 spotless 1m 12s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 15s Maven dependency ordering for patch
+1 💚 mvninstall 5m 9s the patch passed
+1 💚 compile 8m 10s the patch passed
+1 💚 javac 8m 10s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 2m 3s the patch passed
+1 💚 spotbugs 5m 19s the patch passed
+1 💚 hadoopcheck 21m 19s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 2m 0s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 1m 10s The patch does not generate ASF License warnings.
76m 2s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6902/3/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #6902
JIRA Issue HBASE-29252
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux 0a7f92a72c35 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 tool maven
Personality dev-support/hbase-personality.sh
git revision master / db17a2b
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 85 (vs. ulimit of 30000)
modules C: hbase-common hbase-server U: .
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6902/3/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 28s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed 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 🆗 mvndep 0m 11s Maven dependency ordering for branch
+1 💚 mvninstall 3m 28s master passed
+1 💚 compile 1m 21s master passed
+1 💚 javadoc 0m 47s master passed
+1 💚 shadedjars 6m 6s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 13s Maven dependency ordering for patch
+1 💚 mvninstall 3m 23s the patch passed
+1 💚 compile 1m 26s the patch passed
+1 💚 javac 1m 26s the patch passed
+1 💚 javadoc 0m 48s the patch passed
+1 💚 shadedjars 6m 16s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚 unit 2m 26s hbase-common in the patch passed.
+1 💚 unit 233m 19s hbase-server in the patch passed.
265m 57s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6902/3/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #6902
JIRA Issue HBASE-29252
Optional Tests javac javadoc unit compile shadedjars
uname Linux 486b25b924e4 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 tool maven
Personality dev-support/hbase-personality.sh
git revision master / db17a2b
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6902/3/testReport/
Max. process+thread count 5185 (vs. ulimit of 30000)
modules C: hbase-common hbase-server U: .
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6902/3/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.


protected ByteBuff currentBuffer;
protected int startOffset = -1;
protected int keyOffset = -1;
Copy link
Member

Choose a reason for hiding this comment

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

I won't request further changes, but for future reference, these comments would ideally be javadoc and then this additional information would be more readily onhand for folks pursuing the code in an IDE environment.

@ndimiduk ndimiduk merged commit 30ce21b into apache:master Apr 25, 2025
1 check passed
@ndimiduk ndimiduk deleted the HBASE-29252/row-index-v1-allocations branch April 25, 2025 09:45
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
ndimiduk pushed a commit to ndimiduk/hbase that referenced this pull request Apr 25, 2025
ndimiduk pushed a commit that referenced this pull request Apr 26, 2025
ndimiduk pushed a commit that referenced this pull request Apr 28, 2025
ndimiduk pushed a commit that referenced this pull request Apr 28, 2025
ndimiduk pushed a commit that referenced this pull request Apr 28, 2025
mokai87 pushed a commit to mokai87/hbase that referenced this pull request Aug 7, 2025
sanjeet006py pushed a commit to sanjeet006py/hbase that referenced this pull request Sep 26, 2025
Sign up for free to 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.

4 participants