filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.82k stars 1.25k forks source link

Chain export inefficiencies #4994

Open austinabell opened 3 years ago

austinabell commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

When walking a snapshot, ipld nodes are loaded 2x more than they need to, as well as redundant data structures (2 hashsets and 1 array to do what it seems 1 hashset could)

For extra blockstore reads: Whenever the callback happens, the Cid is loaded from the blockstore (https://github.com/filecoin-project/lotus/blob/a63ef1dcd549d800b93bd504703d5b25f187606a/chain/store/store.go#L1360), but also in addition to this, it's also read when it's used during walking (https://github.com/filecoin-project/lotus/blob/a63ef1dcd549d800b93bd504703d5b25f187606a/chain/store/store.go#L1393, https://github.com/filecoin-project/lotus/blob/a63ef1dcd549d800b93bd504703d5b25f187606a/chain/store/store.go#L1318, ...)

Extra data structures:

Let me know if I'm missing something here, I've implemented without these (using the callback to pass back the loaded bytes and only one hashset) and it seems to work the same, but I could be missing an edge case. This also doesn't matter that much to optimize, so probably a low priority ticket.

To Reproduce Steps to reproduce the behavior:

  1. Run '...'
  2. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Version (run lotus version):

Additional context Add any other context about the problem here.

raulk commented 3 years ago

@austinabell ditto. I've ran into these inefficiencies when trying to produce a full snapshot. The current logic tries to remove duplicates, but it could be done differently.

jennijuju commented 3 years ago

@vyzo mentioned he may be interested in this😉

Kubuxu commented 1 year ago

Another thing of note is that lotus doesn't seem to stream the export CARs.