Re: [JGIT PATCH 03/15] Add IntList as a more efficient representation of List<Integer>
From: Sverre Rabbelier <hidden>
Date: 2016-06-15 22:45:46
On Fri, Dec 12, 2008 at 16:41, Shawn O. Pearce [off-list ref] wrote:
If you'd like to send a patch to change it, I'll apply it. But I don't think its worth my time to make this toString() more efficient.
I mainly mentioned it because it's in a Class meant to be more optimal than what Java ships with, but I agree with your reasoning that this toString is not part of what needs to be optimized.
Other areas of JGit I do try to micro-optimize, because they are right smack in the middle of the critical paths.
Hehe, I very much agree with not optimizing prematurely, and if you do optimize to go for it all the way.
E.g. look at ObjectId.equals(byte[],int,byte[],int). I hand-unrolled the memcmp loop because the JIT on x86 does *soooo* much better when the code is spelled out:
<code snipped> Kind of sad that you have to write this kind of code if you want good performance, ah well, perhaps someday... (import java.lang.optimized ;) ).
This block is in the critical path for any tree diff code, in particular for a "git log -- a/" sort of operation. Its used to compare the SHA-1s from two different tree records to see if they differ. Not unrolling this was a huge penalty.
I reckon that is done a lot :). Ashame the JRE can't do that kind of
optimization for you. e.g., if you do:
for(int i = 0; i < constant; i++) {
some_code;
}
--
Cheers,
Sverre Rabbelier