-
-
Notifications
You must be signed in to change notification settings - Fork 370
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. |
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: