Skip to content

v0.20251029.0

@berendt berendt tagged this 29 Oct 14:06
Further optimize SONIC configuration generation by implementing global
caching strategies for metalbox devices and VIP addresses, and simplifying
peer type calculation.

Changes in config_generator.py:

1. Metalbox Global Cache:
   - Add _metalbox_devices_cache global variable
   - Create _load_metalbox_devices_cache() to bulk fetch all metalbox
     devices, interfaces, and IPs at sync start
   - Modify _get_metalbox_ip_for_device() to use pre-loaded cache
   - Performance: O(N × M × K) → O(1) lookups

2. Peer Type Optimization:
   - Simplify _determine_peer_type() to use existing device_as_mapping
   - Eliminate redundant spine/superspine device queries and group calculations
   - Performance: Removed O(N) queries per peer type check

Changes in connections.py:

3. VIP Addresses Global Cache:
   - Add _vip_addresses_cache global variable
   - Create load_vip_addresses_cache() to bulk fetch all VIP addresses at sync start
   - Create clear_vip_addresses_cache() for cache cleanup
   - Modify get_connected_interface_ipv4_address() to use cached VIPs
   - Performance: O(N × P) → O(1) lookups

Changes in sync.py:

4. Cache Integration:
   - Call _load_metalbox_devices_cache() after cache clearing
   - Call load_vip_addresses_cache() after cache clearing
   - Add clear_vip_addresses_cache() to cleanup process

All function signatures preserved. Error handling and logging patterns maintained.

AI-assisted: Claude Code

Signed-off-by: Christian Berendt <berendt@osism.tech>
Assets 2
Loading