RMG-Java icon indicating copy to clipboard operation
RMG-Java copied to clipboard

General speed optimization

Open rwest opened this issue 13 years ago • 7 comments

This 'issue' is a place to collect thoughts about general speed and efficiency improvements.

There's a pretty minimal sampling java profiler at http://code.google.com/p/jsamp/wiki/Documentation that you can just attach to a running JVM on a compute node, leave it for a few hours, come back and kill it, and analyze the collected samples.

I sampled every 100ms for ~4 hours (5 enlargement iterations) on a job of mine with pdep, a large seed, and 32 reaction systems, but no pruning. Stats when I started sampling were:

The model core has 20524 reactions and 281 species. The model edge has 314641 reactions and 43038 species. There are 48093 partial pressure-dependent networks containing 50250 path and 13346 net reactions. The chem.inp file has 281 species (excluding inert gases). The chem.inp file has 20149 reactions (excluding duplicates). Running time: 2248.988 min Memory used: 1778.66 MB / 3585.67 MB (49.60%)

It spends roughly:

  • 90% solving the reaction systems jing.rxnSys.JDASSL.solve
  • 60% waiting for the unix proces (presumably mostly DASSL) java.lang.UNIXProcess.waitForProcessExit
  • 26% checking if reaction structures are equal jing.rxn.Structure.equals
  • 22% in java.util.LinkedList.clone (possibly in the above Structure.equals call?)
  • only 5% enlarging the model jing.rxnSys.ReactionModelGenerator.enlargeReactionModel

First observation: solving all the reaction systems each time this way is incredibly wasteful - especially as 30 of my 32 reaction systems are valid and only 2 are being used to enlarge the model!

rwest avatar May 17 '11 19:05 rwest

In your observation, I'm not sure what you mean by wasteful...the systems need to be solved to determine they are valid, no?

gmagoon avatar May 17 '11 20:05 gmagoon

Here's the longer output (curtailed at 10 samples):

Self counts:                                                              
java.net.PlainSocketImpl.socketAccept                           159333     37.8%
java.lang.UNIXProcess.waitForProcessExit                        95934      22.8%
java.io.FileInputStream.readBytes                               95847      22.7%
java.util.LinkedList.clone                                      34920      8.3%
jing.rxn.Structure.equals                                       7288       1.7%
java.lang.Object.wait                                           7094       1.7%
java.lang.UNIXProcess.forkAndExec                               6929       1.6%
jing.chem.SpeciesDictionary.getSpeciesFromName                  5263       1.2%
java.lang.StrictMath.floor                                      3457       0.8%
java.lang.StrictMath.acos                                       1603       0.4%
jing.rxn.PDepNetwork.contains                                   455        0.1%
java.lang.String.length                                         318        0.1%
java.util.LinkedList.indexOf                                    237        0.1%
jing.rxn.Reaction.calculateHrxn                                 214        0.1%
jing.rxn.Reaction.calculateTotalRate                            183        0.0%
jing.chemUtil.Graph.getNodeList                                 163        0.0%
java.io.FileOutputStream.writeBytes                             145        0.0%
jing.chemUtil.GraphComponent.isEquivalent                       143        0.0%
jing.rxn.Reaction.calculateKeq                                  133        0.0%
java.util.Stack.push                                            130        0.0%
jing.chemUtil.Graph.addMissingHydrogen                          117        0.0%
jing.chemUtil.Node.contentSub                                   102        0.0%
jing.chemUtil.Graph.isEquivalent                                97         0.0%
jing.rxnSys.ReactionSystem.appendUnreactedSpeciesStatus         96         0.0%
jing.chemUtil.Graph.resetMatchedGC                              73         0.0%
java.util.Stack.pop                                             73         0.0%
jing.rxn.PDepReaction.calculateForwardFlux                      70         0.0%
jing.param.Temperature.<init>                                   61         0.0%
sun.misc.FloatingDecimal.multPow52                              56         0.0%
java.util.ArrayList.iterator                                    52         0.0%
java.util.HashMap.getEntry                                      51         0.0%
sun.misc.FloatingDecimal.doubleValue                            38         0.0%
java.lang.String.<init>                                         38         0.0%
jing.chemUtil.GraphComponent.isSubCentralMatched                34         0.0%
java.lang.Integer.hashCode                                      30         0.0%
java.util.LinkedList.access$200                                 29         0.0%
sun.misc.FloatingDecimal.readJavaFormatString                   28         0.0%
jing.chemUtil.GraphComponent.isSub                              25         0.0%
java.lang.Integer.getChars                                      24         0.0%
java.lang.Object.hashCode                                       23         0.0%
java.io.FileOutputStream.open                                   23         0.0%
jing.chemUtil.Graph.toStringWithoutCentralID                    22         0.0%
java.lang.AbstractStringBuilder.append                          22         0.0%
java.security.AccessController.doPrivileged                     21         0.0%
jing.rxnSys.JDAS.getAutoEdgeReactionInfo                        20         0.0%
java.util.LinkedList.addAll                                     19         0.0%
jing.chemUtil.Node.toStringWithoutCentralID                     17         0.0%
java.util.HashMap.transfer                                      14         0.0%
jing.rxnSys.JDAS.generatePDepReactionList                       13         0.0%
jing.chemUtil.Graph.getNodeNumber                               13         0.0%
jing.chem.ChemElement.translateName                             13         0.0%
jing.rxnSys.JDAS.generatePDepODEReactionList                    11         0.0%
java.lang.StringBuilder.append                                  11         0.0%
java.lang.Integer.toString                                      11         0.0%
jing.rxnSys.CoreEdgeReactionModel.reactantsInCoreQ              10         0.0%
jing.rxn.PDepNetwork.getCoreReactions                           10         0.0%
jing.chemUtil.Arc.neighborOk                                    10         0.0%
java.util.Arrays.copyOfRange                                    10         0.0%

                                                                          
Total counts:                                                             
jing.rxnSys.ReactionModelGenerator.modelGeneration              159334     37.8%
ca.evanjones.JSamp$1.run                                        159334     37.8%
RMG.main                                                        159334     37.8%
java.net.ServerSocket.implAccept                                159333     37.8%
java.net.ServerSocket.accept                                    159333     37.8%
java.net.PlainSocketImpl.socketAccept                           159333     37.8%
java.net.AbstractPlainSocketImpl.accept                         159333     37.8%
jing.rxnSys.ReactionSystem.solveReactionSystem                  143926     34.1%
jing.rxnSys.JDASSL.solve                                        142437     33.8%
java.lang.UNIXProcess$1$1.run                                   102888     24.4%
java.lang.UNIXProcess.waitForProcessExit                        95934      22.8%
java.lang.UNIXProcess.access$900                                95934      22.8%
java.io.BufferedReader.readLine                                 95888      22.7%
sun.nio.cs.StreamDecoder.read                                   95848      22.7%
sun.nio.cs.StreamDecoder.implRead                               95848      22.7%
java.io.InputStreamReader.read                                  95848      22.7%
java.io.BufferedReader.fill                                     95848      22.7%
sun.nio.cs.StreamDecoder.readBytes                              95847      22.7%
java.io.FileInputStream.readBytes                               95847      22.7%
java.io.FileInputStream.read                                    95847      22.7%
java.io.BufferedInputStream.read                                95823      22.7%
java.io.BufferedInputStream.read1                               95822      22.7%
jing.rxnSys.JDASSL.solveDAE                                     92272      21.9%
java.util.LinkedList.indexOf                                    42465      10.1%
java.util.LinkedList.contains                                   42465      10.1%
jing.rxn.Structure.equals                                       42248      10.0%
jing.rxn.Reaction.equals                                        42228      10.0%
jing.rxnSys.JDAS.generatePDepODEReactionList                    41290      9.8%
jing.rxnSys.JDAS.generatePDepReactionList                       41082      9.7%
jing.rxn.Structure.isCGListEquivalentAsSpecies                  34960      8.3%
java.util.LinkedList.clone                                      34927      8.3%
jing.rxnSys.ReactionModelGenerator.enlargeReactionModel         7300       1.7%
jing.rxnSys.RateBasedPDepRME.enlargeReactionModel               7295       1.7%
jing.rxnSys.RateBasedPDepRME.addSpeciesToCore                   7168       1.7%
java.lang.Object.wait                                           7094       1.7%
java.lang.Runtime.exec                                          6993       1.7%
java.lang.ProcessImpl.start                                     6993       1.7%
java.lang.ProcessBuilder.start                                  6993       1.7%
java.lang.UNIXProcess.<init>                                    6991       1.7%
java.lang.UNIXProcess$Gate.waitForExit                          6981       1.7%
java.lang.UNIXProcess.access$500                                6930       1.6%
java.lang.UNIXProcess.forkAndExec                               6929       1.6%
jing.rxn.TemplateReactionGenerator.react                        6637       1.6%
jing.rxn.ReactionTemplate.reactTwoReactants                     6626       1.6%
jing.chem.Species.make                                          6348       1.5%
jing.chem.Species.<init>                                        5807       1.4%
jing.chem.SpeciesDictionary.getSpeciesFromName                  5263       1.2%
jing.rxnSys.JDAS.transferReaction                               5015       1.2%
jing.chem.Species.generateInChI                                 4279       1.0%
jing.chem.ChemGraph.generateInChI                               4279       1.0%
jing.rxnSys.JDAS.generateTROEReactionList                       3999       0.9%
jing.rxnSys.JDAS.getAutoEdgeReactionInfo                        3857       0.9%
jing.rxnSys.JDAS.getEdgeReactionString                          3771       0.9%
java.lang.StrictMath.floor                                      3457       0.8%
java.lang.Math.floor                                            3457       0.8%
java.lang.StringBuilder.append                                  3392       0.8%
java.lang.AbstractStringBuilder.append                          3357       0.8%
sun.misc.FloatingDecimal.<init>                                 3322       0.8%
sun.misc.FloatingDecimal.dtoa                                   3321       0.8%
jing.chem.Species.findStablestThermoData                        3245       0.8%
jing.chem.ChemGraph.getThermoData                               3245       0.8%
jing.chem.ChemGraph.generateThermoData                          3245       0.8%
jing.chem.QMTP.generateThermoData                               3057       0.7%
jing.rxnSys.ReactionModelGenerator.writeInChIs                  2863       0.7%
jing.rxnSys.ReactionSystem.initializePDepNetwork                2549       0.6%
jing.rxn.FastMasterEqn.runPDepCalculation                       2532       0.6%
jing.chem.Species.generateNASAThermoData                        2502       0.6%
jing.chem.GATPFit.generateNASAThermoData                        2502       0.6%
jing.chem.GATPFit.callGATPFit                                   2502       0.6%
jing.chem.QMTP.generateQMThermoData                             2408       0.6%
jing.chem.ChemGraph.getModifiedInChIKeyAnew                     2149       0.5%
jing.chem.ChemGraph.getModifiedInChIAnew                        2131       0.5%
jing.rxn.PDepReaction.calculateRate                             1605       0.4%
jing.rxn.PDepRateConstant.calculateRate                         1605       0.4%
jing.rxn.ChebyshevPolynomials.calculateRate                     1603       0.4%
jing.rxn.ChebyshevPolynomials.calculatePhi                      1603       0.4%
java.lang.StrictMath.acos                                       1603       0.4%
java.lang.Math.acos                                             1603       0.4%
jing.rxnSys.Chemkin.writeChemkinInputFile                       1594       0.4%
jing.chem.QMTP.getPM3MM4ThermoDataUsingCCLib                    1577       0.4%
jing.rxnSys.Chemkin.writeChemkinPdepReactions                   1560       0.4%
jing.rxnSys.ReactionSystem.appendUnreactedSpeciesStatus         1481       0.4%
jing.chem.QMTP.getQMFileName                                    1418       0.3%
jing.chem.QMTP.parseMopacPM3                                    898        0.2%
jing.rxnSys.JDAS.generateThirdBodyReactionList                  866        0.2%
jing.chem.QMTP.parseGaussianPM3                                 680        0.2%
jing.rxn.PDepReaction.calculateForwardFlux                      652        0.2%
jing.chemUtil.Graph.isEquivalent                                601        0.1%
jing.chem.ChemGraph.isEquivalent                                593        0.1%
jing.chem.ChemGraph.equals                                      593        0.1%
jing.rxn.Reaction.calculateTotalRate                            582        0.1%
jing.rxn.TemplateReaction.calculateTotalPDepRate                581        0.1%
jing.rxn.PDepNetwork.getCoreReactions                           546        0.1%
jing.rxn.PDepNetwork.contains                                   518        0.1%
jing.rxn.PDepNetwork.addReactionToNetworks                      517        0.1%
java.util.Formatter.format                                      481        0.1%
java.lang.String.format                                         481        0.1%
jing.rxn.Reaction.toRestartString                               450        0.1%
jing.rxnSys.ReactionModelGenerator.writeEdgeReactions           428        0.1%
jing.rxn.PDepReaction.calculateReverseFlux                      409        0.1%
jing.chem.QMTP.determinePointGroupUsingSYMMETRYProgram          356        0.1%
jing.chem.QMTP.calculateThermoFromPM3MM4Calc                    356        0.1%
java.util.HashMap.put                                           349        0.1%
jing.chemUtil.GraphComponent.isEquivalent                       329        0.1%
java.util.Formatter.parse                                       321        0.1%
java.util.regex.Matcher.getTextLength                           318        0.1%
java.lang.String.length                                         318        0.1%
java.util.HashMap.getEntry                                      304        0.1%
jing.chem.SpeciesDictionary.putSpecies                          302        0.1%
jing.rxn.ReactionAdjList.reactChemGraph                         300        0.1%
jing.chem.ChemGraph.make                                        292        0.1%
jing.chem.ChemGraph.<init>                                      286        0.1%
jing.chemUtil.Graph.resetMatchedGC                              281        0.1%
jing.rxn.PDepNetwork.getSpeciesLeakFluxes                       263        0.1%
java.util.LinkedHashMap.get                                     243        0.1%
jing.rxn.ArrheniusKinetics.toChemkinString                      241        0.1%
jing.rxnSys.ReactionSystem.isModelValid                         240        0.1%
jing.rxnSys.RateBasedPDepVT.isModelValid                        240        0.1%
jing.rxnSys.FinishController.isModelValid                       240        0.1%
jing.chem.SpeciesDictionary.getSpecies                          233        0.1%
jing.chemUtil.Graph.isSub                                       228        0.1%
jing.rxn.Reaction.calculateHrxn                                 214        0.1%
jing.rxnSys.ReactionModelGenerator.writeCoreReactions           208        0.0%
jing.chem.Species.getFullName                                   197        0.0%
jing.chem.ChemGraph.isForbiddenStructure                        191        0.0%
jing.chem.GATP.generateThermoData                               188        0.0%
jing.rxn.ThirdBodyReaction.toRestartString                      179        0.0%
jing.rxn.Structure.toRestartString                              178        0.0%
java.util.regex.Matcher.find                                    171        0.0%
jing.rxnSys.JDASSL.readOutputFile                               168        0.0%
jing.chemUtil.Graph.getNodeList                                 165        0.0%
java.util.regex.Matcher.reset                                   161        0.0%
java.util.regex.Pattern.matcher                                 150        0.0%
java.util.regex.Matcher.<init>                                  150        0.0%
java.util.Formatter$FormatSpecifier.print                       150        0.0%
java.util.Formatter$FormatSpecifier.printFloat                  147        0.0%
sun.misc.FormattedFloatingDecimal.dtoa                          145        0.0%
sun.misc.FormattedFloatingDecimal.<init>                        145        0.0%
java.io.FileOutputStream.writeBytes                             145        0.0%
java.io.FileOutputStream.write                                  145        0.0%
sun.nio.cs.StreamEncoder.writeBytes                             144        0.0%
jing.rxn.ThirdBodyReaction.toChemkinString                      144        0.0%
jing.rxn.TROEReaction.toRestartString                           143        0.0%
java.lang.Double.parseDouble                                    138        0.0%
java.io.Writer.write                                            136        0.0%
java.io.BufferedWriter.write                                    136        0.0%
jing.chemUtil.GraphComponent.isSub                              135        0.0%
jing.chemUtil.Graph.addMissingHydrogen                          135        0.0%
sun.nio.cs.StreamEncoder.write                                  133        0.0%
sun.nio.cs.StreamEncoder.implWrite                              133        0.0%
jing.rxn.Reaction.calculateKeq                                  133        0.0%
java.util.Stack.push                                            133        0.0%
java.io.OutputStreamWriter.write                                133        0.0%
java.io.BufferedWriter.flushBuffer                              133        0.0%
jing.chem.PrimaryThermoLibrary.getThermoData                    129        0.0%
jing.rxn.TROEReaction.toChemkinString                           115        0.0%
jing.chemUtil.Node.contentSub                                   114        0.0%
java.lang.UNIXProcess.waitFor                                   114        0.0%
jing.rxnSys.ReactionModelGenerator.writePDepNetworks            111        0.0%
jing.chemUtil.HierarchyTreeNode.findMatchedPath                 110        0.0%
jing.chemUtil.HierarchyTree.findMatchedPath                     110        0.0%
jing.chem.ChemGraph.isSubAtCentralNodes                         110        0.0%
sun.misc.FloatingDecimal.doubleValue                            108        0.0%
jing.chemUtil.Graph.isSubAtCentralNodes                         108        0.0%
jing.chem.GATP.getGAGroup                                       103        0.0%
jing.rxnSys.JDAS.generateLindemannReactionList                  96         0.0%
jing.rxnSys.ReactionModelGenerator.writeEdgeSpecies             91         0.0%
jing.rxnSys.RateBasedPDepRME.makeSpeciesIncluded                89         0.0%
jing.rxn.PDepNetwork.makeIsomerIncluded                         87         0.0%
jing.chemUtil.GraphComponent.resetStack                         80         0.0%
jing.chem.ChemGraph.toString                                    73         0.0%
java.util.Stack.pop                                             73         0.0%
jing.rxn.TemplateReactionGenerator.generatePdepReactions        72         0.0%
jing.rxn.ReactionTemplate.reactOneReactant                      72         0.0%
jing.rxn.PDepIsomer.generatePaths                               72         0.0%
jing.chemUtil.Graph.toStringWithoutCentralID                    72         0.0%
jing.chemUtil.GraphComponent.isSubCentralMatched                68         0.0%
jing.chem.Species.equals                                        63         0.0%
java.util.HashSet.contains                                      63         0.0%
java.util.HashMap.containsKey                                   63         0.0%
jing.param.Temperature.<init>                                   61         0.0%
jing.rxn.PDepReaction.toRestartString                           58         0.0%
sun.misc.FloatingDecimal.multPow52                              57         0.0%
jing.chemUtil.Graph.getArcList                                  52         0.0%
java.util.ArrayList.iterator                                    52         0.0%
jing.chemUtil.Node.toStringWithoutCentralID                     50         0.0%
jing.chem.ThermoGAGroupLibrary.findGAGroup                      48         0.0%
java.lang.String.<init>                                         48         0.0%
jing.chem.Species.calculateTransportParameters                  42         0.0%
jing.chem.GATransportP.generateTransportData                    42         0.0%
jing.chem.ChemGraph.getTransportData                            42         0.0%
jing.chem.ChemGraph.generateTransportData                       42         0.0%
jing.rxnSys.ReactionModelGenerator.writeRatesAndParameters      39         0.0%
jing.chem.QMTP.successfulGaussianResultExistsQ                  37         0.0%
jing.chem.ChemGraph.whichForbiddenStructures                    37         0.0%
jing.rxn.ReactionTemplate.findRateConstant                      35         0.0%
jing.chem.Species.generateSpectroscopicData                     32         0.0%
jing.chem.FrequencyGroups.generateFreqData                      32         0.0%
java.util.LinkedList$ListItr.remove                             30         0.0%
java.security.AccessController.doPrivileged                     30         0.0%
java.lang.Integer.hashCode                                      30         0.0%
java.util.LinkedList.access$200                                 29         0.0%
sun.misc.FloatingDecimal.readJavaFormatString                   28         0.0%
java.lang.String.valueOf                                        27         0.0%
java.io.FileWriter.<init>                                       27         0.0%
java.io.FileOutputStream.<init>                                 27         0.0%
jing.rxn.StructureTemplate.getMatchedFunctionalGroup            26         0.0%
jing.rxnSys.Chemkin.writeGridOfRateCoeffs                       25         0.0%
jing.chemUtil.GraphComponent.addNeighbor                        25         0.0%
jing.rxn.ReactionAdjList.react                                  24         0.0%
jing.chem.Species.generateMolFileString                         24         0.0%
java.lang.Integer.toString                                      24         0.0%
java.lang.Integer.getChars                                      24         0.0%
jing.chemUtil.Graph.copy                                        23         0.0%
jing.chemUtil.Arc.addNeighbor                                   23         0.0%
java.lang.Object.hashCode                                       23         0.0%
java.io.FileOutputStream.open                                   23         0.0%
jing.chemUtil.Graph.connect                                     22         0.0%
jing.chemUtil.Graph.addArcBetween                               22         0.0%
jing.chemUtil.Arc.link                                          22         0.0%
jing.rxnSys.CoreEdgeReactionModel.categorizeReaction            21         0.0%
jing.rxn.LibraryReactionGenerator.dupreaction                   20         0.0%
jing.rxn.LibraryReactionGenerator.RemoveDuplicateReac           20         0.0%
jing.rxnSys.Logger.log                                          19         0.0%
jing.rxnSys.Logger.info                                         19         0.0%
jing.chem.GATransportP.getGAGroup                               19         0.0%
java.util.LinkedList.addAll                                     19         0.0%
jing.rxnSys.ReactionModelGenerator.printModelSize               18         0.0%
jing.chem.ThermoGAGroupLibrary.findRadicalGroup                 18         0.0%
jing.chem.Species.generateResonanceIsomers                      18         0.0%
jing.rxnSys.CoreEdgeReactionModel.reactantsInCoreQ              17         0.0%
jing.rxnSys.CoreEdgeReactionModel.containsAsUnreactedSpecies    16         0.0%
jing.rxn.PDepNetwork.getNumCoreReactions                        16         0.0%
jing.chem.PrimaryTransportLibrary.getTransportData              16         0.0%
jing.chem.ChemElement.make                                      15         0.0%
java.util.LinkedList.<init>                                     15         0.0%
jing.rxnSys.SystemSnapshot.getSpeciesStatus                     14         0.0%
jing.rxn.TemplateReaction.makeTemplateReaction                  14         0.0%
jing.chemUtil.Graph.combine                                     14         0.0%
java.util.HashMap.transfer                                      14         0.0%
java.util.HashMap.resize                                        14         0.0%
java.util.HashMap.addEntry                                      14         0.0%
java.io.PrintStream.println                                     14         0.0%
jing.rxnSys.JDAS.setupInputFile                                 13         0.0%
jing.rxnSys.JDAS.generateSpeciesStatus                          13         0.0%
jing.rxn.PDepReaction.toChemkinString                           13         0.0%
jing.chemUtil.Graph.getNodeNumber                               13         0.0%
jing.chem.TransportGALibrary.findGroup                          13         0.0%
jing.chem.ThermoGAGroupLibrary.findGaucheGroup                  13         0.0%
jing.chem.ChemElement.translateName                             13         0.0%
java.io.PrintStream.write                                       13         0.0%
java.io.BufferedOutputStream.flushBuffer                        13         0.0%
sun.nio.cs.StreamEncoder.implFlushBuffer                        12         0.0%
sun.nio.cs.StreamEncoder.flushBuffer                            12         0.0%
java.io.OutputStreamWriter.flushBuffer                          12         0.0%
java.io.BufferedOutputStream.flush                              12         0.0%
jing.rxnSys.CoreEdgeReactionModel.containsAsReactedSpecies      11         0.0%
jing.rxn.Structure.hashCode                                     11         0.0%
jing.rxn.PDepReaction.toStringWithRate                          11         0.0%
jing.rxn.StructureTemplate.identifyReactedSites                 10         0.0%
jing.rxn.FastMasterEqn.writeInputString                         10         0.0%
jing.chemUtil.Node.getOtherNode                                 10         0.0%
jing.chemUtil.Graph.setCentralNode                              10         0.0%
jing.chemUtil.Graph.identifyAllOrderedMatchedSites              10         0.0%
jing.chemUtil.Graph.getCycleNumber                              10         0.0%
jing.chemUtil.Arc.neighborOk                                    10         0.0%
jing.chemUtil.Arc.getOtherNode                                  10         0.0%
jing.chem.ChemGraph.resetThermoSite                             10         0.0%
jing.chem.ChemGraph.identifyReactionMatchedSite                 10         0.0%
jing.chem.ChemGraph.getSymmetryNumber                           10         0.0%
jing.chem.ChemGraph.getCycleNumber                              10         0.0%
java.util.HashSet.add                                           10         0.0%
java.util.Arrays.copyOfRange                                    10         0.0%
java.lang.StringBuilder.toString                                10         0.0%
 

rwest avatar May 17 '11 20:05 rwest

I mean that it spends a large majority of the CPU time, not generating reaction mechanisms, but checking that the reaction systems that have been converged for the last 100 iterations are still converged on the 101st iteration, which, by my observations, they usually are. Perhaps something like 'once a system has been valid for two iterations in a row, stop checking it until everything is valid (or N iterations have passed), then check them all again' would be safe?

rwest avatar May 17 '11 20:05 rwest

A follow-up analysis on Richard's work, that will systematically expanded to more features, such as Pdep, QMTP, restart,etc...

Introduction: RMG-Java, at commit 8574cb8a6cbb5a250648de79921c552e2d3d4158 is used. The GUI plugin for Eclipse called “JVM Monitor” is used for the CPU Profiling. CPU Sampling technique is used.

Settings: A simulation of JP10 (C10H16) pyrolysis for 1 reaction system (1 set of conditions) without QMTP, without P-Dep activated, with one small seed mechanism, without pruning, without reading restart. A Intel Core 2 Duo CPU P9600 @ 2.66Ghz is used for this purpose. This is the state of the RMG generated model: The model core has 172 reactions and 73 species. The model edge has 43345 reactions and 4459 species. The chem.inp file has 73 species (excluding inert gases). The chem.inp file has 172 reactions (excluding duplicates). Running time: 35.795 min Memory used: 251.22 MB / 259.52 MB (96.80%)

Results After 3.5 K seconds of sampling at 50ms of all the RMG core packages, the following order of total method invocation time is observed at ReactionModelGenerator.modelGeneration as base method: • 78% : ReactionModelGenerator.enlargeReactionModel • 3% : ReactionSystem.solveReactionSystem • 13% : ReactionModelGenerator.writeEdgeReactions • 5% : ReactionModelGenerator.writeEdgeSpecies

In ReactionModelGenerator.enlargeReactionModel the majority (69% ) of the time is spent in ReactionTemplate.reactTwoReactants. The majority in that method is spent to species comparison during the creation of a new species: ChemGraph.equals(): 21% (SpeciesDictionary.getSpecies() + 5% (SpeciesDictionary.putSpecies()). Another great portion is the initialization of a chemgraph (ChemGraph.init()) ( 20 %) in the ChemGraph.make() method. 13% abs. is consumed by the verification to check for a forbidden structure.

Conclusion: for large molecules for which many possible reaction possibilities exist, writing the edge reactions/species already becomes an important bottleneck and consumes roughly 20% of the CPU.

ps: all % are absolute, compared to the total CPU time (3.5K sec)

Check the snapshot i took in Eclipse from the JVM monitor: http://cloud.github.com/downloads/nickvandewiele/RMG-Java/CPU%20profiling.bmp

nickvandewiele avatar Dec 19 '11 16:12 nickvandewiele

On second thoughts, the observations I made are significantly different from what @rwest saw during his trial. The main differences at Richard's run are the larger profiling time (> 4h compared to my < 1h), Pdep on and the large seed. I started with Leeds methane combustion. I am not sure if the profiling application influences these results, but that might be a culprit too.

nickvandewiele avatar Dec 19 '11 16:12 nickvandewiele

Very interesting, thanks Nick. I had some ideas for potential opportunities for speedup, which I put on a new branch: https://github.com/GreenGroup/RMG-Java/commit/a75660378885f95a1a9ec55e2d0dc164b881db5a Haven't gotten around to testing them yet, but I'll update this issue if the potential changes are useful/safe.

gmagoon avatar Dec 19 '11 16:12 gmagoon

Another possible difference: I had 32 reaction systems (this is partly why it spent a long time simulating them)

rwest avatar Dec 20 '11 20:12 rwest