Skip to content

Find similar functions#358

Open
HaydnTrigg wants to merge 5 commits into
encounter:mainfrom
HaydnTrigg:fr-check-similar-functions
Open

Find similar functions#358
HaydnTrigg wants to merge 5 commits into
encounter:mainfrom
HaydnTrigg:fr-check-similar-functions

Conversation

@HaydnTrigg
Copy link
Copy Markdown
Contributor

Adds a new "Find similar functions" context menu entry on both target/base.
{370B0E6C-5E4D-4A99-831E-64C162518A0B}

This opens a window which scans against all of the objects both base and target and shows a bunch of rows sorted by match %

  • Text filter that filters both name of the function and the object names
  • Target and base checkbox
  • Min/max percentage filters
image

Demo Video

Resolves: #284

@tomsons26
Copy link
Copy Markdown
Contributor

tomsons26 commented Jun 2, 2026

Can you add a option to only scan current module?
For example, projects where similar functions are in same module only there's no need to scan all objects.

@LagoLunatic
Copy link
Copy Markdown
Collaborator

I think when you hit the back button during a search it should cancel the search job prematurely. Currently the search continues running even if you're not inside the similar view anymore. And if you re-enter the similar view, but for a different function than the one in the job that's already running, it will show the old results under the name of the new function, instead of starting a new job for the new function:

image

@HaydnTrigg
Copy link
Copy Markdown
Contributor Author

Can you add a option to only scan current module? For example, projects where similar functions are in same module only there's no need to scan all objects.

This is a good idea and worth exploring, but I’d prefer to revisit it after landing some optimizations in a future PR because it needs a little bit of UI thought. Should comparing against the same object be a separate context menu entry? Should there be a base only, target only option? Or should the search itself respect the filtering options and wait for a user to hit a "Search" button which is an extra step each time they want to do a diff.

It's relatively trivial to add a checkbox to restrict the filter to "Same object" so I've added that to the PR.

image

Demo Video

If the global diffing performance was so quick that most people didn't even notice then it wouldn't be a problem to just hit a single checkbox right in theory which is the lesser of all of the evils I think.

I have a change waiting to go after this which adds a new custom_make_all_args configuration option. This tells objdiff how to run the make command to build all of the base objects at once.

On Windows, a large portion of the time spent comparing objects comes from objdiff repeatedly spawning the build process. That’s not really an objdiff issue. It’s more a consequence of Windows being slow at launching lots of processes in parallel.

This change shifts the approach so objdiff can trigger a single “build everything” step, letting the build system efficiently determine what actually needs rebuilding from a global perspective. In practice, that means handing control over to Ninja to do its job, instead of incurring the overhead of constantly spawning new processes.

The comparison speed is relatively quick after that, but in the demo the comparison code is currently single threaded too. That’s another area that needs improvement and should reduce comparison times substantially.

The demo video is pretty much a worst-case example of where things are at in this PR. That’s a 19MiB executable with ~61500 functions comparing against another function that isn’t exactly small.

WIP custom_make_all_args branch https://github.com/HaydnTrigg/objdiff/tree/custom-make-all-args
Demo Video of Performance Improvements (Note: Still single threaded comparison, just fixes Windows process spawning)

@HaydnTrigg
Copy link
Copy Markdown
Contributor Author

I think when you hit the back button during a search it should cancel the search job prematurely. Currently the search continues running even if you're not inside the similar view anymore. And if you re-enter the similar view, but for a different function than the one in the job that's already running, it will show the old results under the name of the new function, instead of starting a new job for the new function:

image

Should be fixed in HaydnTrigg@88ddb07

@LagoLunatic
Copy link
Copy Markdown
Collaborator

Should be fixed in HaydnTrigg@88ddb07

Nice, thanks. One other similar case I didn't think to test the first time: If you use "File -> Project" or "File -> Recent Projects" you can switch to another project but the job still keeps running for the old one. Otherwise everything LGTM

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.

Feature to check for similar functions

3 participants