Skip to content

HBASE-26773 [hbase-thirdparty] Introduce a hbase-unsafe module in hba…#78

Merged
Apache9 merged 2 commits intoapache:masterfrom
Apache9:HBASE-26773
Mar 1, 2022
Merged

HBASE-26773 [hbase-thirdparty] Introduce a hbase-unsafe module in hba…#78
Apache9 merged 2 commits intoapache:masterfrom
Apache9:HBASE-26773

Conversation

@Apache9
Copy link
Contributor

@Apache9 Apache9 commented Feb 26, 2022

…se-thirdparty to remove the direct references of Unsafe in our main code base

…se-thirdparty to remove the direct references of Unsafe in our main code base
@Apache9 Apache9 requested review from apurtell and busbey February 26, 2022 17:19
@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 45s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 spotbugs 0m 0s spotbugs executables are 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.
_ master Compile Tests _
+1 💚 mvninstall 0m 49s master passed
+1 💚 compile 0m 12s master passed
+1 💚 checkstyle 0m 29s master passed
+1 💚 javadoc 0m 6s master passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 2s Maven dependency ordering for patch
-1 ❌ mvninstall 0m 3s root in the patch failed.
-1 ❌ mvninstall 0m 3s hbase-unsafe in the patch failed.
-1 ❌ compile 0m 4s root in the patch failed.
-1 ❌ compile 0m 3s hbase-unsafe in the patch failed.
-1 ❌ javac 0m 4s root in the patch failed.
-1 ❌ javac 0m 3s hbase-unsafe in the patch failed.
-1 ❌ checkstyle 0m 1s The patch fails to run checkstyle in root
-1 ❌ checkstyle 0m 1s The patch fails to run checkstyle in hbase-unsafe
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 xml 0m 1s The patch has no ill-formed XML file.
-1 ❌ javadoc 0m 3s root in the patch failed.
-1 ❌ javadoc 0m 4s hbase-unsafe in the patch failed.
_ Other Tests _
-1 ❌ unit 0m 3s root in the patch failed.
-1 ❌ unit 0m 3s hbase-unsafe in the patch failed.
+0 🆗 asflicense 0m 7s ASF License check generated no output?
4m 9s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/Dockerfile
GITHUB PR #78
Optional Tests dupname asflicense javac javadoc unit xml compile spotbugs findbugs checkstyle
uname Linux 0dbeb026e997 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 GNU/Linux
Build tool maven
git revision master / 3ecf75e
Default Java Oracle Corporation-1.8.0_282-b08
mvninstall https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-mvninstall-root.txt
mvninstall https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-mvninstall-hbase-unsafe.txt
compile https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-compile-root.txt
compile https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-compile-hbase-unsafe.txt
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-compile-root.txt
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-compile-hbase-unsafe.txt
checkstyle https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/buildtool-patch-checkstyle-root.txt
checkstyle https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/buildtool-patch-checkstyle-hbase-unsafe.txt
javadoc https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-javadoc-root.txt
javadoc https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-javadoc-hbase-unsafe.txt
unit https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-unit-root.txt
unit https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/artifact/yetus-precommit-check/output/patch-unit-hbase-unsafe.txt
Test Results https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/testReport/
Max. process+thread count 39 (vs. ulimit of 1000)
modules C: . hbase-unsafe U: .
Console output https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/1/console
versions git=2.20.1
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 6s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 spotbugs 0m 0s spotbugs executables are 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.
_ master Compile Tests _
+1 💚 mvninstall 0m 45s master passed
+1 💚 compile 0m 12s master passed
+1 💚 checkstyle 0m 29s master passed
+1 💚 javadoc 0m 6s master passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 6s Maven dependency ordering for patch
+1 💚 mvninstall 0m 30s the patch passed
+1 💚 compile 0m 19s the patch passed
-1 ❌ javac 0m 6s hbase-unsafe generated 4 new + 0 unchanged - 0 fixed = 4 total (was 0)
-1 ❌ javac 0m 12s root generated 4 new + 21 unchanged - 0 fixed = 25 total (was 21)
+1 💚 checkstyle 0m 28s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 xml 0m 1s The patch has no ill-formed XML file.
+1 💚 javadoc 0m 10s the patch passed
_ Other Tests _
+1 💚 unit 0m 6s hbase-unsafe in the patch passed.
+1 💚 unit 0m 33s root in the patch passed.
+1 💚 asflicense 0m 10s The patch does not generate ASF License warnings.
5m 11s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/2/artifact/yetus-precommit-check/output/Dockerfile
GITHUB PR #78
Optional Tests dupname asflicense javac javadoc unit xml compile spotbugs findbugs checkstyle
uname Linux ce6fb1579894 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 GNU/Linux
Build tool maven
git revision master / 3ecf75e
Default Java Oracle Corporation-1.8.0_282-b08
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/2/artifact/yetus-precommit-check/output/diff-compile-javac-hbase-unsafe.txt
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/2/artifact/yetus-precommit-check/output/diff-compile-javac-root.txt
Test Results https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/2/testReport/
Max. process+thread count 388 (vs. ulimit of 1000)
modules C: hbase-unsafe . U: .
Console output https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/2/console
versions git=2.20.1
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache9
Copy link
Contributor Author

