Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
ReplayResourceBudget.h File Reference
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <utility>
#include "donner/editor/ImGuiIncludes.h"
#include "donner/editor/repro/ReproFile.h"
Include dependency graph for ReplayResourceBudget.h:

Classes

struct  donner::editor::repro::ReplaySemanticActionCost
 Estimated work performed by one semantic replay action. More...
struct  donner::editor::repro::ReplayInputFrameCost
 Estimated source-mutation work from raw replay input dispatched for one frame. More...
class  donner::editor::repro::ReplayHeldMutationKeyState
 Tracks repeat-capable mutation keys whose down state persists across replay frames. More...
class  donner::editor::repro::ReplayExecutionResourceBudget
 Aggregate runtime budget for replay frames and semantic actions. More...
class  donner::editor::repro::ReplayDiagnosticsResourceBudget
 Aggregate retained-memory budget for replay diagnostics. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::editor::repro::ReplayFrameDispatchResult : std::uint8_t {
  Success ,
  ActionBudgetExceeded ,
  InputBudgetExceeded
}
 Result of applying one frame's actions and then dispatching its raw input.

Functions

bool donner::editor::repro::detail::CheckedAdd (std::size_t left, std::size_t right, std::size_t *result)
bool donner::editor::repro::detail::CheckedMultiply (std::size_t left, std::size_t right, std::size_t *result)
ReplaySemanticActionCost donner::editor::repro::EstimateReplaySemanticActionCost (const ReproAction &action, std::size_t documentSourceBytes, std::size_t selectedElementCount)
 Estimate the mutation and source-rewrite work of one semantic replay action.
ReplayInputFrameCost donner::editor::repro::EstimateReplayInputFrameCost (const ReproFrame &frame, std::size_t documentSourceBytes, std::size_t selectedElementCount, std::size_t potentialDocumentElementCount, std::size_t heldRepeatSourceRewriteUnits=0)
 Conservatively estimate source mutation work reachable through raw frame input.
template<typename ApplyCallback>
bool donner::editor::repro::ApplyReplayActionWithResourceBudget (ReplayExecutionResourceBudget &budget, const ReplaySemanticActionCost &cost, ApplyCallback &&apply)
 Reserve semantic-action work before invoking the mutation callback.
template<typename DispatchCallback>
bool donner::editor::repro::DispatchReplayInputWithResourceBudget (ReplayExecutionResourceBudget &budget, const ReplayInputFrameCost &cost, DispatchCallback &&dispatch)
 Reserve raw-input mutation work before invoking the input dispatch callback.
template<typename ActionRange, typename EstimateActionCallback, typename ApplyActionCallback, typename EstimateInputCallback, typename DispatchInputCallback>
ReplayFrameDispatchResult donner::editor::repro::DispatchReplayFrameWithResourceBudget (ReplayExecutionResourceBudget &budget, const ActionRange &actions, EstimateActionCallback &&estimateAction, ApplyActionCallback &&applyAction, EstimateInputCallback &&estimateInput, DispatchInputCallback &&dispatchInput)
 Apply semantic actions before pricing and dispatching the raw input consumed later in the frame.

Variables

constexpr std::size_t donner::editor::repro::kMaximumReplaySelectionMutations = 8'192

Function Documentation

◆ ApplyReplayActionWithResourceBudget()

template<typename ApplyCallback>
bool donner::editor::repro::ApplyReplayActionWithResourceBudget ( ReplayExecutionResourceBudget & budget,
const ReplaySemanticActionCost & cost,
ApplyCallback && apply )
nodiscard

Reserve semantic-action work before invoking the mutation callback.

This helper is shared by production replay and structured fuzz oracles so the ordering guarantee is directly exercised without requiring a window or graphics context.

◆ DispatchReplayFrameWithResourceBudget()

template<typename ActionRange, typename EstimateActionCallback, typename ApplyActionCallback, typename EstimateInputCallback, typename DispatchInputCallback>
ReplayFrameDispatchResult donner::editor::repro::DispatchReplayFrameWithResourceBudget ( ReplayExecutionResourceBudget & budget,
const ActionRange & actions,
EstimateActionCallback && estimateAction,
ApplyActionCallback && applyAction,
EstimateInputCallback && estimateInput,
DispatchInputCallback && dispatchInput )
nodiscard

Apply semantic actions before pricing and dispatching the raw input consumed later in the frame.

The input estimator runs after every action callback, so it observes the resulting live document size and selection. Every reservation also precedes its corresponding mutation callback.

◆ EstimateReplaySemanticActionCost()

ReplaySemanticActionCost donner::editor::repro::EstimateReplaySemanticActionCost ( const ReproAction & action,
std::size_t documentSourceBytes,
std::size_t selectedElementCount )
inlinenodiscard

Estimate the mutation and source-rewrite work of one semantic replay action.

A style change may inspect and rewrite the document source once per selected element. The source, property, and value sizes are therefore charged for every affected element rather than only once per action.