Skip to content

Commit

Permalink
Merge pull request #28226 from aprilnovak/rename-max-stack-size
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud authored Jul 25, 2024
2 parents 9a7e0e1 + 4d37341 commit 3b0c2f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion framework/doc/content/source/utils/PerfGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ An object that inherits from `PerfGraphInterface` can retrieve the data pertaini

The `PerfGraph` object's main purpose is to store the complete call-graph of `PerfNode`s and the current call-stack of `PerfNode`s. The graph is held by holding onto the `_root_node`. All other scopes that are pushed into the graph are then children/descendants of the `_root_node`.

The call-stack is held within the `_stack` variable. The `_stack` is statically allocated to `MAX_STACK_SIZE` and `_current_position` is used to point at the most recent node on the stack. When a `PerfGuard` tells the `PerfStack` about a new scope, the new scope is added a child to the `PerfNode` that is in the `_current_position`. `_current_position` is then incremented and the new `PerfNode` is put there. When a scope is removed by the `PerfGuard` the `_current_position` is simply decremented - with no other action being necessary.
The call-stack is held within the `_stack` variable. The `_stack` is statically allocated to `MOOSE_MAX_STACK_SIZE` and `_current_position` is used to point at the most recent node on the stack. When a `PerfGuard` tells the `PerfStack` about a new scope, the new scope is added a child to the `PerfNode` that is in the `_current_position`. `_current_position` is then incremented and the new `PerfNode` is put there. When a scope is removed by the `PerfGuard` the `_current_position` is simply decremented - with no other action being necessary.

In addition, the `_execution_list` is keeping a running list of every section that executes. This is utilized by `PerfGraphLivePrint` to print messages out that are multiple levels deep.

Expand Down
8 changes: 4 additions & 4 deletions framework/include/utils_nonunity/PerfGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PerfGraphLivePrint;
template <class... Ts>
class VariadicTable;

#define MAX_STACK_SIZE 100
#define MOOSE_MAX_STACK_SIZE 100
#define MAX_EXECUTION_LIST_SIZE 10000

/**
Expand Down Expand Up @@ -187,7 +187,7 @@ class PerfGraph : protected ConsoleStreamInterface

template <typename Functor>
void treeRecurse(const Functor & act,
const unsigned int level = MAX_STACK_SIZE,
const unsigned int level = MOOSE_MAX_STACK_SIZE,
const bool heaviest = false) const;

protected:
Expand Down Expand Up @@ -352,7 +352,7 @@ class PerfGraph : protected ConsoleStreamInterface
int _current_position;

/// The full callstack. Currently capped at a depth of 100
std::array<PerfNode *, MAX_STACK_SIZE> _stack;
std::array<PerfNode *, MOOSE_MAX_STACK_SIZE> _stack;

/// A circular buffer for holding the execution list, this is read by the printing loop
std::array<SectionIncrement, MAX_EXECUTION_LIST_SIZE> _execution_list;
Expand Down Expand Up @@ -471,7 +471,7 @@ PerfGraph::treeRecurseInternal(const PerfNode & node,
template <typename Functor>
void
PerfGraph::treeRecurse(const Functor & act,
const unsigned int level /* = MAX_STACK_SIZE */,
const unsigned int level /* = MOOSE_MAX_STACK_SIZE */,
const bool heaviest /* = false */) const
{
mooseAssert(_root_node, "Root node does not exist; calling this too early");
Expand Down
2 changes: 1 addition & 1 deletion framework/include/utils_nonunity/PerfGraphLivePrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PerfGraphLivePrint : protected ConsoleStreamInterface
unsigned int _stack_level;

/// The current stack for what the print thread has seen
std::array<PerfGraph::SectionIncrement, MAX_STACK_SIZE> _print_thread_stack;
std::array<PerfGraph::SectionIncrement, MOOSE_MAX_STACK_SIZE> _print_thread_stack;

/// The end of the execution list
/// This is (safely) copied from PerfGraph so that it is consistent for an
Expand Down
4 changes: 2 additions & 2 deletions framework/src/utils_nonunity/PerfGraph.C
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ PerfGraph::push(const PerfID id)

_current_position++;

if (_current_position >= MAX_STACK_SIZE)
if (_current_position >= MOOSE_MAX_STACK_SIZE)
mooseError("PerfGraph is out of stack space!");

_stack[_current_position] = new_node;
Expand Down Expand Up @@ -412,7 +412,7 @@ void
PerfGraph::printHeaviestBranch(const ConsoleStream & console)
{
console << "\nHeaviest Branch:\n";
treeTable(MAX_STACK_SIZE, /* heaviest = */ true).print(console);
treeTable(MOOSE_MAX_STACK_SIZE, /* heaviest = */ true).print(console);
}

void
Expand Down

0 comments on commit 3b0c2f9

Please sign in to comment.