Performance

Measured throughput of cim-kit on the ENTSO-E RealGrid conformity model — 112 MiB, 188,547 objects — and what the numbers come from.

Measured on the ENTSO-E RealGrid conformity model: 112 MiB, 188,547 objects, 1.1 million values. Release build, Apple M-series. Documents are read from memory, so the numbers measure parsing rather than the disk.

OperationTimeRate
Read0.40 s282 MiB/s · 474k objects/s
Write, as the file set it came from0.39 s288 MiB/s
Write as RDF (N-Triples, 1.3M triples)0.58 s
Validate0.05 s4.0M objects/s
Diff against another model state0.08 s2.3M objects/s
Build the inverse index0.04 s
cargo bench -p cim-kit

The benchmark also measures a synthetic model, so it runs without the standards corpus. Absolute figures vary by 20% or more with machine load; the ratios between rows are stable.

Where the speed comes from#

TechniqueEffect
Streaming pull parser over the RDF/XML subset IEC 61970-552 definesNo buffering; a general RDF toolchain is slower and misreads CIM/XML
Element names resolved through a cache keyed on raw QName bytesNear-zero lookup cost; namespaces, attributes and identifiers borrowed on the hot path
Sparse storageMemory proportional to content: four values per object on average against 21 possible fields
Per-class buckets with a recorded slotview::<ACLineSegment>() walks a few buckets; reclassifying an object (as loading SSH before EQ does) is O(1)
No allocation on the diagnostic pathFindings hold an Mrid and a &'static str attribute name, not rendered text

Assembling in parallel#

Each file of a model set can be parsed on its own thread and the parts merged, with std::thread::scope and no extra dependency:

use cim_kit::prelude::*;
use cim_kit::cgmes3::SCHEMA;

fn main() -> cim_kit::Result<()> {
    let files = cim_kit::instance_files("RealGrid/");

    let read: Vec<cim_kit::Result<Dataset>> = std::thread::scope(|scope| {
        let readers: Vec<_> = files
            .iter()
            .map(|file| scope.spawn(move || Dataset::load(SCHEMA, [file])))
            .collect();
        readers.into_iter().map(|r| r.join().expect("reader thread")).collect()
    });

    let mut model = Dataset::new(SCHEMA);
    for part in read {
        model.merge(part?)?;
    }

    println!("{} objects", model.len());
    Ok(())
}

A merged assembly and a sequential one produce the same Dataset::content_id (tested). On RealGrid's four files:

Sequential load0.41 s
Parallel read0.27 s
…plus the merge0.31 s

The wall clock cannot fall below the largest file (one Equipment file dominates), and the merge costs about 40 ms here — worth it for a large set on an idle machine, not for a MicroGrid.

Compile time#

Around 1,100 generated types per vintage are kept cheap to compile: generated code is macro-free and generic-light; vintages are feature-gated, so a CGMES 3.0 program never compiles the 2.4.15 tables; and generated sources are committed rather than built by build.rs.