Replay

Namespace: dftracer::utils::utilities::replay

class DFTracerExecutor : public dftracer::utils::utilities::replay::TraceExecutor

DFTracer executor for sleep-based replay Simulates operation timing without actual I/O

Public Functions

virtual bool execute(const Trace &trace, const ReplayConfig &config) override

Execute a single trace operation

Parameters:
  • trace – The parsed trace event

  • config – Replay configuration

Returns:

true if successful, false otherwise

virtual bool can_handle(const Trace &trace) const override

Check if this executor can handle the given trace

Parameters:

trace – The trace event to check

Returns:

true if this executor can handle the trace

inline virtual std::string get_name() const override

Get human-readable name for this executor

class PosixExecutor : public dftracer::utils::utilities::replay::TraceExecutor

Executor for POSIX file operations (read, write, open, close, etc.)

Public Functions

virtual bool execute(const Trace &trace, const ReplayConfig &config) override

Execute a single trace operation

Parameters:
  • trace – The parsed trace event

  • config – Replay configuration

Returns:

true if successful, false otherwise

virtual bool can_handle(const Trace &trace) const override

Check if this executor can handle the given trace

Parameters:

trace – The trace event to check

Returns:

true if this executor can handle the trace

inline virtual std::string get_name() const override

Get human-readable name for this executor

struct ReplayConfig

Configuration options for trace replay

Public Members

bool maintain_timing = true
bool dry_run = false
bool dftracer_mode = false
bool no_sleep = false
double timing_scale = 1.0
std::uint64_t start_time_offset = 0
bool verbose = false
std::string output_directory
std::size_t max_file_size = 1024 * 1024 * 100
std::unordered_set<std::string> filter_functions
std::unordered_set<std::string> exclude_functions
std::unordered_set<std::string> filter_categories
std::unordered_set<std::string> exclude_categories
std::unordered_set<std::uint32_t> filter_pids
std::unordered_set<std::uint32_t> filter_tids
std::unordered_set<std::uint32_t> exclude_pids
std::unordered_set<std::uint32_t> exclude_tids
std::uint64_t start_timestamp = 0
std::uint64_t end_timestamp = UINT64_MAX
std::int64_t min_operation_size = -1
std::int64_t max_operation_size = -1
int min_level = -1
int max_level = -1
double sampling_rate = 1.0
std::uint64_t sample_seed = 0
bool sample_deterministic = true
std::size_t max_events = 0
std::size_t max_open_files = 1024
bool use_call_tree = false
bool hierarchical_replay = false
bool respect_call_hierarchy = true
int mpi_rank = 0
int mpi_size = 1
std::function<void(const Trace&, std::chrono::steady_clock::time_point)> on_dispatch
class ReplayEngine

Main replay engine that coordinates trace reading and execution

Usage:

ReplayConfig config;
config.dftracer_mode = true;

ReplayEngine engine(config); auto result = engine.replay(“trace.pfw.gz”); result.print_summary();

Public Functions

explicit ReplayEngine(const ReplayConfig &config)

Construct replay engine with configuration

Parameters:

config – Replay configuration options

ReplayEngine(const std::string &trace_file, const ReplayConfig &config)

Construct and immediately configure for a trace file

Parameters:
  • trace_file – Path to trace file

  • config – Replay configuration options

~ReplayEngine()
void add_executor(std::unique_ptr<TraceExecutor> executor)

Add a custom executor for specific trace types

Parameters:

executor – Unique pointer to executor (engine takes ownership)

ReplayResult replay(const std::string &trace_file, const std::string &index_file = "")

Replay traces from a single file

Parameters:
  • trace_file – Path to trace file (.pfw or .pfw.gz)

  • index_file – Optional path to index file

Returns:

Replay results and statistics

ReplayResult replay(const std::vector<std::string> &trace_files)

Replay traces from multiple files

Parameters:

trace_files – Vector of trace file paths

Returns:

Aggregated replay results

ReplayResult replay_with_call_tree(const std::string &trace_dir, const std::string &pattern = "*.pfw.gz")

Replay traces using call tree structure Builds hierarchical call tree and replays in proper order

