-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
bpo-46848: Optimize mmap.find() with memmem(3) #31554
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
Conversation
Will fix the failing tests ASAP. |
2fd87a0
to
7f81d2d
Compare
Another thing you could try out and compare is using the fastsearch functions defined in Objects/stringlib, which should generally be faster than that naive loop and also platform independent. |
Modules/mmapmodule.c
Outdated
start_p = self->data + start; | ||
end_p = self->data + end; | ||
|
||
#ifdef UNIX |
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.
The function is not specified in POSIX standard. Please add a feature check to configure.ac
and check for HAVE_MEMMEM
.
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.
Done.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
e378cef
to
6fb16fd
Compare
#31625 provides a platform independent proposal. |
This merge requests optimizes
mmap.find()
by using libc'smemmem(3)
function (which is optimized) instead of using a trivial for loop. I could not find an equivalent solution formmap.rfind()
yet.The following snippet runs 100% faster with this patch applied. The file used is a logfile of 2.3 GB size
With this patch applied:
Without this patch:
https://bugs.python.org/issue46848