Apache9 commented Feb 27, 2022

The javac warnings are expected. We do use sun.misc.Unsafe in the package...

Copy link
Contributor

@apurtell apurtell left a comment

Choose a reason for hiding this comment

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

One naming nit request, otherwise lgtm

* Delegate all methods of {@link HBaseUnsafe0}, so we will not touch the actual
* {@code sun.misc.Unsafe} class until we actually call the methods.
*/
public final class HBaseUnsafe {
Copy link
Contributor

Choose a reason for hiding this comment

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

Want to call this PlatformDependent :-) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a joke, but would be fine too for real...

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'm just fine with either name :)

* Delegate all the method in sun.misc.Unsafe.
*/
@SuppressWarnings("restriction")
final class HBaseUnsafe0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This naming is unusual for our code base. We usually do things like HBaseUnsafe -> HBaseUnsafeImpl, or HBaseUnsafe -> HBaseUnsafeInternal. The '0' suffix is efficient but the more typical constructions are better for comprehension.

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 prefer the internal one.

Let me update the patch.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 8s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 spotbugs 0m 0s spotbugs executables are 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.
_ master Compile Tests _
+1 💚 mvninstall 0m 25s master passed
+1 💚 compile 0m 12s master passed
+1 💚 checkstyle 0m 26s master passed
+1 💚 javadoc 0m 5s master passed
-0 ⚠️ patch 0m 35s Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 5s Maven dependency ordering for patch
+1 💚 mvninstall 0m 30s the patch passed
+1 💚 compile 0m 19s the patch passed
-1 ❌ javac 0m 6s hbase-unsafe generated 4 new + 0 unchanged - 0 fixed = 4 total (was 0)
-1 ❌ javac 0m 13s root generated 4 new + 21 unchanged - 0 fixed = 25 total (was 21)
+1 💚 checkstyle 0m 28s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 xml 0m 1s The patch has no ill-formed XML file.
+1 💚 javadoc 0m 10s the patch passed
_ Other Tests _
+1 💚 unit 0m 6s hbase-unsafe in the patch passed.
+1 💚 unit 0m 33s root in the patch passed.
+1 💚 asflicense 0m 9s The patch does not generate ASF License warnings.
4m 45s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/3/artifact/yetus-precommit-check/output/Dockerfile
GITHUB PR #78
Optional Tests dupname asflicense javac javadoc unit xml compile spotbugs findbugs checkstyle
uname Linux 33914005158d 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 GNU/Linux
Build tool maven
git revision master / 3ecf75e
Default Java Oracle Corporation-1.8.0_282-b08
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/3/artifact/yetus-precommit-check/output/diff-compile-javac-hbase-unsafe.txt
javac https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/3/artifact/yetus-precommit-check/output/diff-compile-javac-root.txt
Test Results https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/3/testReport/
Max. process+thread count 387 (vs. ulimit of 1000)
modules C: hbase-unsafe . U: .
Console output https://ci-hbase.apache.org/job/HBase-Thirdparty-PreCommit/job/PR-78/3/console
versions git=2.20.1
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache9 Apache9 merged commit 9f5c6e2 into apache:master Mar 1, 2022
private static final boolean UNALIGNED;

static {
AVAIL = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
Copy link
Member

Choose a reason for hiding this comment

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

nit: implement as a lambda instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will cause compile error, as there is a PrivilegedExceptionAction...

Copy link
Member

Choose a reason for hiding this comment

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

nod

Method m;
try {
m = clazz.getDeclaredMethod("arrayBaseOffset", Class.class);
if (m == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Static analysis says that Class#getDeclaredMethod never returns null, so none of these null checks are ever executed. I don't know how descriptive the system-generated error messages will be, but the nice helpful warn statements won't happen.

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 just copied this piece of code from the hbase main repo, without any changes. Maybe it is used to be compatible with some strange JDK implementations?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm good point, this class implementation could be JDK dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the implementation of the 'Class', not Unsafe, so typically I agree with you that we should get a NoSuchMethodException. Anyway, not a big deal? Can open a new issue to remove these null checks...

Copy link
Member

Choose a reason for hiding this comment

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

Agreed it's not a big deal. It might be confusing in the future for someone reading code without the aid of a development environment.

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