Parameters:
  • trace_dir – Directory containing trace files

  • pattern – File pattern (default: “*.pfw.gz”)

Returns:

Replay results with call tree statistics

bool process_trace_line(dftracer::utils::utilities::common::json::JsonParser &parser, ReplayResult &result)

Process a single trace event already loaded into a JsonParser. Public so callers driving their own TraceReader::read_json loop can feed events in directly without going through replay(file).

coro::AsyncGenerator<Trace> stream_traces(const std::vector<std::string> &files)

Stream parsed Trace events from the given trace files. Drives TraceReader::read_json under the hood; each call yields one event. Used to plug replay into a producer task inside a Pipeline.

coro::CoroTask<void> run_pipelined(dftracer::utils::CoroScope &scope, const std::vector<std::string> &files, ReplayResult &result, std::size_t channel_capacity = 4096)

Drive a producer/consumer pipeline that decouples read+parse from timing+execute. The producer fills a bounded channel from stream_traces; a single consumer drains it and dispatches events (apply_timing → executor->execute). Read latency is hidden behind the consumer’s per-event work + sleep_for, eliminating the dispatch lateness that the sequential path accumulates on large gz-compressed traces.

Parameters:
  • scope – Parent CoroScope (typically a Pipeline task scope).

  • filesTrace files to replay in order.

  • result – Aggregated counts and per-event stats are written here. Must outlive the awaited coroutine.

  • channel_capacity – Max in-flight parsed Traces. Default 4096.

struct ReplayResult

Results and statistics from replay execution

Public Functions

void print_summary(bool verbose = false) const

Print summary statistics

Parameters:

verbose – Include detailed breakdown

Public Members

std::size_t total_events = 0
std::size_t executed_events = 0
std::size_t filtered_events = 0
std::size_t failed_events = 0
std::chrono::microseconds total_duration = {0}
std::chrono::microseconds execution_duration = {0}
std::unordered_map<std::string_view, std::size_t> function_counts
std::unordered_map<std::string_view, std::size_t> category_counts
std::vector<std::string> error_messages
std::unordered_map<std::uint32_t, std::size_t> pid_counts
std::unordered_map<std::uint32_t, std::size_t> tid_counts
std::size_t total_bytes_read = 0
std::size_t total_bytes_written = 0
std::uint64_t first_timestamp = UINT64_MAX
std::uint64_t last_timestamp = 0
std::size_t total_nodes = 0
std::size_t tree_depth = 0
std::size_t unique_processes = 0
struct Trace

Trace structure representing a single trace event from DFTracer Contains all information needed for replay operations

Public Functions

inline Trace()

Default constructor

inline bool is_metadata() const

Check if this is a metadata trace

inline std::uint64_t get_end_time() const

Get end time, calculating from start + duration if needed

inline bool has_valid_timing() const

Check if this trace has valid timing information

inline bool has_size() const

Check if this trace has I/O size information

inline bool has_offset() const

Check if this trace has offset information

Public Members

std::string_view cat
std::string io_cat
std::string acc_pat
std::string_view func_name
double duration
std::uint64_t count
std::uint64_t time_range
std::uint64_t time_start
std::uint64_t time_end
std::uint64_t epoch
std::uint64_t pid
std::uint64_t tid
std::string_view fhash
std::string_view hhash
std::uint64_t image_id
TraceType type
ViewFields view_fields
BinFields bin_fields
std::int64_t size = -1
std::int64_t offset = -1
bool is_valid = false
class TraceExecutor

Interface for executing individual trace operations

Subclassed by dftracer::utils::utilities::replay::DFTracerExecutor, dftracer::utils::utilities::replay::PosixExecutor

Public Functions

virtual ~TraceExecutor() = default
virtual bool execute(const Trace &trace, const ReplayConfig &config) = 0

Execute a single trace operation

Parameters:
  • trace – The parsed trace event

  • config – Replay configuration

Returns:

true if successful, false otherwise

virtual bool can_handle(const Trace &trace) const = 0

Check if this executor can handle the given trace

Parameters:

trace – The trace event to check

Returns:

true if this executor can handle the trace

virtual std::string get_name() const = 0

Get human-readable name for this executor