kadena-io / chainweb-node

Chainweb: A Proof-of-Work Parallel-Chain Architecture for Massive Throughput
https://docs.kadena.io/basics/whitepapers/overview
BSD 3-Clause "New" or "Revised" License
248 stars 95 forks source link

Optimize PeerDb peer selection and pruning #2023

Closed edmundnoble closed 2 weeks ago

edmundnoble commented 4 weeks ago

This code is already strict enough. ixset-typed's IxSet is a set and a strict list of maps. When updated, ixset-typed will force the set and maps to whnf, and insert the new element into a Set. Sets are strict in their elements and maps are strict in their keys, and the value type PeerEntry is itself strict in its components, so the newly inserted PeerEntry will be forced, as well as the indices containing it and the set containing it.

The force also requires touching every single component of the IxSet, which is probably expensive.