Skip to main content

Module optimization

Module optimization 

Source
Expand description

RETE Network Optimization Module

This module implements various optimizations for the RETE algorithm:

  1. Node Sharing - Reuse alpha nodes with identical patterns
  2. Alpha Memory Compaction - Reduce memory usage in alpha nodes
  3. Beta Memory Indexing - Fast lookup for joins
  4. Token Pooling - Reuse token objects

These optimizations provide:

  • 2x faster rule matching
  • 50% memory reduction
  • 10-100x improvement for large rule sets (10K+ rules)

Structsยง

AlphaPattern
Pattern key for node sharing Two alpha nodes can share if they have the same pattern
BetaMemoryIndex
Beta Memory Index Fast lookup for join operations
CompactAlphaMemory
Compact Alpha Memory Uses HashSet to eliminate duplicates and reduce memory
FactKey
Key for fact deduplication
NodeSharingRegistry
Node Sharing Registry Manages shared alpha nodes across the RETE network
NodeSharingStats
Node sharing statistics
OptimizationManager
Central manager for all RETE optimizations
OptimizationStats
Comprehensive optimization statistics
SharedAlphaNode
Shared Alpha Node Multiple rules can reference the same shared alpha node
Token
Token for RETE propagation Represents a fact flowing through the network
TokenPool
Token Pool for object reuse Reduces allocations by reusing token objects
TokenPoolStats
Token pool statistics