The PerfGraph will hold the master list of all registered performance segments and the head PerfNode. More...
#include <PerfGraph.h>
Classes | |
| struct | CumulativeSectionInfo |
| Use to hold the cumulative time and memory for each section, which comes from all of the PerfNodes that contribute to said section. More... | |
| class | SectionIncrement |
| Use to hold an increment of time and memory for a section This is used in the LivePrint capability. More... | |
Public Types | |
| enum | DataType { SELF, CHILDREN, TOTAL, SELF_AVG, CHILDREN_AVG, TOTAL_AVG, SELF_PERCENT, CHILDREN_PERCENT, TOTAL_PERCENT, SELF_MEMORY, CHILDREN_MEMORY, TOTAL_MEMORY, CALLS } |
| For retrieving values. More... | |
| using | PerfGraphRegistry = moose::internal::PerfGraphRegistry |
Public Member Functions | |
| PerfGraph (const std::string &root_name, MooseApp &app, const bool live_all, const bool perf_graph_live) | |
| Create a new PerfGraph. More... | |
| ~PerfGraph () | |
| Destructor. More... | |
| void | print (const ConsoleStream &console, unsigned int level) |
| Print the tree out. More... | |
| void | printHeaviestBranch (const ConsoleStream &console) |
| Print out the heaviest branch through the tree. More... | |
| void | printHeaviestSections (const ConsoleStream &console, const unsigned int num_sections) |
| Print out the heaviest sections that were timed. More... | |
| bool | active () const |
| Whether or not timing is active. More... | |
| void | setActive (bool active) |
| Turn on or off timing. More... | |
| void | enableLivePrint () |
| Enables Live Print. More... | |
| void | disableLivePrint () |
| Completely disables Live Print (cannot be restarted) More... | |
| void | setLivePrintAll (bool active) |
| Forces all sections to be output live. More... | |
| void | setLiveTimeLimit (Real time_limit) |
| Set the time limit before a message prints. More... | |
| void | setLiveMemoryLimit (unsigned int mem_limit) |
| Sert the memory limit before a message prints. More... | |
| Real | sectionData (const DataType type, const std::string §ion_name, const bool must_exist=true) |
| Gets a PerfGraph result pertaining to a section. More... | |
| void | update () |
| Updates the time section_time and time for all currently running nodes. More... | |
| std::size_t | getMaxMemory () const |
| Get the maximum memory allocation in MB. More... | |
| MooseApp & | mooseApp () |
| const PerfNode & | rootNode () const |
| template<typename Functor > | |
| void | treeRecurse (const Functor &act, const unsigned int level=MOOSE_MAX_STACK_SIZE, const bool heaviest=false) const |
Static Public Member Functions | |
| static MooseEnum | dataTypeEnum () |
| DataType in a MooseEnum for use in InputParameters in objects that query the PerfGraph with sectionData. More... | |
Protected Types | |
| enum | IncrementState { STARTED, PRINTED, FINISHED } |
| The execution state of an increment. More... | |
| typedef VariadicTable< std::string, unsigned long int, Real, Real, Real, long int, Real, Real, Real, long int > | FullTable |
| typedef VariadicTable< std::string, unsigned long int, Real, Real, Real, long int > | HeaviestTable |
Protected Member Functions | |
| void | addToExecutionList (const PerfID id, const IncrementState state, const std::chrono::time_point< std::chrono::steady_clock > time, const long int memory) |
| Add the information to the execution list. More... | |
| void | push (const PerfID id) |
| Add a Node onto the end of the end of the current callstack. More... | |
| void | pop () |
| Remove a Node from the end of the current scope. More... | |
| void | recursivelyUpdate (const PerfNode ¤t_node) |
| Updates the cumulative self/children/total time and memory for each section across all nodes that contribute to said section in _cumulative_section_info. More... | |
Protected Attributes | |
| MooseApp & | _moose_app |
| The MooseApp. More... | |
| bool | _live_print_all |
| Whether or not to put everything in the perf graph. More... | |
| bool | _disable_live_print |
| Whether or not live print is disabled (cannot be turned on again) More... | |
| PerfGraphRegistry & | _perf_graph_registry |
| The PerfGraphRegistry. More... | |
| const libMesh::processor_id_type | _pid |
| This processor id. More... | |
| const std::string | _root_name |
| Name of the root node. More... | |
| const PerfID | _root_node_id |
| The id for the root node. More... | |
| const std::unique_ptr< PerfNode > | _root_node |
| The root node of the graph. More... | |
| int | _current_position |
| The current node position in the stack. More... | |
| std::array< PerfNode *, MOOSE_MAX_STACK_SIZE > | _stack |
| The full callstack. Currently capped at a depth of 100. More... | |
| std::array< SectionIncrement, MAX_EXECUTION_LIST_SIZE > | _execution_list |
| A circular buffer for holding the execution list, this is read by the printing loop. More... | |
| std::atomic< unsigned int > | _execution_list_begin |
| Where the print thread should start reading the execution list. More... | |
| std::atomic< unsigned int > | _execution_list_end |
| Where the print thread should stop reading the execution list. More... | |
| std::unordered_map< std::string, CumulativeSectionInfo > | _cumulative_section_info |
| The cumulative time and memory for each section. More... | |
| std::vector< CumulativeSectionInfo * > | _cumulative_section_info_ptrs |
| Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we don't need to iterate over the above map much - and it makes it easier to sort. More... | |
| std::atomic< std::size_t > | _max_memory |
| Maximum memory encountered during push and pop. More... | |
| bool | _active |
| Whether or not timing is active. More... | |
| std::promise< bool > | _done |
| The promise to the print thread that will signal when to stop. More... | |
| bool | _destructing |
| Tell the print thread to teardown. More... | |
| std::mutex | _destructing_mutex |
| The mutex to use with a condition_variable predicate to guard _destructing. More... | |
| std::condition_variable | _finished_section |
| The condition_variable to wake the print thread. More... | |
| std::atomic< Real > | _live_print_time_limit |
| The time limit before a message is printed (in seconds) More... | |
| std::atomic< unsigned int > | _live_print_mem_limit |
| The memory limit before a message is printed (in MB) More... | |
| const std::unique_ptr< PerfGraphLivePrint > | _live_print |
| The object that is doing live printing. More... | |
| std::thread | _print_thread |
| The thread for printing sections as they execute. More... | |
| const ConsoleStream | _console |
| An instance of helper class to write streams to the Console objects. More... | |
Private Member Functions | |
| FullTable | treeTable (const unsigned int level, const bool heaviest=false) |
| Helper for building a VariadicTable that represents the tree. More... | |
| template<typename Functor > | |
| void | treeRecurseInternal (const PerfNode &node, const Functor &act, const unsigned int level, const bool heaviest, unsigned int current_depth) const |
| void | updateMaxMemory (const std::size_t current_memory) |
| Update _max_memory if current_memory > _max_memory. More... | |
Friends | |
| class | PerfGuard |
| class | PerfGraphLivePrint |
| void | dataStore (std::ostream &, PerfGraph &, void *) |
| void | dataLoad (std::istream &, PerfGraph &, void *) |
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.
Definition at line 43 of file PerfGraph.h.
|
protected |
Definition at line 211 of file PerfGraph.h.
|
protected |
Definition at line 213 of file PerfGraph.h.
Definition at line 46 of file PerfGraph.h.
| enum PerfGraph::DataType |
For retrieving values.
| Enumerator | |
|---|---|
| SELF | |
| CHILDREN | |
| TOTAL | |
| SELF_AVG | |
| CHILDREN_AVG | |
| TOTAL_AVG | |
| SELF_PERCENT | |
| CHILDREN_PERCENT | |
| TOTAL_PERCENT | |
| SELF_MEMORY | |
| CHILDREN_MEMORY | |
| TOTAL_MEMORY | |
| CALLS | |
Definition at line 51 of file PerfGraph.h.
|
protected |
The execution state of an increment.
| Enumerator | |
|---|---|
| STARTED | Section just started running. |
| PRINTED | This section has already started printing. |
| FINISHED | The section is complete. |
Definition at line 248 of file PerfGraph.h.
| PerfGraph::PerfGraph | ( | const std::string & | root_name, |
| MooseApp & | app, | ||
| const bool | live_all, | ||
| const bool | perf_graph_live | ||
| ) |
Create a new PerfGraph.
| root_name | The name of the root node |
| app | The MooseApp this PerfGraph is for |
| live_all | Whether every message should be printed |
| perf_graph_live | Enable/disable PerfGraphLive (permanently) |
Definition at line 28 of file PerfGraph.C.
| PerfGraph::~PerfGraph | ( | ) |
Destructor.
Definition at line 55 of file PerfGraph.C.
|
inline |
Whether or not timing is active.
When not active no timing information will be kept
Definition at line 124 of file PerfGraph.h.
Referenced by setActive(), and setLivePrintAll().
|
inlineprotected |
Add the information to the execution list.
Should only be called by push() and pop()
Definition at line 155 of file PerfGraph.C.
Referenced by pop(), and push().
|
inlinestatic |
DataType in a MooseEnum for use in InputParameters in objects that query the PerfGraph with sectionData.
Definition at line 72 of file PerfGraph.h.
Referenced by PerfGraphData::validParams().
| void PerfGraph::disableLivePrint | ( | ) |
Completely disables Live Print (cannot be restarted)
Definition at line 68 of file PerfGraph.C.
Referenced by CommonOutputAction::act(), MooseApp::setupOptions(), and ~PerfGraph().
| void PerfGraph::enableLivePrint | ( | ) |
Enables Live Print.
Definition at line 58 of file PerfGraph.C.
|
inline |
Get the maximum memory allocation in MB.
This is thread safe.
Definition at line 183 of file PerfGraph.h.
Referenced by updateMaxMemory().
|
inline |
|
protected |
Remove a Node from the end of the current scope.
Note: only accessible by using PerfGuard!
Definition at line 236 of file PerfGraph.C.
Referenced by PerfGuard::~PerfGuard().
| void PerfGraph::print | ( | const ConsoleStream & | console, |
| unsigned int | level | ||
| ) |
Print the tree out.
| console | The output stream to output to |
| level | The log level, the higher the number the more output you get |
Definition at line 416 of file PerfGraph.C.
Referenced by PerfGraphOutput::output().
| void PerfGraph::printHeaviestBranch | ( | const ConsoleStream & | console | ) |
Print out the heaviest branch through the tree.
| console | The output stream to output to |
Definition at line 423 of file PerfGraph.C.
Referenced by PerfGraphOutput::output().
| void PerfGraph::printHeaviestSections | ( | const ConsoleStream & | console, |
| const unsigned int | num_sections | ||
| ) |
Print out the heaviest sections that were timed.
| console | The output stream to output to |
Definition at line 430 of file PerfGraph.C.
Referenced by PerfGraphOutput::output().
Add a Node onto the end of the end of the current callstack.
Note: only accessible by using PerfGuard!
Definition at line 186 of file PerfGraph.C.
Referenced by PerfGraph(), and PerfGuard::PerfGuard().
Updates the cumulative self/children/total time and memory for each section across all nodes that contribute to said section in _cumulative_section_info.
Note: requires that the contents in each CumulativeSectionInfo in _cumulative_section_info be initially resized and zeroed
| current_node | The current node to work on |
Definition at line 332 of file PerfGraph.C.
Referenced by update().
|
inline |
Definition at line 193 of file PerfGraph.h.
| Real PerfGraph::sectionData | ( | const DataType | type, |
| const std::string & | section_name, | ||
| const bool | must_exist = true |
||
| ) |
Gets a PerfGraph result pertaining to a section.
| type | The result type to retrieve |
| section_name | The name of the section |
| must_exist | Whether not the section must exist; if false and the section does not exist, returns 0, if true and the section does not exist, exit with an error |
Definition at line 94 of file PerfGraph.C.
Referenced by PerfGraphData::finalize().
|
inline |
Turn on or off timing.
Definition at line 129 of file PerfGraph.h.
Referenced by CommonOutputAction::act(), and MooseApp::setupOptions().
Sert the memory limit before a message prints.
Definition at line 157 of file PerfGraph.h.
Referenced by CommonOutputAction::act().
|
inline |
Forces all sections to be output live.
Definition at line 144 of file PerfGraph.h.
Set the time limit before a message prints.
Definition at line 149 of file PerfGraph.h.
Referenced by CommonOutputAction::act().
| void PerfGraph::treeRecurse | ( | const Functor & | act, |
| const unsigned int | level = MOOSE_MAX_STACK_SIZE, |
||
| const bool | heaviest = false |
||
| ) | const |
Definition at line 488 of file PerfGraph.h.
Referenced by treeTable().
|
private |
Definition at line 450 of file PerfGraph.h.
Referenced by treeRecurse().
|
private |
Helper for building a VariadicTable that represents the tree.
| level | The level to print out below (<=) |
| heaviest | Show only the heaviest branch |
Definition at line 353 of file PerfGraph.C.
Referenced by print(), and printHeaviestBranch().
| void PerfGraph::update | ( | ) |
Updates the time section_time and time for all currently running nodes.
Definition at line 285 of file PerfGraph.C.
Referenced by dataLoad(), dataStore(), printHeaviestSections(), sectionData(), and treeTable().
|
private |
Update _max_memory if current_memory > _max_memory.
Definition at line 500 of file PerfGraph.C.
Referenced by pop(), and push().
Definition at line 525 of file PerfGraph.C.
Definition at line 511 of file PerfGraph.C.
|
friend |
Definition at line 422 of file PerfGraph.h.
|
friend |
Definition at line 421 of file PerfGraph.h.
|
protected |
Whether or not timing is active.
Definition at line 394 of file PerfGraph.h.
Referenced by active(), pop(), push(), and setActive().
|
inherited |
An instance of helper class to write streams to the Console objects.
Definition at line 31 of file ConsoleStreamInterface.h.
Referenced by IterationAdaptiveDT::acceptStep(), MeshOnlyAction::act(), SetupDebugAction::act(), MaterialOutputAction::act(), Adaptivity::adaptMesh(), FEProblemBase::adaptMesh(), addToExecutionList(), SimplePredictor::apply(), SystemBase::applyScalingFactors(), MultiApp::backup(), FEProblemBase::backupMultiApps(), CoarsenedPiecewiseLinear::buildCoarsenedGrid(), DefaultSteadyStateConvergence::checkConvergence(), MeshDiagnosticsGenerator::checkElementOverlap(), MeshDiagnosticsGenerator::checkElementTypes(), MeshDiagnosticsGenerator::checkElementVolumes(), FEProblemBase::checkExceptionAndStopSolve(), SolverSystem::checkInvalidSolution(), MeshDiagnosticsGenerator::checkLocalJacobians(), MeshDiagnosticsGenerator::checkNonConformalMesh(), MeshDiagnosticsGenerator::checkNonConformalMeshFromAdaptivity(), MeshDiagnosticsGenerator::checkNonMatchingEdges(), MeshDiagnosticsGenerator::checkNonPlanarSides(), MeshDiagnosticsGenerator::checkPolygons(), FEProblemBase::checkProblemIntegrity(), ReferenceResidualConvergence::checkRelativeConvergence(), MeshDiagnosticsGenerator::checkSidesetsOrientation(), MeshDiagnosticsGenerator::checkWatertightNodesets(), MeshDiagnosticsGenerator::checkWatertightSidesets(), IterationAdaptiveDT::computeAdaptiveDT(), TransientBase::computeConstrainedDT(), DefaultMultiAppFixedPointConvergence::computeCustomConvergencePostprocessor(), NonlinearSystemBase::computeDamping(), FixedPointIterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInitialDT(), IterationAdaptiveDT::computeInterpolationDT(), LinearSystem::computeLinearSystemTags(), FEProblemBase::computeLinearSystemTags(), NonlinearSystemBase::computeScaling(), Problem::console(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), MultiApp::createApp(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MFEMSteady::execute(), MessageFromInput::execute(), SteadyBase::execute(), Eigenvalue::execute(), ActionWarehouse::executeActionsWithAction(), ActionWarehouse::executeAllActions(), MeshGeneratorSystem::executeMeshGenerators(), ElementQualityChecker::finalize(), SidesetAroundSubdomainUpdater::finalize(), FEProblemBase::finishMultiAppStep(), MeshRepairGenerator::fixOverlappingNodes(), SurfaceSubdomainsDelaunayRemesher::General2DDelaunay(), OrientSurfaceMeshGenerator::generate(), CoarsenBlockGenerator::generate(), PolyLineMeshFollowingNodeSetGenerator::generate(), MeshGenerator::generateInternal(), VariableCondensationPreconditioner::getDofToCondense(), InversePowerMethod::init(), NonlinearEigen::init(), FEProblemBase::initialAdaptMesh(), DefaultMultiAppFixedPointConvergence::initialize(), SubProblem::initialSetup(), EigenExecutionerBase::inversePowerIteration(), FEProblemBase::joinAndFinalize(), TransientBase::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), FEProblemBase::logAdd(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), SurfaceDelaunayGeneratorBase::meshNormalDeviation2D(), MooseBase::mooseDeprecated(), MooseBase::mooseDeprecatedNoTrace(), MooseBase::mooseInfo(), MooseBase::mooseWarning(), MooseBase::mooseWarningNonPrefixed(), ReferenceResidualConvergence::nonlinearConvergenceSetup(), ReporterDebugOutput::output(), PerfGraphOutput::output(), SolutionInvalidityOutput::output(), MaterialPropertyDebugOutput::output(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), WebServerControl::outputMessage(), Console::outputPostprocessors(), PseudoTimestep::outputPseudoTimestep(), Console::outputReporters(), DefaultMultiAppFixedPointConvergence::outputResidualNorm(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), AB2PredictorCorrector::postSolve(), ActionWarehouse::printActionDependencySets(), BlockRestrictionDebugOutput::printBlockRestrictionMap(), SolutionInvalidity::printDebug(), EigenExecutionerBase::printEigenvalue(), SecantSolve::printFixedPointConvergenceHistory(), SteffensenSolve::printFixedPointConvergenceHistory(), PicardSolve::printFixedPointConvergenceHistory(), FixedPointSolve::printFixedPointConvergenceReason(), PerfGraphLivePrint::printLiveMessage(), MaterialPropertyDebugOutput::printMaterialMap(), PerfGraphLivePrint::printStats(), NEML2Action::printSummary(), AutomaticMortarGeneration::projectPrimaryNodesSinglePair(), AutomaticMortarGeneration::projectSecondaryNodesSinglePair(), CoarsenBlockGenerator::recursiveCoarsen(), SolutionTimeAdaptiveDT::rejectStep(), MultiApp::restore(), FEProblemBase::restoreMultiApps(), FEProblemBase::restoreSolutions(), NonlinearSystemBase::setInitialSolution(), MooseApp::setupOptions(), Checkpoint::shouldOutput(), SubProblem::showFunctorRequestors(), SubProblem::showFunctors(), FullSolveMultiApp::showStatusMessage(), EigenProblem::solve(), FEProblemSolve::solve(), FixedPointSolve::solve(), NonlinearSystem::solve(), LinearSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), FixedPointSolve::solveStep(), MeshRepairGenerator::splitNonConvexPolygons(), PerfGraphLivePrint::start(), WebServerControl::startServer(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), MFEMTransient::takeStep(), TransientBase::takeStep(), TerminateChainControl::terminate(), SubProblem::timestepSetup(), FEProblemBase::updateMeshXFEM(), Convergence::verboseOutput(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().
|
protected |
The cumulative time and memory for each section.
This is updated on update() Note that this is total cumulative time/memory across every place that section is in the graph
I'm making this a map so that we can give out references to the values The three values are: self, children The map is on std::string because we might need to be able to retrieve timing values in a "late binding" situation before the section has been registered.
Definition at line 382 of file PerfGraph.h.
Referenced by recursivelyUpdate(), sectionData(), and update().
|
protected |
Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we don't need to iterate over the above map much - and it makes it easier to sort.
Definition at line 388 of file PerfGraph.h.
Referenced by printHeaviestSections(), sectionData(), treeRecurseInternal(), and update().
|
protected |
The current node position in the stack.
Definition at line 359 of file PerfGraph.h.
|
protected |
Tell the print thread to teardown.
Definition at line 400 of file PerfGraph.h.
Referenced by disableLivePrint(), and PerfGraphLivePrint::start().
|
protected |
The mutex to use with a condition_variable predicate to guard _destructing.
Definition at line 403 of file PerfGraph.h.
Referenced by disableLivePrint(), and PerfGraphLivePrint::start().
|
protected |
Whether or not live print is disabled (cannot be turned on again)
Definition at line 341 of file PerfGraph.h.
Referenced by disableLivePrint(), enableLivePrint(), pop(), and push().
|
protected |
The promise to the print thread that will signal when to stop.
Definition at line 397 of file PerfGraph.h.
|
protected |
A circular buffer for holding the execution list, this is read by the printing loop.
Definition at line 365 of file PerfGraph.h.
Referenced by addToExecutionList().
|
protected |
Where the print thread should start reading the execution list.
Definition at line 368 of file PerfGraph.h.
|
protected |
Where the print thread should stop reading the execution list.
Definition at line 371 of file PerfGraph.h.
Referenced by addToExecutionList(), and PerfGraphLivePrint::start().
|
protected |
The condition_variable to wake the print thread.
Definition at line 406 of file PerfGraph.h.
Referenced by disableLivePrint(), pop(), and PerfGraphLivePrint::start().
|
protected |
The object that is doing live printing.
Definition at line 415 of file PerfGraph.h.
Referenced by enableLivePrint().
|
protected |
Whether or not to put everything in the perf graph.
Definition at line 338 of file PerfGraph.h.
Referenced by PerfGraphLivePrint::iterateThroughExecutionList(), pop(), push(), and setLivePrintAll().
|
protected |
The memory limit before a message is printed (in MB)
Definition at line 412 of file PerfGraph.h.
Referenced by setLiveMemoryLimit().
|
protected |
The time limit before a message is printed (in seconds)
Definition at line 409 of file PerfGraph.h.
Referenced by setLiveTimeLimit().
|
protected |
Maximum memory encountered during push and pop.
Definition at line 391 of file PerfGraph.h.
Referenced by getMaxMemory(), and updateMaxMemory().
|
protected |
|
protected |
The PerfGraphRegistry.
Definition at line 344 of file PerfGraph.h.
Referenced by dataLoad(), dataStore(), pop(), printHeaviestSections(), push(), recursivelyUpdate(), sectionData(), treeRecurseInternal(), and update().
|
protected |
This processor id.
Definition at line 347 of file PerfGraph.h.
Referenced by disableLivePrint(), enableLivePrint(), pop(), and push().
|
protected |
The thread for printing sections as they execute.
Definition at line 418 of file PerfGraph.h.
Referenced by disableLivePrint(), and enableLivePrint().
|
protected |
|
protected |
The root node of the graph.
Definition at line 356 of file PerfGraph.h.
Referenced by dataLoad(), dataStore(), push(), rootNode(), treeRecurse(), treeTable(), and update().
|
protected |
The id for the root node.
Definition at line 353 of file PerfGraph.h.
Referenced by PerfGraph(), printHeaviestSections(), push(), and sectionData().
|
protected |
The full callstack. Currently capped at a depth of 100.
Definition at line 362 of file PerfGraph.h.
1.8.14