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

Performance improvement in cudf::strings::find/rfind for long strings #13226

Merged
merged 16 commits into from
May 8, 2023

Conversation

davidwendt
Copy link
Contributor

@davidwendt davidwendt commented Apr 26, 2023

Description

Improves performance for longer strings with cudf::strings::find() and cudf::strings::rfind() APIs.

The current implementation works well with small-ish strings and so this new implementation splits into a long-ish string algorithm when the average number of bytes per string is 64 bytes or greater. The new implementation searches for the target string by applying a warp per string kernel. Additionally, the special logic needed for matching an empty target (easily checked in host code) is factored out into its own transform functor.
For longer strings, the performance improvement is about 2-6x.

Reference #13048

Checklist

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

@davidwendt davidwendt added 2 - In Progress Currently a work in progress libcudf Affects libcudf (C++/CUDA) code. strings strings issues (C++ and Python) improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Apr 26, 2023
@davidwendt davidwendt self-assigned this Apr 26, 2023
@davidwendt
Copy link
Contributor Author

Some benchmark results from benchmarks/STRINGS_BENCH --benchmark_filter=StringFindScalar/find/

rows width baseline warp x
4096 32 0.037 0.037 1.00
4096 64 0.045 0.045 1.00
4096 128 0.062 0.062 1.00
4096 256 0.102 0.040 2.55
4096 512 0.169 0.048 3.52
4096 1024 0.292 0.061 4.79
4096 2048 0.463 0.084 5.51
4096 4096 0.802 0.141 5.69
4096 8192 1.40 0.238 5.88
32768 32 0.040 0.040 1.00
32768 64 0.048 0.047 1.02
32768 128 0.065 0.065 1.00
32768 256 0.106 0.074 1.43
32768 512 0.197 0.108 1.82
32768 1024 0.326 0.153 2.13
32768 2048 0.524 0.240 2.18
32768 4096 0.890 0.415 2.14
32768 8192 1.48 0.766 1.93
262144 32 0.061 0.061 1.00
262144 64 0.091 0.091 1.00
262144 128 0.177 0.177 1.00
262144 256 0.788 0.339 2.32
262144 512 1.40 0.558 2.51
262144 1024 2.08 0.882 2.36
262144 2048 5.75 1.45 3.97
262144 4096 15.3 2.69 5.69
2097152 32 0.215 0.214 1.00
2097152 64 0.403 0.402 1.00
2097152 128 0.941 0.941 1.00
2097152 256 6.40 2.45 2.61
2097152 512 9.94 4.16 2.39
16777216 32 1.44 1.43 1.01
16777216 64 2.87 2.87 1.00

@davidwendt davidwendt added 3 - Ready for Review Ready for review by team and removed 2 - In Progress Currently a work in progress labels May 3, 2023
@davidwendt davidwendt marked this pull request as ready for review May 3, 2023 14:24
@davidwendt davidwendt requested a review from a team as a code owner May 3, 2023 14:24
@davidwendt davidwendt requested review from bdice and mythrocks May 3, 2023 14:24
Copy link
Member

@PointKernel PointKernel left a comment

Choose a reason for hiding this comment

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

Nice work! 🔥

cpp/src/strings/search/find.cu Show resolved Hide resolved
Copy link
Contributor

@mythrocks mythrocks left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. It took me ages to understand the new kernel.

@bdice bdice removed their request for review May 8, 2023 17:09
@davidwendt
Copy link
Contributor Author

/merge

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 improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change strings strings issues (C++ and Python)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants