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 | setLivePrintActive (bool active) |
Turn on or off live printing (if timing is off then live printing will be off too) 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... | |
MooseApp & | mooseApp () |
const PerfNode & | rootNode () const |
template<typename Functor > | |
void | treeRecurse (const Functor &act, const unsigned int level=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, CONTINUED, 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 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 *, 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... | |
bool | _active |
Whether or not timing is active. More... | |
std::atomic< bool > | _live_print_active |
Whether or not live printing 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 |
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 204 of file PerfGraph.h.
|
protected |
Definition at line 206 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. |
CONTINUED | Something else printed, but now this printed again. |
FINISHED | The section is complete. |
Definition at line 241 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 27 of file PerfGraph.C.
PerfGraph::~PerfGraph | ( | ) |
Destructor.
Definition at line 60 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(), setLivePrintActive(), and setLivePrintAll().
|
inlineprotected |
Add the information to the execution list.
Should only be called by push() and pop()
Definition at line 150 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 63 of file PerfGraph.C.
Referenced by MooseApp::setupOptions(), and ~PerfGraph().
|
inline |
|
protected |
Remove a Node from the end of the current scope.
Note: only accessible by using PerfGuard!
Definition at line 227 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 402 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 409 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 416 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 181 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 318 of file PerfGraph.C.
Referenced by update().
|
inline |
Definition at line 186 of file PerfGraph.h.
Referenced by to_json().
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 89 of file PerfGraph.C.
Referenced by PerfGraphData::finalize().
|
inline |
Turn on or off timing.
Definition at line 129 of file PerfGraph.h.
Referenced by MooseApp::setupOptions().
Sert the memory limit before a message prints.
Definition at line 157 of file PerfGraph.h.
Referenced by CommonOutputAction::act().
|
inline |
Turn on or off live printing (if timing is off then live printing will be off too)
Definition at line 134 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 = MAX_STACK_SIZE , |
||
const bool | heaviest = false |
||
) | const |
Definition at line 479 of file PerfGraph.h.
Referenced by treeTable().
|
private |
Definition at line 441 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 339 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 271 of file PerfGraph.C.
Referenced by dataLoad(), dataStore(), printHeaviestSections(), sectionData(), and treeTable().
Definition at line 500 of file PerfGraph.C.
Definition at line 486 of file PerfGraph.C.
|
friend |
Definition at line 418 of file PerfGraph.h.
|
friend |
Definition at line 417 of file PerfGraph.h.
|
protected |
Whether or not timing is active.
Definition at line 387 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(), MeshDiagnosticsGenerator::checkElementOverlap(), MeshDiagnosticsGenerator::checkElementTypes(), MeshDiagnosticsGenerator::checkElementVolumes(), FEProblemBase::checkExceptionAndStopSolve(), MeshDiagnosticsGenerator::checkLocalJacobians(), MeshDiagnosticsGenerator::checkNonConformalMesh(), MeshDiagnosticsGenerator::checkNonConformalMeshFromAdaptivity(), MeshDiagnosticsGenerator::checkNonPlanarSides(), FEProblemBase::checkProblemIntegrity(), ReferenceResidualProblem::checkRelativeConvergence(), MeshDiagnosticsGenerator::checkSidesetsOrientation(), IterationAdaptiveDT::computeAdaptiveDT(), Transient::computeConstrainedDT(), FixedPointSolve::computeCustomConvergencePostprocessor(), NonlinearSystemBase::computeDamping(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInitialDT(), IterationAdaptiveDT::computeInterpolationDT(), NonlinearSystemBase::computeScaling(), Problem::console(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), MultiApp::createApp(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MessageFromInput::execute(), Steady::execute(), Eigenvalue::execute(), ActionWarehouse::executeActionsWithAction(), ActionWarehouse::executeAllActions(), ElementQualityChecker::finalize(), FEProblemBase::finishMultiAppStep(), MeshRepairGenerator::fixOverlappingNodes(), CoarsenBlockGenerator::generate(), MeshGenerator::generateInternal(), VariableCondensationPreconditioner::getDofToCondense(), InversePowerMethod::init(), NonlinearEigen::init(), FEProblemBase::initialAdaptMesh(), EigenExecutionerBase::inversePowerIteration(), FEProblemBase::joinAndFinalize(), Transient::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), FEProblemBase::logAdd(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), MooseBaseErrorInterface::mooseDeprecated(), MooseBaseErrorInterface::mooseInfo(), MooseBaseErrorInterface::mooseWarning(), MooseBaseErrorInterface::mooseWarningNonPrefixed(), ReferenceResidualProblem::nonlinearConvergenceSetup(), ReporterDebugOutput::output(), PerfGraphOutput::output(), MaterialPropertyDebugOutput::output(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), Console::outputPostprocessors(), PseudoTimestep::outputPseudoTimestep(), Console::outputReporters(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), AB2PredictorCorrector::postSolve(), ActionWarehouse::printActionDependencySets(), SolutionInvalidity::printDebug(), EigenExecutionerBase::printEigenvalue(), SecantSolve::printFixedPointConvergenceHistory(), SteffensenSolve::printFixedPointConvergenceHistory(), PicardSolve::printFixedPointConvergenceHistory(), FixedPointSolve::printFixedPointConvergenceReason(), PerfGraphLivePrint::printLiveMessage(), MaterialPropertyDebugOutput::printMaterialMap(), PerfGraphLivePrint::printStats(), AutomaticMortarGeneration::projectPrimaryNodesSinglePair(), AutomaticMortarGeneration::projectSecondaryNodesSinglePair(), CoarsenBlockGenerator::recursiveCoarsen(), SolutionTimeAdaptiveDT::rejectStep(), MultiApp::restore(), FEProblemBase::restoreMultiApps(), SimplePredictor::shouldApply(), Checkpoint::shouldOutput(), SubProblem::showFunctorRequestors(), SubProblem::showFunctors(), FullSolveMultiApp::showStatusMessage(), FEProblemSolve::solve(), FixedPointSolve::solve(), NonlinearSystem::solve(), EigenProblem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), LStableDirk4::solve(), AStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), FixedPointSolve::solveStep(), PerfGraphLivePrint::start(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), Transient::takeStep(), 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 378 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 384 of file PerfGraph.h.
Referenced by printHeaviestSections(), sectionData(), treeRecurseInternal(), and update().
|
protected |
The current node position in the stack.
Definition at line 355 of file PerfGraph.h.
|
protected |
Tell the print thread to teardown.
Definition at line 396 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 399 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 337 of file PerfGraph.h.
Referenced by disableLivePrint(), PerfGraph(), pop(), and push().
|
protected |
The promise to the print thread that will signal when to stop.
Definition at line 393 of file PerfGraph.h.
|
protected |
A circular buffer for holding the execution list, this is read by the printing loop.
Definition at line 361 of file PerfGraph.h.
Referenced by addToExecutionList().
|
protected |
Where the print thread should start reading the execution list.
Definition at line 364 of file PerfGraph.h.
|
protected |
Where the print thread should stop reading the execution list.
Definition at line 367 of file PerfGraph.h.
Referenced by addToExecutionList(), and PerfGraphLivePrint::start().
|
protected |
The condition_variable to wake the print thread.
Definition at line 402 of file PerfGraph.h.
Referenced by disableLivePrint(), pop(), and PerfGraphLivePrint::start().
|
protected |
The object that is doing live printing.
Definition at line 411 of file PerfGraph.h.
Referenced by PerfGraph().
|
protected |
Whether or not live printing is active.
Definition at line 390 of file PerfGraph.h.
Referenced by pop(), push(), setLivePrintActive(), and PerfGraphLivePrint::start().
|
protected |
Whether or not to put everything in the perf graph.
Definition at line 334 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 408 of file PerfGraph.h.
Referenced by setLiveMemoryLimit().
|
protected |
The time limit before a message is printed (in seconds)
Definition at line 405 of file PerfGraph.h.
Referenced by setLiveTimeLimit().
|
protected |
|
protected |
The PerfGraphRegistry.
Definition at line 340 of file PerfGraph.h.
Referenced by dataLoad(), dataStore(), pop(), printHeaviestSections(), push(), recursivelyUpdate(), sectionData(), treeRecurseInternal(), and update().
|
protected |
This processor id.
Definition at line 343 of file PerfGraph.h.
Referenced by disableLivePrint(), PerfGraph(), pop(), and push().
|
protected |
The thread for printing sections as they execute.
Definition at line 414 of file PerfGraph.h.
Referenced by disableLivePrint(), and PerfGraph().
|
protected |
|
protected |
The root node of the graph.
Definition at line 352 of file PerfGraph.h.
Referenced by dataLoad(), dataStore(), push(), rootNode(), treeRecurse(), treeTable(), and update().
|
protected |
The id for the root node.
Definition at line 349 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 358 of file PerfGraph.h.