peerstore: next steps for datastore-backed peerstore #1702
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
status/in-progress
In progress
Following libp2p/go-libp2p-peerstore#34, we're in a pretty good state vs. baseline. Performance benchcmp here: libp2p/go-libp2p-peerstore#31 (comment)
Summing up my thoughts here on how to move forward.
We should find a way to reduce the cost of
Peers()
. IPFS doesn't call it from critical paths (only CLI commands), but as libp2p powers more projects, we should not make assumptions about how users will be calling us.PeersWithAddrs()
traverses the entire KV store building a set of unique peers.go-datastore
iterator doesn't allow us to seek arbitrarily, but badger does. Instead of ingesting all keys, and comparing them, we want to perform a "fold" operation taking advantage of the fact that badger is an ordered LSM tree. When we encounter a new peer, we skip over all keys untilValidForPrefix
is no longertrue
. That means we've encountered another peer, and we use that as the new prefix to seek against./peeridx
keyspace. Then we can just iterate through a small keyspace instead of the entire database.Regarding option 3 above, find a way to store the earliest and tardiest expirations.
Use the
ds.Key
functionality to create key hierarchies, e.g./peer:<id>/addr:<hash or index>
=>multiaddr
.Migrate the KeyBook and the PeerMetadata substores, under appropriate hierarchical namespaces as per above.
Find a way to remove the multiaddr hash from the peer's key, maybe replacing it with some kind of sequence number.
Spin off pstoreds package into top-level module:
go-libp2p-peerstore-ds
.EDIT: Consider moving
PeerInfo
to somewhere more common.The text was updated successfully, but these errors were encountered: