-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Arbitrarily high hit counts / high allocation counts hurts search performance, refactor search hits to use rz_vector? #1909
Comments
Hi! Thanks for your report. Could you be a bit clearer on what is the problem before discussing possible solutions? From the
And this happens very quicky. Did I understand it right? Are you doing anything different? |
I built off of whatever's included by default for building cutter on it's default branch. I'm on windows x64 bit. From memory I ran the command to search for 0's by accident across all memory maps when I was attached to inscryption.exe, there's a demo on steam which I can only imagine would do the same thing. I don't have complete context for what rizin would've done in command line, I essentially froze cutter. |
We would need few more details to start looking at this. I feel this is more of a "bug report" rather than a "feature request" We need to understand, at least:
Without the above info there is not much we can do to help you, sorry. |
Will be solved by #4742 |
Is your feature request related to a problem? Please describe.
May be more related to cutter's gui because it looks like the api has a maximum search limit / count and perhaps that'd solve the issue in commandline. However, without knowing that in advance you can hang the application by running a search which may have too many results. The issue stems from usage of a list structure which allocates for every saved result in
rz_search_t
.The problem function in question would be
rz_search_hit_new
.Edit: on second look it appears the api is being used with a callback which terminates early and skips the allocation I thought was the original issue. This might impact uses of this part of the api without a provided callback, they're likely slower than it should be. Whatever's causing the application hang eludes me.
Describe the solution you'd like
Key part here would be to refactor the search functionality to use a vector like (or probably better rope like) structure. This should improve search timings considerably since time won't be wasted waiting on the system for memory. There appears to be a header for vectors in the library, it probably could be put to use here. A well designed rope structure would probably be better.
EG: instead of
something like:
Since results are addresses there's no need to allocate for every 8 byte address, and since any information related to pointers is auxiliary to the pointer there's and pointers are by definition unique there's plenty of opportunity to use hashtables to grab any interesting auxiliary information about the pointer later. It seems like in addition to the matched address currently a pointer to the search used is saved. There's probably a good amount of memory to save by not storing that pointer for each hit.
Describe alternatives you've considered
Another idea would be a custom allocator, seems like that would considerably more difficult, and I suspect a better data structure is the better approach.
Additional context
A fairly easy way to test this is to do what I did by accident, which is to debug a program and search for 0 effectively everywhere.
It also looks as if the maxhits variable can be used to reserve space in
rz_search_begin
. This in theory should reduce allocations wherever this api is used.The text was updated successfully, but these errors were encountered: