Live data from Hacker News

Why is C faster than Java: git vs JGit

marc.info

1–10 of 106 posts

Re: Why is C faster than Java: git vs JGit

#3
I had a similar experience when I was doing some Galois Field arithmetic in Java. You pay a huge penalty because of the absence of unsigned types. In our case we had to use long instead of int, which is extra costly, since many basic operations in Java return int by default.

Re: Why is C faster than Java: git vs JGit

#4
I almost skipped this link; I assumed it was typical borring blog noise. It's not.

This is an insightful post from the git mailing list which shows some of the real limitations that a top tier developer hits when trying to write Java code as fast as neatly optimized C code. Definitely worth reading.

Re: Why is C faster than Java: git vs JGit

#5
post #3

I had a similar experience when I was doing some Galois Field arithmetic in Java. You pay a huge penalty because of the absence of unsigned types. In our case we had to use long instead of int, which is extra costly, since many basic operations in Java return int by default.

Why does signedness matter?

Addition is XOR which is sign-agnostic. Multiplication has to be done via table lookups to be fast which also makes it sign agnostic.

Well, at least for p=2.

Re: Why is C faster than Java: git vs JGit

#6

So why do they write and use jgit at google instead of just git?

From the project page:

The original goal of JGit/EGit was to provide an Eclipse plugin for working with software using the Git SCM. The Eclipse plugin is still the main goal of many of the developers, but we are open to anyone wanting to interface with other tools, Netbeans, Ant, Maven etc. For those, the JGit part provides a high performance API for working with Git repositories. The main other user of JGit, besides EGit, is Gerrit Code Review, which used by projects such as JGit (ofcourse), EGit (by implication) and Android.

Not sure if that provides a very good motivation, but there you go. :)

Re: Why is C faster than Java: git vs JGit

#7
I find it kind of interesting that in Haskell, which is arguably even higher level than Java, most of these optimisations are eminently possible..

EDIT: This obviously came across a bit as language fanboyism, so I guess I should mention that the language features that let you do many of them let you shoot yourself in the foot just as easily as you can in C, and you can certainly argue that with a strong FFI you might as well just call into C if you really need that kind of low level performance..

Re: Why is C faster than Java: git vs JGit

#8
post #3

I had a similar experience when I was doing some Galois Field arithmetic in Java. You pay a huge penalty because of the absence of unsigned types. In our case we had to use long instead of int, which is extra costly, since many basic operations in Java return int by default.

Why does signedness matter? Addition is XOR which is sign-agnostic. Multiplication has to be done via table lookups to be fast which also makes it sign agnostic. Well, at least for p=2.

I was doing it in GF(2^32-5). Your statement is true for GF(2^n) where n is small enough to keep the entire multiplication-table in memory (usually n <= 8). When it's bigger you keep log-tables in memory then sign matters. However when n=16 you get lucky and can use char as an unsigned 16 bit int.

Re: Why is C faster than Java: git vs JGit

#9

So why do they write and use jgit at google instead of just git?

It's a java library, making it much easier to use from java code than a command-line utility and all the ensuing parsing and munging of string data (which is not java's forte either)
Post reply on HN