www.mooseframework.org
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
PerfGraph Class Reference

The PerfGraph will hold the master list of all registered performance segments and the head PerfNode. More...

#include <PerfGraph.h>

Inheritance diagram for PerfGraph:
[legend]

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 &section_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...
 
MooseAppmooseApp ()
 
const PerfNoderootNode () 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 intFullTable
 
typedef VariadicTable< std::string, unsigned long int, Real, Real, Real, long intHeaviestTable
 

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 &current_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 *)
 

Detailed Description

The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.

Definition at line 43 of file PerfGraph.h.

Member Typedef Documentation

◆ FullTable

typedef VariadicTable<std::string, unsigned long int, Real, Real, Real, long int, Real, Real, Real, long int> PerfGraph::FullTable
protected

Definition at line 204 of file PerfGraph.h.

◆ HeaviestTable

typedef VariadicTable<std::string, unsigned long int, Real, Real, Real, long int> PerfGraph::HeaviestTable
protected

Definition at line 206 of file PerfGraph.h.

◆ PerfGraphRegistry

Definition at line 46 of file PerfGraph.h.

Member Enumeration Documentation

◆ 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.

◆ IncrementState

enum PerfGraph::IncrementState
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.

242  {
244  STARTED,
245 
247  PRINTED,
248 
250  CONTINUED,
251 
253  FINISHED
254  };
The section is complete.
Definition: PerfGraph.h:253
This section has already started printing.
Definition: PerfGraph.h:247
Section just started running.
Definition: PerfGraph.h:244
Something else printed, but now this printed again.
Definition: PerfGraph.h:250

Constructor & Destructor Documentation

◆ PerfGraph()

PerfGraph::PerfGraph ( const std::string &  root_name,
MooseApp app,
const bool  live_all,
const bool  perf_graph_live 
)

Create a new PerfGraph.

Parameters
root_nameThe name of the root node
appThe MooseApp this PerfGraph is for
live_allWhether every message should be printed
perf_graph_liveEnable/disable PerfGraphLive (permanently)

Definition at line 27 of file PerfGraph.C.

32  _moose_app(app),
33  _live_print_all(live_all),
34  _disable_live_print(!perf_graph_live),
36  _pid(app.comm().rank()),
37  _root_name(root_name),
39  _root_node(std::make_unique<PerfNode>(_root_node_id)),
41  _stack(),
44  _active(true),
45  _live_print_active(true),
46  _destructing(false),
49  _live_print(std::make_unique<PerfGraphLivePrint>(*this, app))
50 {
51  if (_pid == 0 && !_disable_live_print)
52  {
53  // Start the printing thread
54  _print_thread = std::thread([this] { this->_live_print->start(); });
55  }
56 
58 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
const processor_id_type _pid
This processor id.
Definition: PerfGraph.h:343
std::thread _print_thread
The thread for printing sections as they execute.
Definition: PerfGraph.h:414
std::atomic< unsigned int > _live_print_mem_limit
The memory limit before a message is printed (in MB)
Definition: PerfGraph.h:408
std::atomic< unsigned int > _execution_list_begin
Where the print thread should start reading the execution list.
Definition: PerfGraph.h:364
const std::unique_ptr< PerfGraphLivePrint > _live_print
The object that is doing live printing.
Definition: PerfGraph.h:411
processor_id_type rank() const
std::atomic< unsigned int > _execution_list_end
Where the print thread should stop reading the execution list.
Definition: PerfGraph.h:367
const Parallel::Communicator & comm() const
bool _live_print_all
Whether or not to put everything in the perf graph.
Definition: PerfGraph.h:334
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
std::array< PerfNode *, MAX_STACK_SIZE > _stack
The full callstack. Currently capped at a depth of 100.
Definition: PerfGraph.h:358
bool _active
Whether or not timing is active.
Definition: PerfGraph.h:387
ConsoleStreamInterface(MooseApp &app)
A class for providing a helper stream object for writting message to all the Output objects...
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
MooseApp & _moose_app
The MooseApp.
Definition: PerfGraph.h:331
int _current_position
The current node position in the stack.
Definition: PerfGraph.h:355
bool _disable_live_print
Whether or not live print is disabled (cannot be turned on again)
Definition: PerfGraph.h:337
const std::string _root_name
Name of the root node.
Definition: PerfGraph.h:346
bool _destructing
Tell the print thread to teardown.
Definition: PerfGraph.h:396
void push(const PerfID id)
Add a Node onto the end of the end of the current callstack.
Definition: PerfGraph.C:181
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.
std::atomic< Real > _live_print_time_limit
The time limit before a message is printed (in seconds)
Definition: PerfGraph.h:405
std::atomic< bool > _live_print_active
Whether or not live printing is active.
Definition: PerfGraph.h:390
const PerfID _root_node_id
The id for the root node.
Definition: PerfGraph.h:349

◆ ~PerfGraph()

PerfGraph::~PerfGraph ( )

Destructor.

Definition at line 60 of file PerfGraph.C.

60 { disableLivePrint(); }
void disableLivePrint()
Completely disables Live Print (cannot be restarted)
Definition: PerfGraph.C:63

Member Function Documentation

◆ active()

bool PerfGraph::active ( ) const
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().

124 { return _active; }
bool _active
Whether or not timing is active.
Definition: PerfGraph.h:387

◆ addToExecutionList()

void PerfGraph::addToExecutionList ( const PerfID  id,
const IncrementState  state,
const std::chrono::time_point< std::chrono::steady_clock >  time,
const long int  memory 
)
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().

154 {
155  auto & section_increment = _execution_list[_execution_list_end];
156 
157  section_increment._id = id;
158  section_increment._state = state;
159  section_increment._time = time;
160  section_increment._memory = memory;
161  section_increment._beginning_num_printed = _console.numPrinted();
162 
163  // A note about this next section of code:
164  // It is only EVER run on the main thread - and therefore there can be
165  // no race conditions. All that is important here is that the print
166  // thread always sees a consistent value for _execution_list_end
167  auto next_execution_list_end = _execution_list_end + 1;
168 
169  // Are we at the end of our circular buffer?
170  if (next_execution_list_end >= MAX_EXECUTION_LIST_SIZE)
171  next_execution_list_end = 0;
172 
173  // This "release" will synchronize the above memory changes with the
174  // "acquire" in the printing thread
175  // All of the above memory operations will be seen by the
176  // printing thread before the printing thread sees this new value
177  _execution_list_end.store(next_execution_list_end, std::memory_order_release);
178 }
std::atomic< unsigned int > _execution_list_end
Where the print thread should stop reading the execution list.
Definition: PerfGraph.h:367
unsigned long long int numPrinted() const
The number of times something has been printed.
Definition: ConsoleStream.C:70
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::array< SectionIncrement, MAX_EXECUTION_LIST_SIZE > _execution_list
A circular buffer for holding the execution list, this is read by the printing loop.
Definition: PerfGraph.h:361

◆ dataTypeEnum()

static MooseEnum PerfGraph::dataTypeEnum ( )
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().

73  {
74  return MooseEnum(
75  "SELF CHILDREN TOTAL SELF_AVG CHILDREN_AVG TOTAL_AVG SELF_PERCENT CHILDREN_PERCENT "
76  "TOTAL_PERCENT SELF_MEMORY CHILDREN_MEMORY TOTAL_MEMORY CALLS");
77  }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31

◆ disableLivePrint()

void PerfGraph::disableLivePrint ( )

Completely disables Live Print (cannot be restarted)

Definition at line 63 of file PerfGraph.C.

Referenced by MooseApp::setupOptions(), and ~PerfGraph().

64 {
65  if (_pid == 0 && !_disable_live_print)
66  {
67  {
68  // Unlike using atomics for execution_thread_end
69  // here we actually lock to ensure that either the print thread
70  // immediately sees that we are destructing or is immediately
71  // notified with the below notification. Without doing this
72  // it would be possible (but unlikely) for the print thread to
73  // hang for 1 second at the end of execution (which would not be
74  // good anytime you are running lots of fast calculations back-to-back
75  // like during testing or stochastic sampling).
76  std::lock_guard<std::mutex> lock(_destructing_mutex);
77  _destructing = true;
78  }
79 
80  _finished_section.notify_one();
81 
82  _print_thread.join();
83 
84  _disable_live_print = true;
85  }
86 }
const processor_id_type _pid
This processor id.
Definition: PerfGraph.h:343
std::thread _print_thread
The thread for printing sections as they execute.
Definition: PerfGraph.h:414
std::condition_variable _finished_section
The condition_variable to wake the print thread.
Definition: PerfGraph.h:402
std::mutex _destructing_mutex
The mutex to use with a condition_variable predicate to guard _destructing.
Definition: PerfGraph.h:399
bool _disable_live_print
Whether or not live print is disabled (cannot be turned on again)
Definition: PerfGraph.h:337
bool _destructing
Tell the print thread to teardown.
Definition: PerfGraph.h:396

◆ mooseApp()

MooseApp& PerfGraph::mooseApp ( )
inline
Returns
The MooseApp

Definition at line 181 of file PerfGraph.h.

181 { return _moose_app; }
MooseApp & _moose_app
The MooseApp.
Definition: PerfGraph.h:331

◆ pop()

void PerfGraph::pop ( )
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().

228 {
229  if (!_active && !_live_print_active)
230  return;
231 
232  auto current_time = std::chrono::steady_clock::now();
233 
234  auto & current_node = _stack[_current_position];
235 
236  MemoryUtils::Stats stats;
237  auto memory_success = MemoryUtils::getMemoryStats(stats);
238 
239  long int current_memory = 0;
240 
241  if (memory_success)
242  current_memory =
244  else if (_current_position !=
245  -1) // If we weren't able to get the memory stats, let's just use the start memory
246  current_memory = _stack[_current_position]->startMemory();
247 
248  current_node->addTimeAndMemory(current_time, current_memory);
249 
251 
252  // Add this to the exection list
254  (!_perf_graph_registry.readSectionInfo(current_node->id())._live_message.empty() ||
256  {
257  addToExecutionList(current_node->id(), IncrementState::FINISHED, current_time, current_memory);
258 
259  // Tell the printing thread that a section has finished
260  //
261  // Note: no mutex is needed here because we're using an atomic
262  // in the predicate of the condition_variable in the thread
263  // This is technically correct - but there is a chance of missing a signal
264  // For us - that chance is low and doesn't matter (the timeout will just be hit
265  // instead). So - I would rather not have an extra lock here in the main thread.
266  _finished_section.notify_one();
267  }
268 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
const processor_id_type _pid
This processor id.
Definition: PerfGraph.h:343
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
std::size_t _physical_memory
Definition: MemoryUtils.h:23
bool _live_print_all
Whether or not to put everything in the perf graph.
Definition: PerfGraph.h:334
std::condition_variable _finished_section
The condition_variable to wake the print thread.
Definition: PerfGraph.h:402
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.
Definition: PerfGraph.C:150
std::array< PerfNode *, MAX_STACK_SIZE > _stack
The full callstack. Currently capped at a depth of 100.
Definition: PerfGraph.h:358
bool _active
Whether or not timing is active.
Definition: PerfGraph.h:387
int _current_position
The current node position in the stack.
Definition: PerfGraph.h:355
bool _disable_live_print
Whether or not live print is disabled (cannot be turned on again)
Definition: PerfGraph.h:337
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174
const PerfGraphSectionInfo & readSectionInfo(PerfID section_id) const
Special accessor just for PerfGraph so that no locking is needed in PerfGraph.
std::atomic< bool > _live_print_active
Whether or not live printing is active.
Definition: PerfGraph.h:390

◆ print()

void PerfGraph::print ( const ConsoleStream console,
unsigned int  level 
)

Print the tree out.

Parameters
consoleThe output stream to output to
levelThe log level, the higher the number the more output you get

Definition at line 402 of file PerfGraph.C.

Referenced by PerfGraphOutput::output().

403 {
404  console << "\nPerformance Graph:\n";
405  treeTable(level).print(console);
406 }
void print(StreamType &stream)
Pretty print the table of data.
Definition: VariadicTable.h:97
FullTable treeTable(const unsigned int level, const bool heaviest=false)
Helper for building a VariadicTable that represents the tree.
Definition: PerfGraph.C:339

◆ printHeaviestBranch()

void PerfGraph::printHeaviestBranch ( const ConsoleStream console)

Print out the heaviest branch through the tree.

Parameters
consoleThe output stream to output to

Definition at line 409 of file PerfGraph.C.

Referenced by PerfGraphOutput::output().

410 {
411  console << "\nHeaviest Branch:\n";
412  treeTable(MAX_STACK_SIZE, /* heaviest = */ true).print(console);
413 }
void print(StreamType &stream)
Pretty print the table of data.
Definition: VariadicTable.h:97
FullTable treeTable(const unsigned int level, const bool heaviest=false)
Helper for building a VariadicTable that represents the tree.
Definition: PerfGraph.C:339

◆ printHeaviestSections()

void PerfGraph::printHeaviestSections ( const ConsoleStream console,
const unsigned int  num_sections 
)

Print out the heaviest sections that were timed.

Parameters
consoleThe output stream to output to

Definition at line 416 of file PerfGraph.C.

Referenced by PerfGraphOutput::output().

417 {
418  update();
419 
420  console << "\nHeaviest Sections:\n";
421 
422  // Indirect Sort The Self Time
423  std::vector<size_t> sorted;
426  sorted,
427  [](CumulativeSectionInfo * lhs, CumulativeSectionInfo * rhs)
428  {
429  if (lhs && rhs)
430  return lhs->_self > rhs->_self;
431 
432  // If the LHS exists - it's definitely bigger than a non-existant RHS
433  if (lhs)
434  return true;
435 
436  // Both don't exist - so it doesn't matter how we sort them
437  return false;
438  });
439 
440  HeaviestTable vtable({"Section", "Calls", "Self(s)", "Avg.", "%", "Mem(MB)"}, 10);
441 
442  vtable.setColumnFormat({VariadicTableColumnFormat::AUTO, // Section; doesn't matter
448  );
449 
450  vtable.setColumnPrecision({
451  1, // Section
452  1, // Calls
453  3, // Time
454  3, // Avg.
455  2, // Percent
456  1 // Memory
457  });
458 
459  mooseAssert(!_cumulative_section_info_ptrs.empty(),
460  "update() must be run before printHeaviestSections()!");
461 
462  // The total time of the root node
463  auto total_root_time = _cumulative_section_info_ptrs[_root_node_id]->_total;
464 
465  // Now print out the largest ones
466  for (unsigned int i = 0; i < num_sections; i++)
467  {
468  auto id = sorted[i];
469 
471  continue;
472 
473  const auto & entry = *_cumulative_section_info_ptrs[id];
474  vtable.addRow(_perf_graph_registry.sectionInfo(id)._name, // Section
475  entry._num_calls, // Calls
476  entry._self, // Time
477  entry._self / static_cast<Real>(entry._num_calls), // Avg.
478  100. * entry._self / total_root_time, // Percent
479  entry._self_memory); // Memory
480  }
481 
482  vtable.print(console);
483 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
void indirectSort(RandomAccessIterator beg, RandomAccessIterator end, std::vector< size_t > &b)
Definition: IndirectSort.h:68
void update()
Updates the time section_time and time for all currently running nodes.
Definition: PerfGraph.C:271
std::vector< CumulativeSectionInfo * > _cumulative_section_info_ptrs
Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we...
Definition: PerfGraph.h:384
const PerfGraphSectionInfo & sectionInfo(const PerfID section_id) const
Given a PerfID return the PerfGraphSectionInfo The ID.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
VariadicTable< std::string, unsigned long int, Real, Real, Real, long int > HeaviestTable
Definition: PerfGraph.h:206
const PerfID _root_node_id
The id for the root node.
Definition: PerfGraph.h:349

◆ push()

void PerfGraph::push ( const PerfID  id)
protected

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().

182 {
183  if (!_active && !_live_print_active)
184  return;
185 
186  PerfNode * new_node = nullptr;
187 
188  if (id == _root_node_id)
189  new_node = _root_node.get();
190  else
191  new_node = _stack[_current_position]->getChild(id);
192 
193  MemoryUtils::Stats stats;
194  auto memory_success = MemoryUtils::getMemoryStats(stats);
195 
196  long int start_memory = 0;
197 
198  if (memory_success)
199  start_memory =
201  else if (_current_position !=
202  -1) // If we weren't able to get the memory stats, let's just use the parent's
203  start_memory = _stack[_current_position]->startMemory();
204 
205  // Set the start time
206  auto current_time = std::chrono::steady_clock::now();
207 
208  new_node->setStartTimeAndMemory(current_time, start_memory);
209 
210  // Increment the number of calls
211  new_node->incrementNumCalls();
212 
214 
215  if (_current_position >= MAX_STACK_SIZE)
216  mooseError("PerfGraph is out of stack space!");
217 
218  _stack[_current_position] = new_node;
219 
220  // Add this to the execution list unless the message is empty - but pre-emted by live_print_all
223  addToExecutionList(id, IncrementState::STARTED, current_time, start_memory);
224 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
const processor_id_type _pid
This processor id.
Definition: PerfGraph.h:343
std::string _live_message
Message to print while the section is running.
void setStartTimeAndMemory(const std::chrono::time_point< std::chrono::steady_clock > time, const long int memory)
Set the current start time.
Definition: PerfNode.h:40
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
std::size_t _physical_memory
Definition: MemoryUtils.h:23
bool _live_print_all
Whether or not to put everything in the perf graph.
Definition: PerfGraph.h:334
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.
Definition: PerfGraph.C:150
void incrementNumCalls()
Increments the number of calls.
Definition: PerfNode.h:75
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
std::array< PerfNode *, MAX_STACK_SIZE > _stack
The full callstack. Currently capped at a depth of 100.
Definition: PerfGraph.h:358
bool _active
Whether or not timing is active.
Definition: PerfGraph.h:387
int _current_position
The current node position in the stack.
Definition: PerfGraph.h:355
bool _disable_live_print
Whether or not live print is disabled (cannot be turned on again)
Definition: PerfGraph.h:337
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174
const PerfGraphSectionInfo & readSectionInfo(PerfID section_id) const
Special accessor just for PerfGraph so that no locking is needed in PerfGraph.
std::atomic< bool > _live_print_active
Whether or not live printing is active.
Definition: PerfGraph.h:390
const PerfID _root_node_id
The id for the root node.
Definition: PerfGraph.h:349
A node in the PerfGraph.
Definition: PerfNode.h:24

◆ recursivelyUpdate()

void PerfGraph::recursivelyUpdate ( const PerfNode current_node)
protected

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

Parameters
current_nodeThe current node to work on

Definition at line 318 of file PerfGraph.C.

Referenced by update().

319 {
320  const auto & section_name = _perf_graph_registry.readSectionInfo(current_node.id())._name;
321 
322  // RHS insertion on purpose
323  auto & section_time = _cumulative_section_info[section_name];
324 
325  section_time._self += current_node.selfTimeSec();
326  section_time._children += current_node.childrenTimeSec();
327  section_time._total += current_node.totalTimeSec();
328  section_time._num_calls += current_node.numCalls();
329 
330  section_time._self_memory += current_node.selfMemory();
331  section_time._children_memory += current_node.childrenMemory();
332  section_time._total_memory += current_node.totalMemory();
333 
334  for (auto & child_it : current_node.children())
335  recursivelyUpdate(*child_it.second);
336 }
long int totalMemory() const
Get the amount of memory added by this node.
Definition: PerfNode.h:161
void recursivelyUpdate(const PerfNode &current_node)
Updates the cumulative self/children/total time and memory for each section across all nodes that con...
Definition: PerfGraph.C:318
Real selfTimeSec() const
Get the time this node took in seconds.
Definition: PerfNode.h:115
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
long int selfMemory() const
Get the amount of memory added by this node.
Definition: PerfNode.C:41
long int childrenMemory() const
Get the amount of memory added by this node.
Definition: PerfNode.C:47
Real totalTimeSec() const
The time this Node plus all of its children took in seconds.
Definition: PerfNode.h:128
unsigned long int numCalls() const
Get the number of times this node was called.
Definition: PerfNode.h:146
const std::map< PerfID, std::unique_ptr< PerfNode > > & children() const
Get the children.
Definition: PerfNode.h:106
Real childrenTimeSec() const
The time this node&#39;s children took in seconds.
Definition: PerfNode.h:141
PerfID id() const
Get the ID of this Node.
Definition: PerfNode.h:35
std::unordered_map< std::string, CumulativeSectionInfo > _cumulative_section_info
The cumulative time and memory for each section.
Definition: PerfGraph.h:378
const PerfGraphSectionInfo & readSectionInfo(PerfID section_id) const
Special accessor just for PerfGraph so that no locking is needed in PerfGraph.

◆ rootNode()

const PerfNode& PerfGraph::rootNode ( ) const
inline
Returns
A constant reference to the root node

Definition at line 186 of file PerfGraph.h.

Referenced by to_json().

186 { return *_root_node; }
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352

◆ sectionData()

Real PerfGraph::sectionData ( const DataType  type,
const std::string &  section_name,
const bool  must_exist = true 
)

Gets a PerfGraph result pertaining to a section.

Parameters
typeThe result type to retrieve
section_nameThe name of the section
must_existWhether 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().

92 {
93  update();
94 
95  const auto section_it =
96  _cumulative_section_info.find(section_name == "Root" ? _root_name : section_name);
97 
98  if (section_it == _cumulative_section_info.end())
99  {
100  if (!must_exist || // isn't required to exist
101  _perf_graph_registry.sectionExists(section_name) // or, is required to exist and it does
102  )
103  return 0;
104 
105  mooseError("Unknown PerfGraph section name \"",
106  section_name,
107  "\" in PerfGraph::sectionData().\nIf you are attempting to retrieve the root use "
108  "\"Root\".");
109  }
110 
111  const CumulativeSectionInfo & section_info = section_it->second;
112 
113  if (type == CALLS)
114  return section_info._num_calls;
115 
116  const auto app_time = _cumulative_section_info_ptrs[_root_node_id]->_total;
117 
118  switch (type)
119  {
120  case SELF:
121  return section_info._self;
122  case CHILDREN:
123  return section_info._children;
124  case TOTAL:
125  return section_info._total;
126  case SELF_AVG:
127  return section_info._self / static_cast<Real>(section_info._num_calls);
128  case CHILDREN_AVG:
129  return section_info._children / static_cast<Real>(section_info._num_calls);
130  case TOTAL_AVG:
131  return section_info._total / static_cast<Real>(section_info._num_calls);
132  case SELF_PERCENT:
133  return 100. * (section_info._self / app_time);
134  case CHILDREN_PERCENT:
135  return 100. * (section_info._children / app_time);
136  case TOTAL_PERCENT:
137  return 100. * (section_info._total / app_time);
138  case SELF_MEMORY:
139  return section_info._self_memory;
140  case CHILDREN_MEMORY:
141  return section_info._children_memory;
142  case TOTAL_MEMORY:
143  return section_info._total_memory;
144  default:
145  ::mooseError("Unknown DataType");
146  }
147 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
bool sectionExists(const std::string &section_name) const
Whether or not a section with that name has been registered The name of the section.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
void update()
Updates the time section_time and time for all currently running nodes.
Definition: PerfGraph.C:271
std::vector< CumulativeSectionInfo * > _cumulative_section_info_ptrs
Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we...
Definition: PerfGraph.h:384
std::unordered_map< std::string, CumulativeSectionInfo > _cumulative_section_info
The cumulative time and memory for each section.
Definition: PerfGraph.h:378
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::string _root_name
Name of the root node.
Definition: PerfGraph.h:346
const PerfID _root_node_id
The id for the root node.
Definition: PerfGraph.h:349

◆ setActive()

void PerfGraph::setActive ( bool  active)
inline

Turn on or off timing.

Definition at line 129 of file PerfGraph.h.

Referenced by MooseApp::setupOptions().

129 { _active = active; }
bool active() const
Whether or not timing is active.
Definition: PerfGraph.h:124
bool _active
Whether or not timing is active.
Definition: PerfGraph.h:387

◆ setLiveMemoryLimit()

void PerfGraph::setLiveMemoryLimit ( unsigned int  mem_limit)
inline

Sert the memory limit before a message prints.

Definition at line 157 of file PerfGraph.h.

Referenced by CommonOutputAction::act().

158  {
159  _live_print_mem_limit.store(mem_limit, std::memory_order_relaxed);
160  }
std::atomic< unsigned int > _live_print_mem_limit
The memory limit before a message is printed (in MB)
Definition: PerfGraph.h:408

◆ setLivePrintActive()

void PerfGraph::setLivePrintActive ( bool  active)
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().

bool active() const
Whether or not timing is active.
Definition: PerfGraph.h:124
std::atomic< bool > _live_print_active
Whether or not live printing is active.
Definition: PerfGraph.h:390

◆ setLivePrintAll()

void PerfGraph::setLivePrintAll ( bool  active)
inline

Forces all sections to be output live.

Definition at line 144 of file PerfGraph.h.

144 { _live_print_all = active; }
bool _live_print_all
Whether or not to put everything in the perf graph.
Definition: PerfGraph.h:334
bool active() const
Whether or not timing is active.
Definition: PerfGraph.h:124

◆ setLiveTimeLimit()

void PerfGraph::setLiveTimeLimit ( Real  time_limit)
inline

Set the time limit before a message prints.

Definition at line 149 of file PerfGraph.h.

Referenced by CommonOutputAction::act().

150  {
151  _live_print_time_limit.store(time_limit, std::memory_order_relaxed);
152  }
std::atomic< Real > _live_print_time_limit
The time limit before a message is printed (in seconds)
Definition: PerfGraph.h:405

◆ treeRecurse()

template<typename Functor >
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().

482 {
483  mooseAssert(_root_node, "Root node does not exist; calling this too early");
484  treeRecurseInternal(*_root_node, act, level, heaviest, 0);
485 }
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
void treeRecurseInternal(const PerfNode &node, const Functor &act, const unsigned int level, const bool heaviest, unsigned int current_depth) const
Definition: PerfGraph.h:441

◆ treeRecurseInternal()

template<typename Functor >
void PerfGraph::treeRecurseInternal ( const PerfNode node,
const Functor &  act,
const unsigned int  level,
const bool  heaviest,
unsigned int  current_depth 
) const
private

Definition at line 441 of file PerfGraph.h.

Referenced by treeRecurse().

446 {
447  mooseAssert(_perf_graph_registry.sectionExists(node.id()), "Unable to find section name!");
448 
449  const auto & current_section_info = _perf_graph_registry.readSectionInfo(node.id());
450  if (current_section_info._level <= level)
451  {
452  mooseAssert(!_cumulative_section_info_ptrs.empty(), "update() must be run before treeRecurse!");
453  act(node, current_section_info, current_depth++);
454  }
455 
456  if (heaviest)
457  {
458  const PerfNode * heaviest_child = nullptr;
459  for (const auto & child_it : node.children())
460  {
461  const auto & current_child = *child_it.second;
462 
463  if (!heaviest_child || (current_child.totalTime() > heaviest_child->totalTime()))
464  heaviest_child = &current_child;
465  }
466 
467  if (heaviest_child)
468  treeRecurseInternal(*heaviest_child, act, level, true, current_depth);
469  }
470  else
471  {
472  for (const auto & child_it : node.children())
473  treeRecurseInternal(*child_it.second, act, level, false, current_depth);
474  }
475 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
bool sectionExists(const std::string &section_name) const
Whether or not a section with that name has been registered The name of the section.
std::vector< CumulativeSectionInfo * > _cumulative_section_info_ptrs
Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we...
Definition: PerfGraph.h:384
const std::map< PerfID, std::unique_ptr< PerfNode > > & children() const
Get the children.
Definition: PerfNode.h:106
PerfID id() const
Get the ID of this Node.
Definition: PerfNode.h:35
std::chrono::steady_clock::duration totalTime() const
The time this Node plus all of it&#39;s children took.
Definition: PerfNode.C:22
void treeRecurseInternal(const PerfNode &node, const Functor &act, const unsigned int level, const bool heaviest, unsigned int current_depth) const
Definition: PerfGraph.h:441
const PerfGraphSectionInfo & readSectionInfo(PerfID section_id) const
Special accessor just for PerfGraph so that no locking is needed in PerfGraph.
A node in the PerfGraph.
Definition: PerfNode.h:24

◆ treeTable()

PerfGraph::FullTable PerfGraph::treeTable ( const unsigned int  level,
const bool  heaviest = false 
)
private

Helper for building a VariadicTable that represents the tree.

Parameters
levelThe level to print out below (<=)
heaviestShow only the heaviest branch

Definition at line 339 of file PerfGraph.C.

Referenced by print(), and printHeaviestBranch().

340 {
341  update();
342 
343  FullTable vtable({"Section",
344  "Calls",
345  "Self(s)",
346  "Avg(s)",
347  "%",
348  "Mem(MB)",
349  "Total(s)",
350  "Avg(s)",
351  "%",
352  "Mem(MB)"},
353  10);
354 
355  vtable.setColumnFormat({
356  VariadicTableColumnFormat::AUTO, // Section Name
366  });
367 
368  vtable.setColumnPrecision({
369  1, // Section Name
370  0, // Calls
371  3, // Self
372  3, // Avg.
373  2, // %
374  0, // Memory
375  3, // Total
376  3, // Avg.
377  2, // %
378  0, // Memory
379  });
380 
381  auto act = [this, &vtable](const PerfNode & node,
382  const moose::internal::PerfGraphSectionInfo & section_info,
383  const unsigned int depth)
384  {
385  vtable.addRow(std::string(depth * 2, ' ') + section_info._name, // Section Name
386  node.numCalls(), // Calls
387  node.selfTimeSec(), // Self
388  node.selfTimeAvg(), // Avg.
389  100. * node.selfTimeSec() / _root_node->totalTimeSec(), // %
390  node.selfMemory(), // Memory
391  node.totalTimeSec(), // Total
392  node.totalTimeAvg(), // Avg.
393  100. * node.totalTimeSec() / _root_node->totalTimeSec(), // %
394  node.totalMemory()); // Memory
395  };
396  treeRecurse(act, level, heaviest);
397 
398  return vtable;
399 }
long int totalMemory() const
Get the amount of memory added by this node.
Definition: PerfNode.h:161
Real selfTimeSec() const
Get the time this node took in seconds.
Definition: PerfNode.h:115
long int selfMemory() const
Get the amount of memory added by this node.
Definition: PerfNode.C:41
void treeRecurse(const Functor &act, const unsigned int level=MAX_STACK_SIZE, const bool heaviest=false) const
Definition: PerfGraph.h:479
Real selfTimeAvg() const
The average time this node took in seconds.
Definition: PerfNode.h:119
VariadicTable< std::string, unsigned long int, Real, Real, Real, long int, Real, Real, Real, long int > FullTable
Definition: PerfGraph.h:204
Real totalTimeSec() const
The time this Node plus all of its children took in seconds.
Definition: PerfNode.h:128
Used to hold metadata about the registered sections Note: this is a class instead of a struct because...
void update()
Updates the time section_time and time for all currently running nodes.
Definition: PerfGraph.C:271
unsigned long int numCalls() const
Get the number of times this node was called.
Definition: PerfNode.h:146
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
Real totalTimeAvg() const
The average time this Node plus all of its children took in seconds.
Definition: PerfNode.h:132
A node in the PerfGraph.
Definition: PerfNode.h:24

◆ update()

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().

272 {
273  // First update all of the currently running nodes
274  auto now = std::chrono::steady_clock::now();
275 
276  MemoryUtils::Stats stats;
278  auto now_memory =
280 
281  for (int i = 0; i <= _current_position; i++)
282  {
283  auto node = _stack[i];
284  node->addTimeAndMemory(now, now_memory);
285  node->setStartTimeAndMemory(now, now_memory);
286  }
287 
288  // Zero out the entries
289  for (auto & section_time_it : _cumulative_section_info)
290  {
291  auto & section_time = section_time_it.second;
292 
293  section_time._num_calls = 0;
294  section_time._self = 0.;
295  section_time._children = 0.;
296  section_time._total = 0.;
297  section_time._self_memory = 0;
298  section_time._children_memory = 0;
299  section_time._total_memory = 0.;
300  }
301 
303 
304  // Update vector pointing to section times
305  // Note: we are doing this _after_ recursively filling
306  // because new entries may have been created
308 
309  for (auto & section_time_it : _cumulative_section_info)
310  {
311  auto id = _perf_graph_registry.sectionID(section_time_it.first);
312 
313  _cumulative_section_info_ptrs[id] = &section_time_it.second;
314  }
315 }
void recursivelyUpdate(const PerfNode &current_node)
Updates the cumulative self/children/total time and memory for each section across all nodes that con...
Definition: PerfGraph.C:318
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
std::size_t _physical_memory
Definition: MemoryUtils.h:23
std::vector< CumulativeSectionInfo * > _cumulative_section_info_ptrs
Pointers into _cumulative_section_info indexed on PerfID This is here for convenience and speed so we...
Definition: PerfGraph.h:384
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
std::array< PerfNode *, MAX_STACK_SIZE > _stack
The full callstack. Currently capped at a depth of 100.
Definition: PerfGraph.h:358
std::unordered_map< std::string, CumulativeSectionInfo > _cumulative_section_info
The cumulative time and memory for each section.
Definition: PerfGraph.h:378
int _current_position
The current node position in the stack.
Definition: PerfGraph.h:355
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID The name of the section.
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174

Friends And Related Function Documentation

◆ dataLoad

void dataLoad ( std::istream &  stream,
PerfGraph perf_graph,
void context 
)
friend

Definition at line 500 of file PerfGraph.C.

501 {
502  // Load in all of the recovered sections and register those that do not exist yet
503  std::vector<moose::internal::PerfGraphSectionInfo> recovered_section_info;
504  dataLoad(stream, recovered_section_info, nullptr);
505  for (const auto & info : recovered_section_info)
506  {
507  if (info._live_message.size())
509  info._name, info._level, info._live_message, info._print_dots);
510  else
511  perf_graph._perf_graph_registry.registerSection(info._name, info._level);
512  }
513 
514  // Update the current node time/memory/calls before loading the nodes as the load
515  // will append information to current nodes that exist
516  perf_graph.update();
517 
518  // Recursively load all of the nodes; this will append information to matching nodes
519  // and will create new nodes for section paths that do not exist
520  dataLoad(stream, perf_graph._root_node, &perf_graph);
521 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
MPI_Info info
void update()
Updates the time section_time and time for all currently running nodes.
Definition: PerfGraph.C:271
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
friend void dataLoad(std::istream &, PerfGraph &, void *)
Definition: PerfGraph.C:500

◆ dataStore

void dataStore ( std::ostream &  stream,
PerfGraph perf_graph,
void context 
)
friend

Definition at line 486 of file PerfGraph.C.

487 {
488  // We need to store the registry id -> section info map so that we can add
489  // registered sections that may not be added yet during recover
490  dataStore(stream, perf_graph._perf_graph_registry._id_to_item, nullptr);
491 
492  // Update before serializing the nodes so that the time/memory/calls are correct
493  perf_graph.update();
494 
495  // Recursively serialize all of the nodes
496  dataStore(stream, perf_graph._root_node, nullptr);
497 }
PerfGraphRegistry & _perf_graph_registry
The PerfGraphRegistry.
Definition: PerfGraph.h:340
friend void dataStore(std::ostream &, PerfGraph &, void *)
Definition: PerfGraph.C:486
void update()
Updates the time section_time and time for all currently running nodes.
Definition: PerfGraph.C:271
const std::unique_ptr< PerfNode > _root_node
The root node of the graph.
Definition: PerfGraph.h:352
std::vector< Item > _id_to_item
Vector of IDs to Items.

◆ PerfGraphLivePrint

friend class PerfGraphLivePrint
friend

Definition at line 418 of file PerfGraph.h.

◆ PerfGuard

friend class PerfGuard
friend

Definition at line 417 of file PerfGraph.h.

Member Data Documentation

◆ _active

bool PerfGraph::_active
protected

Whether or not timing is active.

Definition at line 387 of file PerfGraph.h.

Referenced by active(), pop(), push(), and setActive().

◆ _console

const ConsoleStream ConsoleStreamInterface::_console
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().

◆ _cumulative_section_info

std::unordered_map<std::string, CumulativeSectionInfo> PerfGraph::_cumulative_section_info
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().

◆ _cumulative_section_info_ptrs

std::vector<CumulativeSectionInfo *> PerfGraph::_cumulative_section_info_ptrs
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().

◆ _current_position

int PerfGraph::_current_position
protected

The current node position in the stack.

Definition at line 355 of file PerfGraph.h.

Referenced by pop(), push(), and update().

◆ _destructing

bool PerfGraph::_destructing
protected

Tell the print thread to teardown.

Definition at line 396 of file PerfGraph.h.

Referenced by disableLivePrint(), and PerfGraphLivePrint::start().

◆ _destructing_mutex

std::mutex PerfGraph::_destructing_mutex
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().

◆ _disable_live_print

bool PerfGraph::_disable_live_print
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().

◆ _done

std::promise<bool> PerfGraph::_done
protected

The promise to the print thread that will signal when to stop.

Definition at line 393 of file PerfGraph.h.

◆ _execution_list

std::array<SectionIncrement, MAX_EXECUTION_LIST_SIZE> PerfGraph::_execution_list
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().

◆ _execution_list_begin

std::atomic<unsigned int> PerfGraph::_execution_list_begin
protected

Where the print thread should start reading the execution list.

Definition at line 364 of file PerfGraph.h.

◆ _execution_list_end

std::atomic<unsigned int> PerfGraph::_execution_list_end
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().

◆ _finished_section

std::condition_variable PerfGraph::_finished_section
protected

The condition_variable to wake the print thread.

Definition at line 402 of file PerfGraph.h.

Referenced by disableLivePrint(), pop(), and PerfGraphLivePrint::start().

◆ _live_print

const std::unique_ptr<PerfGraphLivePrint> PerfGraph::_live_print
protected

The object that is doing live printing.

Definition at line 411 of file PerfGraph.h.

Referenced by PerfGraph().

◆ _live_print_active

std::atomic<bool> PerfGraph::_live_print_active
protected

Whether or not live printing is active.

Definition at line 390 of file PerfGraph.h.

Referenced by pop(), push(), setLivePrintActive(), and PerfGraphLivePrint::start().

◆ _live_print_all

bool PerfGraph::_live_print_all
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().

◆ _live_print_mem_limit

std::atomic<unsigned int> PerfGraph::_live_print_mem_limit
protected

The memory limit before a message is printed (in MB)

Definition at line 408 of file PerfGraph.h.

Referenced by setLiveMemoryLimit().

◆ _live_print_time_limit

std::atomic<Real> PerfGraph::_live_print_time_limit
protected

The time limit before a message is printed (in seconds)

Definition at line 405 of file PerfGraph.h.

Referenced by setLiveTimeLimit().

◆ _moose_app

MooseApp& PerfGraph::_moose_app
protected

The MooseApp.

Definition at line 331 of file PerfGraph.h.

Referenced by mooseApp().

◆ _perf_graph_registry

PerfGraphRegistry& PerfGraph::_perf_graph_registry
protected

The PerfGraphRegistry.

Definition at line 340 of file PerfGraph.h.

Referenced by dataLoad(), dataStore(), pop(), printHeaviestSections(), push(), recursivelyUpdate(), sectionData(), treeRecurseInternal(), and update().

◆ _pid

const processor_id_type PerfGraph::_pid
protected

This processor id.

Definition at line 343 of file PerfGraph.h.

Referenced by disableLivePrint(), PerfGraph(), pop(), and push().

◆ _print_thread

std::thread PerfGraph::_print_thread
protected

The thread for printing sections as they execute.

Definition at line 414 of file PerfGraph.h.

Referenced by disableLivePrint(), and PerfGraph().

◆ _root_name

const std::string PerfGraph::_root_name
protected

Name of the root node.

Definition at line 346 of file PerfGraph.h.

Referenced by sectionData().

◆ _root_node

const std::unique_ptr<PerfNode> PerfGraph::_root_node
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().

◆ _root_node_id

const PerfID PerfGraph::_root_node_id
protected

The id for the root node.

Definition at line 349 of file PerfGraph.h.

Referenced by PerfGraph(), printHeaviestSections(), push(), and sectionData().

◆ _stack

std::array<PerfNode *, MAX_STACK_SIZE> PerfGraph::_stack
protected

The full callstack. Currently capped at a depth of 100.

Definition at line 358 of file PerfGraph.h.

Referenced by pop(), push(), and update().


The documentation for this class was generated from the following files: