filecoin-project / lotus

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

Re-tune piece-reader to allow for random parallel access of data #10532

Closed rjan90 closed 1 year ago

rjan90 commented 1 year ago

Re-tune the piece reader code to allow for random, parallel access to unblock retrieval bottlenecks.

Quote from Magik:

from what I’ve observed in booster-bitswap (which most of the time is serving ~150 blocks/sec), the bottleneck comes from the piece-reader code, which was optimized for sequential full-piece retrievals. Given that now we need more random-access reads of data in sectors, that bit of code needs to be re-tuned to allow random, parallel access (lack of which seems to be a major bottleneck in traces I’ve observed).

Just tuning piece-reader should be easy ~10x, for more we may need to educate SPs on how to store unsealed sectors (e.g. when using RAID configure large stripe size, so that only one/fewer drive heads need to move to read each block)

Estimated time effort: 1-2 days

magik6k commented 1 year ago

Some more context:

shrenujbansal commented 1 year ago

@magik6k @rjan90 This domain/logic/code is completely foreign to me. Could you provide some basic instructions I can perform to witness the core issue locally? So I'm guessing something that performs a retrieval on an unsealed sector and takes long

davidd8 commented 1 year ago

Following up here, as this is an important fix that will enable SPs to serve retrievals at scale, since retrieval traffic from Saturn and the wider IP network will request smaller (<< piece size) and "random" data from SPs, not just full Pieces. In practice and through load testing (testing results, http load testing tool and example), we've seen the current limitations, so we currently heavily rate-limit Saturn nodes from requesting from SPs.

A 10x performance improvement would help us increase the rate limit to a level that should enable SPs to handle all of Project Rhea's traffic, agnostic of transport protocol, which is why we should try to get this into Lotus sooner, rather than later. Can we get it into 1.23?

brendalee commented 1 year ago

Here is a link to the load testing tooling that @hannahhoward and team built for load testing: https://github.com/filecoin-project/retrieval-load-testing

Adding a bit more to what @davidd8 mentioned, we saw the impact of this specifically with the range request http load testing in Boost (this has similar access patterns as bitswap retrievals).