DGA-MI-SSI / YaCo

YaCo is an Hex-Rays IDA plugin. When enabled, multiple users can work simultaneously on the same binary. Any modification done by any user is synchronized through git version control.
GNU General Public License v3.0
313 stars 36 forks source link

IDA slow/hang on save #36

Closed MrSapps closed 6 years ago

MrSapps commented 6 years ago

I don't know if this is a limitation or bug so I figured I'd raise it.

My repo is here:

https://github.com/AliveTeam/YaCo

Fork make a change and save to repro. IDA will hang for up to 20+ seconds on save.

bamiaux commented 6 years ago

You may experience slowness if you initialized YaCo on a repo before the first auto-analysis was complete. You should probably resync the IDB & force push once to clear it up. Anyway, the branch here https://github.com/DGA-MI-SSI/YaCo/tree/issue_36 may reduce the pauses

MrSapps commented 6 years ago

That wasn't the case but I did a resync & force push anyway :).

Is there an automated build of that branch that I can try? After the force resync the delay is still around the same (not using the issue_36 branch).

MrSapps commented 6 years ago

Managed to get a build but it still hangs IDA for around 20 seconds on save.

The output was this:

repo: commit: 4 added 1 updated 0 deleted

And the changes where:

https://github.com/AliveTeam/YaCo/commit/33ffa2f346de5fdf821c60d8b3db8bf5097b0b81

bamiaux commented 6 years ago

Sorry, I cannot do automated builds because this plugin need to compile against the IDA SDK which is not public.

About the slowness, there are multiple issues

For now, I advise switching every users to this branch, do a force push and maybe invest in a SSD or try it inside a ramdisk ^^

MrSapps commented 6 years ago

Thanks, it is running in an SSD so I guess ram disk is the next thing to try. What is the min version of IDA that v2.0 requires? I will switch to this if we all have a compatible version.

bamiaux commented 6 years ago

Ok, I’m using 7.1 and I’m not reproducing the 20s slowdown with the patches on top of v2.0 If you compile the binaries yourself, You should try with ida 7.1 and idasdk 7.1 Forget the RAM disk if you already have an ssd.

MrSapps commented 6 years ago

OK - if mixed IDA versions use the same repo is that supported or will all users have to switch?

Edit: BTW I was looking at IDA API changes from 7.0 to 7.1 - doesn't look like anything ground breaking which would radically improve performance?

Could it be due to use of hex rays decompiler that it may always generate a lot of events or something?

devnoname120 commented 6 years ago

Sorry, I cannot do automated builds because this plugin need to compile against the IDA SDK which is not public.

@bamiaux

Can't you encrypt the IDA SDK and host it somewhere, and then you encrypt the decryption key using Travis CI's encrypted values feature?

bamiaux commented 6 years ago

The repository format is the same & compatible between 7.0 & 7.1 I don't know why you still have slowdowns, I need to check further

bamiaux commented 6 years ago

@devnoname120 Sorry, I prefer to wait until hexrays make their SDK downloadable by anyone

devnoname120 commented 6 years ago

@bamiaux Do they plan to do so? I haven't read anything about it, and Hex-Rays isn't exactly known for making sound business decisions.

MrSapps commented 6 years ago

Is there any logging or something I could enable that would help to track down the slow down source?

bamiaux commented 6 years ago

@devnoname120 I have no idea about their plans, it's still a mystery to me why the SDK is not public

@paulsapps yes, set LOG_IDB_EVENTS to true here https://github.com/DGA-MI-SSI/YaCo/blob/d9f6a60b78a4a446acc08357b2a56bfc7e3f3927/YaLibs/YaToolsIDALib/Hooks.cpp#L38 you will see some logs on IDA actions

bamiaux commented 6 years ago

Note that if you plan to systematically document the whole base, or "as much as possible", it won't work, as the current XML file format is too inefficient to be able to duplicate a whole IDB

MrSapps commented 6 years ago

I force pushed and flattened repo history to 1 commit. This has reduced save time from 20-40 seconds to about 5 seconds. This seems strange as I thought the force push would have had the same effect as it updates the "base" IDB file to the current "local" IDB file? (It didn't change save time without flattening history down to 1 commit).

Perhaps that is a separate issue.

So with 1 commit and a new base IDB and no changes pressing save takes around 5 seconds and nothing gets pushed. Does that seem about on par with the kind of performance you would expect?

bamiaux commented 6 years ago

What do you mean about the save time ? Maybe there's an issue here.

It takes 2s here, but I'm using a local remote. You can try with this

git remote rm origin
git clone . --bare /some/ssd/path
git remote add origin /some/ssd/path

It will remove the network overhead. In any case, it seems saving does too many git commands which may be optimized, I'll look into it soon Saving without any conflict should be faster than current version

MrSapps commented 6 years ago

Confirmed its around 2 seconds with a local remote. So therefore the delay must be in huge network overhead? This is odd because if I push the changes from the local to real remote origin it only takes around 2 seconds. Therefore I would expect the over all time to be around 4 seconds?

Edit: By push I mean let YaCo save to the local remote (2 seconds) and then do a git push from that one via the git bash).

bamiaux commented 6 years ago

I will look at our git handling code which is using libgit, maybe we can do things more efficiently, but I don't know yet. I'm a little busy right now though, so don't hold your breath ^_^

bamiaux commented 6 years ago

With current issue_36 branch, it looks like the biggest slowdown is during push, which entirely handled by libgit2. I've updated to the latest version, but the changelog doesn't mention any speed changes. I've also modified our rebase handling code which should be slightly faster than before but I don't expect dramatic changes

bamiaux commented 6 years ago

Please try https://github.com/DGA-MI-SSI/YaCo/tree/git_async Saving should be much faster as git push is done in the background now Note that I didn't test it on linux, it may have build issues

bamiaux commented 6 years ago

Linux build fixed

MrSapps commented 6 years ago

Will get a Windows build and try it out as soon as, thanks :)

MrSapps commented 6 years ago

Haven't used it too much yet but looks like the hang is reduced to 2-5 seconds which is acceptable by me :+1:

bamiaux commented 6 years ago

I'm closing it, it's in master with other fixes and will be in the next release