Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] fixing bug 321502 - lost in polymorphia

Matthias Sohn <matthias.sohn@xxxxxxxxxxxxxx> wrote:
> Now as this problem is fixed by consistently relying on value equality
> across AnyObjectId's type hierarchy,

Now that this is changed, we also should look for calls to copy() and
remove them if they are *only* used for a set contains test, or a map
lookup.  I know we did some funny code in some places like:

  HashMap<ObjectId, ...> map = new HashMap<ObjectId, ...>();


because we were using a RevObject as a lookup key into a map we had
built using ObjectId and the map wasn't an ObjectIdSubclassMap.
Removing some of those copy() calls will reduce the amount of
garbage we create during lookups.  :-)

Its on my list of "things to do" now that this equals() change is
in, but I have a lot of other stuff in front of it, which means
I may not get to this anytime soon.  Its a simple performance and
not functionality thing, and its really manual gruntwork, but we
should still do it.

> I suspect we could also get rid of or at least
> simplify ObjectIdSubclassMap. Or do I miss something here ?


I mean, on the surface sure, its now just HashMap.

But it has a smaller memory footprint than HashMap does.
That matters when its backing the object pool for a PackWriter
or IndexPack, or when we are traversing the bulk of a project's
history in order to show a graphical view of it.

IIRC we may also out-perform HashMap for our workload.  But I
haven't looked at it recently.

Back to the top