mdproctor opened a new issue, #6710:
URL: https://github.com/apache/incubator-kie-drools/issues/6710

   ## Summary
   
   Replace `Router`'s `List<List<UnitProcessor<CTX, ?>>>` with a flat 
`UnitProcessor<CTX, ?>[]` — one slot, one call. Fan-out (multiple rules 
subscribing to the same slot) is handled by a pre-compiled 
`FanOutUnitProcessor` placed at subscribe time. Also replace the 
`List<UnitInstance<CTX>> contexts` with a `UnitInstance<CTX>[]` array for 
cache-friendly iteration.
   
   ## Design
   
   From DESIGN-NOTES.md (2026-05-07):
   
   > The Router's processor table is a `UnitProcessor[]` array — one entry per 
slot. Dispatch is a single array index lookup + one method call: 
`processors[slot].add(unit, handle)`. There is no inner list to iterate — no 
linear slowdown as the number of rules or inlets grows.
   >
   > Fan-out (multiple rules subscribing to the same slot) is handled by a 
pre-compiled composite processor (`FanOutUnitProcessor`) placed at that slot by 
`compile()`. The Router is unaware of fan-out — it always makes one call.
   >
   > `contexts` is also an array (not a list) for cache-friendly iteration. 
Total dispatch cost: O(k) where k = active units.
   
   ## Changes
   
   - `Router.java` — `processors: List<List<>>` → `UnitProcessor<CTX, ?>[]`; 
`contexts: List<>` → `UnitInstance<CTX>[]` with swap-and-shrink remove; 
dispatch uses direct array index
   - `FanOutUnitProcessor.java` — new package-private composite processor; 
holds array of processors; dispatches to all
   - `ContextHandle.java` — new package-private handle holding a 
`UnitInstance<?>` reference (replaces `IndexHandle` for context add/remove)
   - `IndexHandle.java` — no longer used by Router; can be removed if no other 
callers
   
   ## Parent epic
   
   #6684


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to