Skip to content

Comments

agent: reduce full config check frequency from 5s to 1m and compare config hashes instead#3028

Draft
nikw9944 wants to merge 2 commits intomainfrom
nikw/config-agent-cpu
Draft

agent: reduce full config check frequency from 5s to 1m and compare config hashes instead#3028
nikw9944 wants to merge 2 commits intomainfrom
nikw/config-agent-cpu

Conversation

@nikw9944
Copy link
Contributor

Summary of Changes

  • agent: reduce network and CPU usage by reducing full config check frequency from 5s to 1m and comparing config hashes instead
  • This change will reduce CPU load on Arista devices
  • It will also reduce CPU load in test environments like e2e

Testing Verification

  • Unit test updates

@nikw9944 nikw9944 linked an issue Feb 17, 2026 that may be closed by this pull request
@nikw9944 nikw9944 changed the title agent: reduce network and CPU usage by reducing full config check frequency from 5s to 1m and comparing config hashes instead agent: reduce full config check frequency from 5s to 1m and compare config hashes instead Feb 17, 2026
@nikw9944 nikw9944 self-assigned this Feb 20, 2026
@nikw9944 nikw9944 force-pushed the nikw/config-agent-cpu branch from 7260b33 to e81a21e Compare February 20, 2026 19:41
@nikw9944
Copy link
Contributor Author

nikw9944 commented Feb 21, 2026

BEFORE: Simple polling every 5 seconds

┌─────────┐                 ┌────────────┐                 ┌────────────┐                  ┌─────────┐
│  Agent  │                 │ Controller │                 │ Controller │                  │   EOS   │
│  main() │                 │ GetConfig()│                 │  Config    │                  │ Device  │
│         │                 │   (gRPC)   │                 │  Generator │                  │         │
└────┬────┘                 └─────┬──────┘                 └─────┬──────┘                  └────┬────┘
     │                            │                              │                              │
     │ Every 5s:                  │                              │                              │
     │                            │                              │                              │
     │ GetBgpNeighbors()          │                              │                              │
     ├─────────────────────────────────────────────────────────────────────────────────────────►│
     │◄─────────────────────────────────────────────────────────────────────────────────────────┤
     │ [peer IPs]                 │                              │                              │
     │                            │                              │                              │
     │ GetConfigFromServer()      │                              │                              │
     ├───────────────────────────►│                              │                              │
     │                            │ processConfigRequest()       │                              │
     │                            ├─────────────────────────────►│                              │
     │                            │                              │ generateConfig()             │
     │                            │                              │  • deduplicateTunnels()      │
     │                            │                              │  • renderConfig()            │
     │                            │                              │    (~50KB config text)       │
     │                            │◄─────────────────────────────┤                              │
     │                            │ [config string]              │                              │
     │◄───────────────────────────┤                              │                              │
     │ ConfigResponse             │                              │                              │
     │ {config: "..."}            │                              │                              │
     │                            │                              │                              │
     │ AddConfigToDevice(config)  │                              │                              │
     ├─────────────────────────────────────────────────────────────────────────────────────────►│
     │◄─────────────────────────────────────────────────────────────────────────────────────────┤
     │ [config applied]           │                              │                              │
     │                            │                              │                              │
     │ sleep(5s)                  │                              │                              │
     │ goto top                   │                              │                              │
     │                            │                              │                              │

AFTER: Hash-based polling (5s hash check, 5m full config fetch)

┌─────────┐                 ┌────────────┐                 ┌────────────┐                  ┌─────────┐
│  Agent  │                 │ Controller │                 │ Controller │                  │   EOS   │
│  main() │                 │GetConfigHash                 │  Config    │                  │ Device  │
│         │                 │ GetConfig()│                 │  Generator │                  │         │
└────┬────┘                 └─────┬──────┘                 └─────┬──────┘                  └────┬────┘
     │                            │                              │                              │
     │ Every 5s:                  │                              │                              │
     │                            │                              │                              │
     │ GetBgpNeighbors()          │                              │                              │
     ├─────────────────────────────────────────────────────────────────────────────────────────►│
     │◄─────────────────────────────────────────────────────────────────────────────────────────┤
     │ [peer IPs]                 │                              │                              │
     │                            │                              │                              │
     │ Decision: should fetch?    │                              │                              │
     │  • First run (no hash)?    │                              │                              │
     │  • 1m since last apply?    │                              │                              │
     │  • Hash changed?           │                              │                              │
     │                            │                              │                              │
     │ GetConfigHashFromServer()  │                              │                              │
     ├───────────────────────────►│                              │                              │
     │                            │ processConfigRequest()       │                              │
     │                            ├─────────────────────────────►│                              │
     │                            │                              │ generateConfig()             │
     │                            │                              │  • deduplicateTunnels()      │
     │                            │                              │  • renderConfig()            │
     │                            │                              │ SHA256(config)               │
     │                            │◄─────────────────────────────┤                              │
     │                            │ [hash only]                  │                              │
     │◄───────────────────────────┤                              │                              │
     │ ConfigHashResponse         │                              │                              │
     │ {hash: "abc123..."}        │                              │                              │
     │ (64 bytes)                 │                              │                              │
     │                            │                              │                              │
     │ Compare: hash != lastHash? │                              │                              │
     │                            │                              │                              │
     ├─── if YES (or first run or 5m timeout):                                                  │
     │                            │                              │                              │
     │    fetchConfigFromController()                            │                              │
     │    ├─► GetConfigFromServer()                              │                              │
     │    │   ──────────────────► │                              │                              │
     │    │                       │ processConfigRequest()       │                              │
     │    │                       ├─────────────────────────────►│                              │
     │    │                       │                              │ generateConfig()             │
     │    │                       │                              │  • deduplicateTunnels()      │
     │    │                       │                              │  • renderConfig()            │
     │    │                       │                              │    (entire config text)      │
     │    │                       │◄─────────────────────────────┤                              │
     │    │   ◄──────────────────│ [config string]               │                              │
     │    │   ConfigResponse      │                              │                              │
     │    │   {config: "..."}     │                              │                              │
     │    │                       │                              │                              │
     │    ├─► computeChecksum(config)                            │                              │
     │    │   [local SHA256]      │                              │                              │
     │    │                       │                              │                              │
     │    └─► return config+hash  │                              │                              │
     │                            │                              │                              │
     │    applyConfig()           │                              │                              │
     │    └─► AddConfigToDevice(config)                          │                              │
     │        ─────────────────────────────────────────────────────────────────────────────────►│
     │        ◄─────────────────────────────────────────────────────────────────────────────────┤
     │        [config applied]    │                              │                              │
     │                            │                              │                              │
     │    lastChecksum = hash     │                              │                              │
     │    lastApplyTime = now     │                              │                              │
     │                            │                              │                              │
     ├─── else: skip this cycle (hash unchanged, no work needed) |                              │
     │                            │                              │                              │
     │ sleep(5s)                  │                              │                              │
     │ goto top                   │                              │                              │
     │                            │                              │                              │

…quency from 5s to 1m and comparing config hashes instead
…the hash is now only computed when fetching new config, not on every 5s poll cycle.
@nikw9944 nikw9944 force-pushed the nikw/config-agent-cpu branch from e81a21e to 96bd570 Compare February 21, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce config agent resource consumption

1 participant