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.
| Operation | Time | Rate |
|---|---|---|
| Read | 0.40 s | 282 MiB/s · 474k objects/s |
| Write, as the file set it came from | 0.39 s | 288 MiB/s |
| Write as RDF (N-Triples, 1.3M triples) | 0.58 s | |
| Validate | 0.05 s | 4.0M objects/s |
| Diff against another model state | 0.08 s | 2.3M objects/s |
| Build the inverse index | 0.04 s |
cargo bench -p cim-kitThe 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#
| Technique | Effect |
|---|---|
| Streaming pull parser over the RDF/XML subset IEC 61970-552 defines | No buffering; a general RDF toolchain is slower and misreads CIM/XML |
| Element names resolved through a cache keyed on raw QName bytes | Near-zero lookup cost; namespaces, attributes and identifiers borrowed on the hot path |
| Sparse storage | Memory proportional to content: four values per object on average against 21 possible fields |
| Per-class buckets with a recorded slot | view::<ACLineSegment>() walks a few buckets; reclassifying an object (as loading SSH before EQ does) is O(1) |
| No allocation on the diagnostic path | Findings 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 load | 0.41 s |
| Parallel read | 0.27 s |
| …plus the merge | 0.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.