Compiling with "-O3" (instead of the default "-Os") speeds up all operations (though it makes compilation slower).

As a specific example, it make my huge repository "add" operation go from 18 seconds to 6; likewise, "update" went from 14 to 5.

I don't think there are any real problems with the optimizers in recent GCC builds, at least I haven't encountered any.