wingrunr21 / gitolite

A Ruby interface for the gitolite git backend system
https://github.com/wingrunr21/gitolite
MIT License
82 stars 37 forks source link

Optimize performance #39

Closed jirutka closed 11 years ago

jirutka commented 11 years ago

There’s big performance issue with saving changes in GitoliteAdmin. It takes seconds with hundreds SSH keys in the keydir (about 10 sec with 250 keys for me). The problem is that it’s always loading all keys from file system even when app doesn’t need them and then writing all the keys back to file system (very expensive operation).

I made two optimizations:

I also made SSHKey immutable. It’s not necessary* but I highly recommend to make SSHKey immutable. If nothing else than because you’re using field owner as a hash key in ssh_keys so it should not be changed while being in hash under the owner as a hash key.

wingrunr21 commented 11 years ago

Looks good with the exception of the SSHKey immutability. I agree with the concept but would prefer not to make this change in v1. I've made a note to do this in v2.

Also, if you could give me some tests for the new objects/behavior.

jirutka commented 11 years ago

Well, here is spec for DirtyProxy. GitoliteAdmin doesn’t have tests (its spec is empty) so I’d have to write it all from scratch, but I don’t have time to do that now.

Should I rebase my branch without the immutable patch so you’ll be able to merge it simply from GitHub?

wingrunr21 commented 11 years ago

That's fine on the GitoliteAdmin side of the testing.

Nope, I can cherry-pick it out. I'll get this merged later today.

jirutka commented 11 years ago

Are you alive? :)

wingrunr21 commented 11 years ago

Ah sorry! Yes I am still alive. I totally spaced on this. I will do it today during the football game.

wingrunr21 commented 11 years ago

Merged. Thanks!