-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
RzBuffer is inefficient (only on hot paths) #4769
Comments
RzBuffer is quite nice, I suggest adding something like: if (buf->type == RZ_BUFFER_BYTES || buf->type == RZ_BUFFER_MMIO) then {
void *ptr = buf->get_raw_ptr()
} else {
... slow path
} |
that should be done only internally |
Can you please elaborate this? What exactly is |
Yes, I updated my pseudocode example to be more precise. |
This sets search.overlap=true by default. Mostly because I think this what people expect. Also, with the search.align or search.alignment options there will be the option to search at alignments. This also adds some hex string to bytes helpers. Fixes them and adds tests. Unfinished reimplementation of /x. Fix up the hex string to buffer functions. Fix fast mask comparison macro. Fix byte comparison with UB. Invert condition to match documentation of callback Handle search options from the settings and add tests. This sets search.overlap=true by default. Mostly because I think this what people expect. Also, with the search.align or search.alignment there are way better options to consider for seraching not overlapping data. Fix rz_hex_str2bin_mask() did set mask bits for 0 Refine documentation for rz_hex_str2bin functions. Add byte search tests. Don't allow wildcards with a custom mask. Change buffer to chunk size and make it a search setting. Make search over bytes more efficient. Searching over windows of memory. Add some helper functions to read from IO into a RzBuffer Simplify buffer management and fix leaks Fix bugs add tests regarding search windows Revert design with RzBuffer due to rizinorg#4769 Fix several stupidity bugs Change order of byte pattern and mask. Apply suggestions.
This sets search.overlap=true by default. Mostly because I think this what people expect. Also, with the search.align or search.alignment options there will be the option to search at alignments. This also adds some hex string to bytes helpers. Fixes them and adds tests. Unfinished reimplementation of /x. Fix up the hex string to buffer functions. Fix fast mask comparison macro. Fix byte comparison with UB. Invert condition to match documentation of callback Handle search options from the settings and add tests. This sets search.overlap=true by default. Mostly because I think this what people expect. Also, with the search.align or search.alignment there are way better options to consider for seraching not overlapping data. Fix rz_hex_str2bin_mask() did set mask bits for 0 Refine documentation for rz_hex_str2bin functions. Add byte search tests. Don't allow wildcards with a custom mask. Change buffer to chunk size and make it a search setting. Make search over bytes more efficient. Searching over windows of memory. Add some helper functions to read from IO into a RzBuffer Simplify buffer management and fix leaks Fix bugs add tests regarding search windows Revert design with RzBuffer due to rizinorg#4769 Fix several stupidity bugs Change order of byte pattern and mask. Apply suggestions.
Is your feature request related to a problem? Please describe.
All
RzBuffer
related functions which use the internal callbacks are inefficient on hot paths.This makes
RzBuffer
unusable if many reads happen on it.The reason is that the internal buffer uses different callbacks for different buffer types (
read()
,write()
,get_size()
,get_whole_buffer()
etc.). This makes sense, but prevents the compiler from inlining functions.Even the simplest functions which only return a pointer, consumes enormous CPU time (in my case 20-30%), because the function pointers are de-referenced every single time.
The compiler can't optimize them away.
Describe the solution you'd like
Move away from function pointers and replace them with switch cases directly calling the functions.
Or implementing "performance" versions of them. But this means double amount of maintenance.
Describe alternatives you've considered
Using raw
ut8* + size
. Which we want (?) to get away from.Additional context
None
The text was updated successfully, but these errors were encountered: