-
Notifications
You must be signed in to change notification settings - Fork 932
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
Improve performance for cudf::strings::count_re #15578
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some performance numbers for using
A general improvement overall but 2-3x improvement for long strings. |
Also should update here the results from the code snippet in the original issue.
After
|
PointKernel
approved these changes
Apr 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with some non-blocking nits.
ttnghia
approved these changes
Apr 24, 2024
/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)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Improves performance of
cudf::strings::count_re
when pattern starts with a literal character.Although this is a specific use case, the regex code has special logic to help speed up the search in this case.
Since the pattern indicates the target must contain this character as the start of the matching sequence, it first does a normal find for the character before continuing matching the remaining pattern. The
find()
function can be inefficient for long strings since it is character based and must resolve the character's byte-position by counting from the beginning of the string. For a function likecount_re()
all occurrences are matched within a target meaning longer target strings can incur expensive counting.The solution included here is to introduce a more efficient
find_char()
utility that accepts astring_view::const_iterator()
which automatically keeps track of its byte and character positions. This helps minimize byte/character counting in between calls fromcount_re()
and other similar functions that make repeated calls for all matches (e.g.replace_re()
andsplit_re()
).Close #15567
Checklist