APIC Runtime Configuration Guide
This document describes the JSON configuration structure used to control runtime behavior, threading, CPU affinity, startup state, and recording policies in APIC.
Usage
Pass the path to the configuration file to the application on startup:
projectApp.exe config="[path]/config.json"
config argument is optional. If it is omitted, or given as a relative path, the CoreEngine looks
for it relative to the process's own folder (the executable's directory) — not the current
working directory. This differs from other path arguments like setup/test, which
resolve relative to the working directory; see CoreEngine Command-Line Arguments
for the full list and path-resolution rules.
1. Folders
Defines logical directories used by the system. This section is optional — any entry (or the whole block) can be commented out to fall back to the built-in default paths.
| Field | Description |
|---|---|
setups | Directory containing setup configuration files. |
tests | Directory containing test scenarios. |
{
"folders": {
"setups": "./setups"
"tests": "./tests"
}
}
2. RealTime Thread
Controls the main real-time processing thread.
| Field | Description |
|---|---|
affinity | CPU core binding. Supports single cores, comma lists, ranges, and the * wildcard. |
priority | Thread scheduling priority (higher = more critical). |
bTimingFixTime | If true, enforces fixed-cycle timing compensation. |
"0,3,4-6" binds to cores 0, 3, 4, 5, 6. Adding * to the list, e.g. "0,3,4-6,*", additionally includes every remaining core not explicitly assigned elsewhere — use it when a thread should also be free to run on any leftover core instead of being strictly limited to the ones listed.
{
"RealTime": {
"affinity": "0,3,4-6,*",
"priority": 6,
"bTimingFixTime": true
}
}
3. CrashDump
Configures automatic crash dump capture if the application terminates unexpectedly.
| Field | Description |
|---|---|
dumpPath | Directory where crash dump files are written. |
dumpSize |
Amount of process state captured in the dump:
|
active | Enable/disable crash dump capture (true or 1/false or 0). |
{
"CrashDump": {
"dumpPath": "./crashdump",
"dumpSize": "mini", // "mini" or "full"
"active": 1
}
}
4. Keyboard Thread
Handles interactive keyboard control.
| Field | Description |
|---|---|
affinity | Dedicated CPU core binding. |
priority | Thread priority. |
active | Enable/disable keyboard monitoring. |
{
"Keyboard": {
"affinity": "2",
"priority": 9,
"active": 1
}
}
5. Reflector
Controls the CoreEngine-side thread that connects out to a running Reflector app instance and streams this engine's shared memory to it for remote monitoring and interaction.
| Field | Description |
|---|---|
affinity | CPU binding. |
priority | Thread priority. |
{
"Reflector": {
"affinity": "1",
"priority": 9
}
}
6. Startup Mode
Defines system boot behavior.
| Field | Description |
|---|---|
bootmode |
Startup state.
Possible values:
|
{
"startup": {
"bootmode": "play" // "stop"
}
}
7. Recorder
Controls recording subsystem behavior, including the nested per-signal coredb recording overrides (see below).
"recorder" key. A stray, differently-cased key such as "Recorder" is a separate, unrelated key as far as the parser is concerned and will not configure the recording subsystem — double-check casing if recorder settings don't seem to take effect.
| Field | Description |
|---|---|
affinity | CPU binding of the recorder threads (control, writer, capture). |
priority | Priority of the recorder threads. |
path | Output directory for recordings. Each recording gets a sub-directory named after its start time. |
flushAfterFrames | Data older than N frames is written to the file (default 50). Unbuffered I/O writes at most once a second per file, a rotating disk at most every 5 s. |
recordOnlyOnChange | Global default, record only when data changes; can be overridden per-signal in coredb. |
active | Enable/disable recording (true or 1/false or 0). |
coredb | Optional. The recorded items (LRU.block, LRU.*, a stream name) and their per-item settings (the old name DBSim is not read) — see the next section. |
Storage driver settings
The recording is done by the StorageDriver (CoreEngine creates it from this section; the same driver stores and reads blocks in streams.json, see Storage Driver, which also explains the write methods and the benchmark in detail). The simulation frame only copies the recorded data to memory: a separate writer thread writes the files, so a slow disk never delays the frame. All keys are optional; the defaults suit most setups.
| Field | Default | Description |
|---|---|---|
interfaceAPILib | "StorageDriverAPI" | The storage API library the driver loads (Windows <name>.dll, Linux lib<name>.so, next to the application). |
ioMode | "auto" | How files are written:
buffered = through the OS cache, one write at a time (works on any drive, network share, USB stick);
async = through the OS cache with queueDepth writes in flight;
direct = unbuffered, queueDepth writes in flight (the CrystalDiskMark SEQ1M Q8T1 pattern, best on SSD/NVMe);
auto = direct on SSD/NVMe, async on rotating or unknown drives.
If a drive refuses unbuffered I/O the recorder uses the OS cache for that file. |
queueSize / queueDepth | 8 | Writes in flight for async / direct (1..64). Windows: I/O completion port, Linux: io_uring. |
driveType | "auto" | ssd / hdd: overrides the drive detection (auto method, block sizes, flush intervals). |
blockSizeKB | 0 | Largest single write per file. 0 = auto: 1024 on SSD, 8192 on a rotating disk (fewer seeks between files). |
ringMB | 64 | Memory that holds recorded frames until they are written. It is allocated (and touched) once at engine init when the recorder is active, and kept for every recording session of the run: a recording that is started or restarted while the engine runs allocates nothing (a ring or staging block that had to be allocated while running is reported: memory allocated while running). Every drive has its own, so with two drives ringMB is allocated twice; a big value (512) costs that memory all the time, keep it just above what the slowest write burst needs (at least 4 frames). Grows to 4 frames and to 250 ms of the data recorded every frame. When it is full, frames are dropped and reported (see onOverflow). |
streamRingMB | 16 | Same, per recorded stream direction (stream drivers recording their messages). |
rateRingMB | 0 | Memory of the items with recRate (they have their own capture lane and ring).
0 = auto: 4 copies of those items and 250 ms of their data, allocated when the first recording session opens
(the console then says memory allocated while running: recRate ring of N KB ... set the recorder rateRingMB to M or more).
A value is allocated at engine init with the other rings, so a recording started while the engine runs allocates nothing.
Less than 4 copies is raised (with a warning). |
maxMemoryMB | 512 | Memory of the writer's per-file buffers. |
minBlockKB | 16 | Smallest write block per file. |
blockSeconds | 0 | Data per file block in seconds, 0 = auto (0.5 SSD, 8 rotating disk). |
flushIntervalMs | 0 | Same as flushAfterFrames in milliseconds; used when > 0. |
directFlushMs | 0 | Unbuffered partial writes at most this often, 0 = auto (1000, 5000 on a rotating disk). |
pollMs | 1 | Writer idle poll. |
onOverflow | "drop" | drop: when the disk does not keep up the frame is dropped (whole frame, counted, reported) and the simulation never waits.
wait: the simulation frame waits until there is room. |
capture | "auto" | Who copies the frame: inline = the simulation thread (a few microseconds for typical blocks);
thread = a capture thread during the idle part of the frame (for large items such as images);
auto = thread from captureThresholdKB per frame.
The decision is made each frame: small frames are copied by the simulation thread even when big items (recorded on change) need the thread. |
captureThresholdKB | 256 | Frames of this size and more go to the capture thread. Also the size from which an item with recRate gets the recRate lane; smaller ones are copied in the frame (see recRate). |
preallocateMB | 64 | Disk space reserved ahead for files written faster than 1 MB/s (0 = off). The file size is not changed. |
syncOnClose | false | Flush the files to the device when the recording closes. |
report | 0 | Recorder information on the console: 0 nothing, 1 the recorder setup
("Recorder config.json setup" when a session opens: files, capture, frame ring, recRate lane and its ring, I/O method per drive; memory pool;
frames, drops and MB per drive when it closes; playback start / end), no item lists;
2 the same and a table of every recorded item: name, kind (block, timing, stream in / out),
eng (B) and raw (B) per record, rate (ms) (recRate, or msg for a stream), on change (recordOnlyOnChange),
drives, max (MB/s) it can produce, and a note when the rate is automatic or limited. Errors and warnings are always shown. The older "report": true = level 1 + environmentReport. |
startRecording | "boot" | "boot": the first recording session opens when the engine runs, with the configured items.
"model": no session at start (the items are only prepared); the first session opens when a model calls CRecorder::StartRecording
(or a network record: command arrives). Use it when a model starts the recording itself (CAMRnD: at the first INS message): with
"boot" that call closes the boot session and opens a second one (two folders, two reports). |
environmentReport | false | At start, print the recording environment (drive type, available I/O, unbuffered alignment) and run a self test of every
storage driver method in every ioMode (writes and deletes test files under path/driver-report). Each line shows PASS/FAIL, the time and details. |
benchmark | false | true or an object: at start, measure every write method / queue size on path, print a table and the best
ioMode / queueSize as "recorder" keys to paste here (see Performance test). |
drives | [] | Several storage devices, each with its own setup: [ { "path": "D:/rec", "ioMode": "direct" }, { "path": "E:/rec", "ioMode": "async", "queueDepth": 8 } ].
A drive starts from the keys of this section and overrides what it sets (path, ioMode, queueDepth, ringMB, driveType, ...); every drive has its own writer thread, ring and capture thread.
A drive that needs no other setting is just its directory: "drives": [ "D:/rec/", "E:/rec/" ] (strings and objects can be mixed). Without path the recording directory is the first drive. Without drives there is one drive (this section). An item names the drives it is spread over with storage (see Several drives). |
storage | "" (drive 0) | The drives of the items that name none: "0", "0-1", "0,2-4,6,*", "*" (like the cores of affinity; * = the drives after the highest one listed: with 10 drives "0,2-4,6,*" is 0,2,3,4,6,7,8,9).
The records of an item on several drives go to the next drive with room: more MB/s than one device writes. The recording viewer needs the .seq files to merge them. |
playbackPath | newest | The recording played back by control:runplayback (a session directory). Default: the newest recording under path. |
playbackDrives | [] | Playback of a recording split over several drives that was copied from its devices to other folders: the folder of each drive, entry i = drive i. An entry is the folder that holds the session folder (same name as the one in playbackPath) or the session folder itself. Without playbackPath, entry 0 is the session folder of drive 0 or the folder that holds the sessions (the newest is played). Not needed when the copies keep their folder names next to each other, see Playing a copied recording. |
readAheadKB / loop | 1024 / false | Playback: data read ahead per file; start again at the end. |
{
"recorder": {
"affinity": "2",
"priority": 9,
"path": "C:/temp/rec_test3",
"flushAfterFrames": 5,
"recordOnlyOnChange": true,
"active": true,
"ioMode": "auto",
"queueDepth": 8,
"report": 1
}
}
The same section with two drives (each with its own setup; a string is just the directory) and the drives chosen per recorded item in coredb (section 8):
{
"recorder": {
"ioMode": "async",
"drives": [ { "path": "D:/rec/", "ioMode": "direct", "queueDepth": 32 }, "E:/rec/" ],
"storage": "0", // items that name no drive
"coredb": {
"CAM.cam.frame": { "storage": "0-1" }, // the big frame: split over both drives
"INS.*": { "storage": "1" }, // only the second drive
"INSStream": { "storage": "0-1" } // a stream driver's messages, split over both
}
}
}
ioMode auto: SSD, parallel writes (up to 8 at once), straight to the disk without the file cache)
when a recording starts, and a summary when it closes: MB recorded, MB/s, frames recorded and dropped.
A Recorder: data dropped warning means the drive is slower than the recorded data: use a faster drive, record less, or enlarge ringMB for short bursts.
Many late captures and dropped frames while the drive keeps up (ring almost empty, disk rate = data rate) mean an item is too big to be
copied within one minor frame (a camera image at a 1 ms frame): give it a recRate.
On a rotating disk, many recorded items mean many files and seeks: fewer, larger items record faster.
The profile view (Profiler) shows the recorder at run time, once per second: Recording capture
(the time the simulation frame spends recording), Recording data rate / disk rate, Recording ring
(data waiting for the writer), Recording writes/s and Recording drops; during playback Playback ... rows.
See Runtime performance report.
8. DBSim recording Configuration (Optional)
Nested inside recorder, this allows fine-grained control over which signals are
recorded and how. Supports wildcard patterns.
| Field | Description |
|---|---|
engSize |
-1 = use actual data size 0 = disabled >0 = bytes per record |
rawSize |
-1 = use actual data size 0 = disabled >0 = bytes per record |
recordOnlyOnChange |
true = the default, only record when the value changes false = record every frame regardless of value changes |
storage |
The drives the item is spread over (recorder drives): "0", "0-1", "0,2-4,6,*", "*".
Default: the recorder storage, else drive 0. An item added by code (CRecorder::AddRecordingItem) keeps the
storage of its entry here; the function also has a last storage argument.
|
recRate |
How often the item's data changes at most, written like framePerMS:
a number = milliseconds (33, "33.3ms"), "30hz", "1khz", "1mhz",
or "auto" = the framePerMS of the block in streams.json (a block in no stream or without framePerMS: one minor frame).
Not given (the default): the copy of the item must end within one minor frame, as before.
See Big items: recRate.
|
engSize/rawSize are especially useful when recording arrays with dynamic length but requiring a fixed storage size. An empty {} entry (e.g. "LRU_KZ.TLMAiding": {}) records that signal with default settings.
{
"recorder": {
...
"coredb": {
"LRU_KH.VirtualMessage": {
"recordOnlyOnChange": true, //default
"engSize": -1
},
"LRU_FC.Status": {
"recordOnlyOnChange": true, //default
"engSize": -1 //-1 means use the size of the data, 0 disabled. otherwise use the specified size. This is useful for arrays where the size may change but you want to record a fixed number of elements.
//"rawSize": 100
},
"LRU_KZ.FC_SensorsData35": {
"recordOnlyOnChange": true, //default
"engSize": -1
},
"CAM.cam.frame": {
"engSize": -1,
"recRate": "30hz" // a camera image: its copy may take one camera frame (33 ms) instead of one minor frame
}
}
}
}
Big items: recRate
Each minor frame the recorder copies the items whose data changed into its memory ring (the disk writes come later, on their own thread).
The copy runs on a capture thread and must be finished when the next minor frame starts, because that frame may change the data:
a copy still running then is aborted and tried again (onOverflow: "drop", counted as dropped and late), or the frame waits for it ("wait").
A big item does not fit: a 10.6 MB camera image (2592 x 2056, 16 bit) takes about 1 ms to copy, so with a 1 ms minor frame most of its copies are aborted,
and an aborted frame also loses the other items of that frame.
recRate tells the recorder how often the item's data really changes. The item then gets its own capture lane (own ring and capture thread, on every drive it is written to):
its copy may take until the first frame in which the data may change again (for "30hz" at a 1 ms frame: 33 frames), while the other items are still recorded every frame.
Without recRate nothing changes.
The recRate lane copies one capture at a time, so only records of captureThresholdKB (256 KB) and more go there.
A smaller item with a recRate (for example the INS blocks) is copied in the frame lane, every frame in which it changed:
in the shared lane it would wait behind the long copy of an image while its block is overwritten (an INS block with recRate 2 next to a
10.6 MB camera image lost 2 messages at every camera frame). The start report says how many recRate items are in the lane and how many are
small, and the detailed table ("report": 2) marks them "small record: copied every frame it changes".
- Where: here (
recordercoredbitem, also for wildcards:"CAM.*": { "recRate": "30hz" }), the networkrecord:JSON, or the program:CRecorder::AddRecordingItem(name, engSize, rawSize, onChange, storage, recRate),SetRecordingProperties(..., recRate),CRecorder::SetRecordingRate(name, "30hz")/SetRecordingRate(name, 33.3)(ms) (see Recorder API). A value given by the program wins;nullptrkeeps the one of config.json. "auto"takes theframePerMSof the block in streams.json (never a value of a driver). An in-block that publishes whenever a message arrives can change more often than itsframePerMS: check thechangedcount.- Declare the fastest rate the data can change at. A camera that delivers in bursts can deliver two images closer than its nominal frame time: declare a little faster (40 Hz for 30 fps).
When the data changes while it is copied, the copy is dropped and counted as
changed(it would be a mix of two images). This check finds most such cases, not all: a writer that changes the data and counts the message only afterwards can finish its write after the check. - Reports: the recording start lists the items and their period (
CAM.cam.frame: every 33.3 ms = 33 frames); the profile view has a rowRecording rate items(copies, longest copy, late, changed); the close report has arecRate itemsline per drive. Their drops and late copies are also counted inRecording drops, as before. - Memory:
rateRingMB(above).recordOnlyOnChange: falseon a recRate item records it whenever its lane is free.
9. EngineSync (Optional – Disabled)
Synchronizes engine time using an external telemetry element. Typically used for deterministic replay or hardware-aligned simulation. Comment out the block (as below) to leave it disabled.
| Field | Description |
|---|---|
stream | Name of the stream that carries the sync telemetry element. |
element | ICD element used as the sync source. |
syncPerMS | Sync interval in milliseconds. |
scale |
Optional. Rescales the raw sync element value before use.
|
affinity | CPU binding for the EngineSync thread. |
priority | Thread priority. |
{
"EngineSync": {
"stream": "SocketTCPTLMStream",
"element": "LRU_KZ.TLMAiding.SystemEventNumber",
"syncPerMS": "1000",
"scale": {
"engType": "float",
"scale": 1000
},
"affinity": "0,1,3,4-6",
"priority": 6
}
}
10. DBSim defaults setup
Specify a filename that holds element default/injection values, applied once at startup. The file can be JSON or a plain text file — see DBSim Defaults Setup File for the full format reference.
| Field | Description |
|---|---|
file | The JSON or text file containing the defaults. |
active | Enable/disable loading the defaults file (true or 1/false or 0). |
{
"coredbSetup": {
"file": "./setups/dbsimsetup.txt",
"active": true
}
}
Threading & Scheduling Strategy
- RealTime thread pinned to multiple cores for deterministic workload distribution.
- Keyboard and Reflector isolated on dedicated cores.
- High priority (9) reserved for latency-sensitive tasks.
- Recorder configured to minimize disk I/O overhead via buffered flushing.
priority (Linux real-time scheduling, SCHED_FIFO for the high priorities) requires root privilege. Without root the call is refused by the operating system and the thread keeps its default scheduling, so timing is less deterministic. Start the application as root (sudo) to apply the priority configuration.
Design Principles
- Deterministic execution via CPU affinity.
- Explicit thread priority control.
- Selective recording for performance optimization.
- Modular optional subsystems (EngineSync, DBSim).