Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XXHash_32 hasher #17533

Open
wants to merge 23 commits into
base: branch-25.02
Choose a base branch
from

Conversation

PointKernel
Copy link
Member

@PointKernel PointKernel commented Dec 5, 2024

Description

Contributes to #17531

This PR introduces the xxhash_32 hasher to libcudf as a preparatory step for evaluating the impact of replacing murmurhash3_x86_32 with xxhash_32 as the default hash.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@PointKernel PointKernel added libcudf Affects libcudf (C++/CUDA) code. Performance Performance related issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Dec 5, 2024
@PointKernel PointKernel self-assigned this Dec 5, 2024
Copy link

copy-pr-bot bot commented Dec 5, 2024

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@PointKernel
Copy link
Member Author

/ok to test

@PointKernel
Copy link
Member Author

/ok to test

@bdice
Copy link
Contributor

bdice commented Dec 6, 2024

Nice work so far @PointKernel. I was experimenting with the same thing locally and had most of the same changes. 😄
Even if we end up deciding not to go forward with this change, I see a few things that we definitely want to merge (missing includes, and fixes for other fragility in tests/etc. exposed by the change of default).

@PointKernel
Copy link
Member Author

Thanks, @bdice. The failing tests are a bit concerning, but I'll investigate them further.

@PointKernel
Copy link
Member Author

/ok to test

@davidwendt
Copy link
Contributor

Perhaps plumb this through as a public function as well here?
https://github.com/rapidsai/cudf/blob/branch-25.02/cpp/include/cudf/hashing.hpp

@github-actions github-actions bot added the CMake CMake build issue label Dec 11, 2024
@PointKernel
Copy link
Member Author

/ok to test

@bdice
Copy link
Contributor

bdice commented Dec 11, 2024

/ok to test
(edit: needed new builds with the fix from #17573)

@bdice
Copy link
Contributor

bdice commented Dec 14, 2024

@PointKernel Do we want to make a change like this to join.hpp, too? (May require some further downstream edits, this may not build as-is.) This was the only major difference between my local experiments and your PR.

diff --git a/cpp/include/cudf/join.hpp b/cpp/include/cudf/join.hpp
index afefd04d4f..a4abd87811 100644
--- a/cpp/include/cudf/join.hpp
+++ b/cpp/include/cudf/join.hpp
@@ -18,6 +18,7 @@
 
 #include <cudf/ast/expressions.hpp>
 #include <cudf/hashing.hpp>
+#include <cudf/hashing/detail/default_hash.cuh>
 #include <cudf/table/table_view.hpp>
 #include <cudf/types.hpp>
 #include <cudf/utilities/default_stream.hpp>
@@ -41,15 +42,6 @@ namespace CUDF_EXPORT cudf {
  */
 enum class has_nested : bool { YES, NO };
 
-// forward declaration
-namespace hashing::detail {
-
-/**
- * @brief Forward declaration for our Murmur Hash 3 implementation
- */
-template <typename T>
-class MurmurHash3_x86_32;
-}  // namespace hashing::detail
 namespace detail {
 
 /**
@@ -307,7 +299,7 @@ enum class nullable_join : bool { YES, NO };
 class hash_join {
  public:
   using impl_type = typename cudf::detail::hash_join<
-    cudf::hashing::detail::MurmurHash3_x86_32<cudf::hash_value_type>>;  ///< Implementation type
+    cudf::hashing::detail::default_hash<cudf::hash_value_type>>;  ///< Implementation type
 
   hash_join() = delete;
   ~hash_join();

@PointKernel
Copy link
Member Author

@PointKernel Do we want to make a change like this to join.hpp, too? (May require some further downstream edits, this may not build as-is.)

The current hash join logic has a hasher-related bug, making performance evaluation by simply switching the hasher unreliable. Once rapidsai/rapids-cmake#723 is merged, I plan to address the issue first and then test the new hasher and hash table together to evaluate how all three impact overall performance.

@PointKernel
Copy link
Member Author

Meanwhile, after analyzing with Nsight Compute, I observed that the xxHash32 kernel uses 29 registers, whereas the MurmurHash kernel uses 28. While xxHash is slightly faster, it also requires one additional register.

image

@bdice
Copy link
Contributor

bdice commented Dec 16, 2024

The differences between 28 and 29 registers are not really material, the compiler may optimize things differently when in a larger kernel. I saw that the mixed join kernels aren’t even always monotonic between assumed complexity and register usage. The hash kernel alone is not big enough to really know, so performance and avoidance of local memory spilling in larger kernels are the key metrics I would use.

@PointKernel
Copy link
Member Author

The differences between 28 and 29 registers are not really material, the compiler may optimize things differently when in a larger kernel. I saw that the mixed join kernels aren’t even always monotonic between assumed complexity and register usage. The hash kernel alone is not big enough to really know, so performance and avoidance of local memory spilling in larger kernels are the key metrics I would use.

I see what you mean. I'll go ahead and make this PR simply add the xxhash_32 hasher to libcudf without changing the default hash. Now that rapids-cmake #723 has been merged, I'll first fix the hasher bug in the hash join and then assess the impact of switching the default hash. Does that sound good to you?

@PointKernel PointKernel marked this pull request as ready for review December 16, 2024 20:33
@PointKernel PointKernel requested review from a team as code owners December 16, 2024 20:33
@PointKernel PointKernel added 3 - Ready for Review Ready for review by team and removed Performance Performance related issue labels Dec 16, 2024
@PointKernel PointKernel changed the title Use XXHash_32 as the default hash Add XXHash_32 hasher Dec 16, 2024
@bdice
Copy link
Contributor

bdice commented Dec 16, 2024

@PointKernel Yes! I support that plan.

Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

We'll need a follow-up PR for the Python side.

edit: we decided to do it here!

@bdice bdice requested a review from a team as a code owner December 16, 2024 21:52
@bdice bdice requested review from wence- and Matt711 December 16, 2024 21:52
@github-actions github-actions bot added Python Affects Python cuDF API. pylibcudf Issues specific to the pylibcudf package labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team CMake CMake build issue improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants