Context
ReteCompiledEngine.createUnit() currently iterates sourceToSlot.entrySet() to subscribe DataStore adapters. This is on the hot path (called per unit instance creation) and uses map iteration, boxing, and identity hash map overhead.
Required design
At compile() time, assign each DataSource accessor a compact integer slot index (0..N-1). Store results as parallel arrays:
Object[] accessors — one accessor per slot
ContextRouterAdapter[] adapters — one adapter per slot (populated lazily on first createUnit())
createUnit() then iterates:
for (int i = 0; i < slotCount; i++) {
Object ds = ((Function1<CTX, DataSource<?>>) accessors[i]).apply(ctx);
// ...subscribe adapter[i]...
}
Slot assignments must be dense (no gaps). Vol1 recycled arrays with compact slot assignment for the same reason. IdentityHashMap-based sourceToSlot stays for build-time use only.
Note
All vol2 evaluation is single-threaded (command-loop model) — no concurrent data structures needed.
Refs #6724
Context
ReteCompiledEngine.createUnit()currently iteratessourceToSlot.entrySet()to subscribe DataStore adapters. This is on the hot path (called per unit instance creation) and uses map iteration, boxing, and identity hash map overhead.Required design
At compile() time, assign each DataSource accessor a compact integer slot index (0..N-1). Store results as parallel arrays:
Object[] accessors— one accessor per slotContextRouterAdapter[] adapters— one adapter per slot (populated lazily on first createUnit())createUnit() then iterates:
Slot assignments must be dense (no gaps). Vol1 recycled arrays with compact slot assignment for the same reason. IdentityHashMap-based sourceToSlot stays for build-time use only.
Note
All vol2 evaluation is single-threaded (command-loop model) — no concurrent data structures needed.
Refs #6724