Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

add est-download-speed to make data fetching timeout adjustable #35

Merged
merged 2 commits into from Aug 13, 2021

Conversation

merlinran
Copy link
Contributor

Adding this seemingly useful feature, while I'm here.

Resolves #33

Signed-off-by: Merlin Ran <merlinran@gmail.com>
fetchTimeout := DefaultDataURIFetchTimeout
if size != 0 {
// add baseline timeout for very small files
fetchTimeout = time.Minute + time.Duration(size/s.estDownloadSpeed)*time.Second
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered making the fetch timeout 2X the value, but don't want to introduce some magic number. The default is small enough, and the help message asked the miners to be conservative.

// DataURIFetchTimeout is the timeout used when fetching data uris.
DataURIFetchTimeout = time.Hour * 3
// DefaultDataURIFetchTimeout is the timeout used when fetching data uris of unknown size.
DefaultDataURIFetchTimeout = time.Hour * 10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extended the default now it's only used in the download command.

@merlinran merlinran requested a review from jsign August 13, 2021 21:19
Copy link
Contributor

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but suggest a much lower default.

@@ -491,7 +494,13 @@ func (s *Store) WriteDataURI(bidID auction.BidID, payloadCid, uri string) (strin
if _, err := f.Seek(0, 0); err != nil {
return "", fmt.Errorf("seeking file to the beginning: %v", err)
}
ctx, cancel := context.WithTimeout(s.ctx, DataURIFetchTimeout)
fetchTimeout := DefaultDataURIFetchTimeout
if size != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, i see now why service/service.go:L302 works.

Comment on lines +48 to +49
// DefaultDataURIFetchTimeout is the timeout used when fetching data uris of unknown size.
DefaultDataURIFetchTimeout = time.Hour * 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conservative ha. SGTM.

main.go Outdated
@@ -124,6 +124,12 @@ func init() {
DefValue: 24 * time.Hour,
Description: "The timeout before discarding deal with no progress",
},
{
Name: "est-download-speed",
DefValue: "5MB",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more conservative here. The existing default was 3hs.
The usual CAR files are ~32GiB, and usually, the same miner receives a batch of things to download.. so more than one thing downloading at the same time. Maybe 1MB/s as default.

I believe we have much more room for improvement in all this download+import... like, a miner downloading 10 CAR files at the same time not only is a risk for download, but I'd imagine importing 10 CAR files later at the same time might nuke their lotus node.

We could always cap the amount of things done concurrently as I suggested some times.. but that's another feature that requires a bit more work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for 1MB/s would be 9hs. If is downloading 3 CAR files at the same time, is an avg of 3hs per CAR. (all hand-wavy...)
Maybe too conservative... but around there, could be a bit more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1MB sounds good. it is what I originally set. good point on concurrent downloads. Maybe just limit MaxDataURIFetchConcurrency to 3? 10 concurrent downloads won't make sense if the bottleneck is bandwidth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I believe we need that flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point might be good to stop bidding if you already have X things waiting for download [just sharing thought for a next feature]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an existing constant we can simply change right now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right didn't recall. LGTM to switch to 3.

Signed-off-by: Merlin Ran <merlinran@gmail.com>
@merlinran merlinran merged commit 2800f0f into main Aug 13, 2021
@merlinran merlinran deleted the merlin/bandwidth-limit branch August 13, 2021 22:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Ability to change the URI Fetch Timeout through the config file
2 participants