Skip to main content

Crate cu_profiler_core

Crate cu_profiler_core 

Source
Expand description

cu-profiler-core — the Solana compute-intelligence engine.

This crate owns the domain model, the Solana log parser, the CPI call-tree and scope-marker analysis, the budget policy engine, baselines, confidence scoring, and diagnostics. It depends on no CLI code and no live Solana runtime by default: the backend::RecordedLogsBackend drives the entire pipeline from logs, which is how the parser, reports and CI logic are developed and tested.

§Honesty about limitations

  • Scope/function attribution requires explicit markers; there is no automatic source-line profiling.
  • program-test results may differ from mainnet runtime conditions.
  • Baselines are only valid when their baseline::Fingerprint matches.

§Example

use cu_profiler_core::backend::RecordedLogsBackend;
use cu_profiler_core::metadata::RunMetadata;
use cu_profiler_core::scenario::Scenario;
use cu_profiler_core::Profiler;

let mut backend = RecordedLogsBackend::new();
backend.insert_blob(
    "swap",
    "Program P invoke [1]\nProgram P consumed 1000 of 200000 compute units\nProgram P success",
    true,
);
let report = Profiler::new().run(
    &backend,
    &[Scenario::new("swap")],
    None,
    RunMetadata::recorded(cu_profiler_core::VERSION),
);
assert_eq!(report.scenarios[0].measurement.total_cu, 1000);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use profiler::Profiler;

Modules§

backend
Execution backends.
baseline
Baseline records and their on-disk store.
budget
Budget policy engine.
confidence
Confidence scoring.
config
cu-profiler.toml parsing.
diagnostics
Diagnostic engine: turns analysed data into actionable, Solana-specific findings.
error
Typed error model for cu-profiler-core.
metadata
Run-level metadata attached to every report and baseline record.
model
The report data model: the raw, serializable result of a profiling run.
parser
Solana log parsing: lexer, compute-budget heuristics, CPI tree, and scope markers, plus a analyze facade that turns raw logs into a structured ParseAnalysis the profiler can consume.
profiler
The profiler engine: runs scenarios through a backend, parses the logs, and assembles a Report — applying budget policies, baseline comparison, confidence scoring and diagnostics along the way.
program_registry
Registry mapping program IDs (base-58 pubkeys) to human labels.
scenario
The first-class Scenario type.

Constants§

VERSION
The version of cu-profiler-core.