Open raulk opened 6 years ago
Tagged a few people just to make you aware of the future direction I'd like to pursue with the peerstore, following all the work that has been done already.
Not feasible because TTL management needs to be fine-grained (up to the multiaddr).
We can also manage this using a GC system. That is, store large records and periodically sweep.
Note: We also don't need to use TTLs if you can think of a better metric/system.
i think this is a definite case for indexing, as you suggest. a note: we can also open multiple badger data stores instead of namespacing keys if it suits. it’s designed to have that be an alternative to multiple column families.
@raulk What is the status of this as of date ? I'd like to help out with this by picking up some some of the chunks if possible.
Following libp2p/go-libp2p-peerstore#34, we're in a pretty good state vs. baseline. Performance benchcmp here: https://github.com/libp2p/go-libp2p-peerstore/issues/31#issuecomment-421433125
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.