Skip to content

Trivial optimization to isFeasiblePair - #911

Merged
jsichi merged 5 commits into
jgrapht:masterfrom
iotamudelta:less_string
Apr 27, 2020
Merged

jsichi merged 5 commits into
jgrapht:masterfrom
iotamudelta:less_string

Conversation

@iotamudelta

@iotamudelta iotamudelta commented Apr 23, 2020 •

Copy link
Copy Markdown

Hide the message strings that are only used in DEBUG case behind DEBUG.

This will eschew expensive String manipulations which show up as more than 50% of time in profiling subgraph isomorphism detection of an undirected graph with 38 nodes with a subgraph of 10 nodes and similarly for full isomorphism.


Johannes M Dieterich added 2 commits April 23, 2020 17:40
@iotamudelta

Copy link
Copy Markdown
Author

This will also help w/ excessive memory traffic and garbage collection - I'm seeing 645 GB (!!!) byte[] total in 30s of flight recording originating from isFeasiblePair()'s use of Strings.

Johannes M Dieterich added 2 commits April 23, 2020 23:14
@d-michail

Copy link
Copy Markdown
Member

Thanks for the optimization. It is indeed necessary.

Just a short survey about your use of the library? How large are the graphs that you are running this algorithm? How long does it take to finish? How much memory does it consume (after the useless strings removal)? Thanks

@iotamudelta

Copy link
Copy Markdown
Author

@d-michail thanks for the response!

The use case is within a global optimization context. Undirected graphs will be in the dozens of nodes typically (although I can foresee going into low hundreds) with total number of vertices also in that ballpark (subgraphs somewhat smaller). I'm currently running this for every step in the optimization (so thousands of times) - I seem to be able to do below a thousand calls per second (which is unfortunately too slow). Memory consumption is "ok" - flight recorder has me believe it's 100MB sustained for this use case for 4 threads. Lots of GC traffic (see below).

The biggest bottleneck right now is the GraphOrdering.getEdge() call from isFeasiblePair(). It does constructs a great number of UnorderedPair objects (16GB per minute according to flight recorder) and invokes Object.equals on their content. So that'd be the next thing that needs to get fixed - it accounts for 50% of memory traffic and CPU time.

@jsichi

jsichi commented Apr 27, 2020

Copy link
Copy Markdown
Member

Thanks!

@jsichi
jsichi merged commit 78fa57a into jgrapht:master Apr 27, 2020
@jsichi

jsichi commented Apr 27, 2020

Copy link
Copy Markdown
Member

Could you give us your real name for the credits?

@iotamudelta

Copy link
Copy Markdown
Author

@jsichi sorry, new laptop wasn't set up right yet. Johannes M Dieterich.

Thanks!

@iotamudelta
iotamudelta deleted the less_string branch April 27, 2020 22:23
@jsichi

jsichi commented Apr 27, 2020

Copy link
Copy Markdown
Member

Great, I've updated with your real name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants