Repository navigation
Change the cache from a Boolean array to a byte array for GraphOrdering - #914
Conversation
This eschews object overhead and resulting boxing/unboxing while retaining the ability to cache per-entry in the adjacancy matrix (by using a short with effectively three states) Additionally, due to the missing object header, this will be more space efficient.
|
@d-michail this addresses the significant overhead in I'd like to also address |
|
You could also use a Regarding caching the Another option would be to have two different @jsichi Any ideas on this one? |
|
Yeah, I like the I'll make the argument that if you want the performance of cached edges and (currently) could afford Note that with the additional So self time of |
|
Thinking more about it, it should be less: so the combined |
Reduces memory footprint by 2x.
|
I agree with @iotamudelta that all-or-nothing caching should be good enough; fine-grained control over what to cache seems like it would be overkill here. |
jsichi
left a comment
There was a problem hiding this comment.
Regarding the array representation, java.util.BitSet would be much more compact (two bits per entry), but I dunno about the performance.
| private int[][] incomingEdges; | ||
| private Boolean[][] adjMatrix; | ||
| /* | ||
| * if caching is enabled, this contains cached information on edges existing, values: |
There was a problem hiding this comment.
Convert this into a Javadoc comment and use proper formatting (unordered list HTML tags).
|
|
||
| if (cacheEdges) { | ||
| containsEdge = adjMatrix[v1Number][v2Number]; | ||
| final byte cache = adjMatrix[v1Number*vertexCount+v2Number]; |
There was a problem hiding this comment.
Save the address computation for use in the update below.
|
@jsichi concerning |
|
It would be a single object for the entire ordering. |
|
@jsichi see updated implementation. It doesn't make a big performance difference compared to Let me know if that's what you were looking for, then I'll adjust the PR title and summary accordingly. |
jsichi
left a comment
There was a problem hiding this comment.
@d-michail are you OK with the latest code?
| Boolean containsEdge = null; | ||
|
|
||
|
|
||
| final int cacheIndex = 2*(v1Number*vertexCount+v2Number); |
There was a problem hiding this comment.
Initialize to 0 and defer computation. (Probably the compiler is smart enough to do this anyway, but hey.
There was a problem hiding this comment.
yeah, I'm rather sure the JIT would have even figured out the double cacheIndex computation before. but better be safe than sorry.
done.
|
Also updated the title and PR summary here to reflect use of |
|
@jsichi I've done some more benchmarking on this solution and unfortunately it seems to be slower than the Thoughts? |
…ion." This reverts commit efa2d48.
|
That's fine; thanks for benchmarking. Just curious--was it a noticeable difference for the isomorphism detection as a whole, or only when microbenchmarking directly against GraphOrdering? |
|
Since the rest of the isomorphism is still rather expensive, it didn't yield a larger overall impact (which is why I missed it first). However, looking closer at I think once this and #918 is settled, there is more to look at ( |
|
Thanks! |
|
Looks good! |
This eschews object overhead and resulting boxing/unboxing while retaining the ability
to cache per-entry in the adjacency matrix (by using a byte with effectively three
states per entry)
Due to the missing object header, this reduces the memory expense per entry to 1 byte from 16 bytes (64bit JVM).
HISTORY.mdorCONTRIBUTORS.md