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

Release the GIL for BytesAhoCorasick when the haystack is bytes #97

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

iscgar
Copy link

@iscgar iscgar commented Jan 6, 2024

In theory we should do that for every type that is guaranteed to be immutable, in order to improve performance, but there's no way to tell whether a type is immutable or not through the Buffer protocol, so we only do this as a special case for bytes.

Fixes #94.

@iscgar
Copy link
Author

iscgar commented Jan 6, 2024

@itamarst I added a test for checking with different types of haystacks, but I'm not sure if there's an automatic way to tell that the optimised path is taken when the haystack is bytes. I did verify the change manually when running the test though by adding prints in the Rust code.

In theory we should do that for every type that is guaranteed to be
immutable, in order to improve performance, but there's no way to tell
whether a type is immutable or not through the Buffer protocol, so we
only do this as a special case for `bytes`.

Fixes G-Research#94.
@itamarst
Copy link
Collaborator

itamarst commented Jan 9, 2024

Thank you!

@itamarst itamarst merged commit c8e4eaa into G-Research:main Jan 9, 2024
21 checks passed
@iscgar iscgar deleted the release_gil_for_bytes_haystack branch March 8, 2024 11:07
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.

BytesAhoCorasick could release the GIL if the haystack is a bytes object
2 participants