Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cache sealing pipeline status #1209

Merged
merged 5 commits into from
Feb 22, 2023
Merged

Conversation

LexLuthr
Copy link
Collaborator

Fixes #1207

Suggested design by DIrk:

if there is no deal filter enabled in config, don't call the method at all

if the deal filter is enabled

check the cache
if the cache is empty

call the method
store the results in the cache
expire the result after x time (where x is configurable)
return the result

@LexLuthr LexLuthr requested a review from dirkmc February 22, 2023 13:15
@LexLuthr LexLuthr self-assigned this Feb 22, 2023
node/config/def.go Outdated Show resolved Hide resolved
storagemarket/provider.go Outdated Show resolved Hide resolved
storagemarket/provider_loop.go Outdated Show resolved Hide resolved

// sealingPipelineStatus updates the SealingPipelineCache to reduce constant sealingpipeline.GetStatus calls
// to the lotus-miner. This is to speed up the deal filter processing
func (p *Provider) sealingPipelineStatus() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because this call is quite expensive, I'd suggest that we don't do in continuously.

Instead I suggest that when there's a call to get the sealing pipeline status

  • check the cache
    • if the value has not expired
      • return the value
      • in the background run a process to get a new value
    • if the value has expired
      • get a new value and wait for it before returning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have tweaked the logic a little more. Since we are processing one deal at a time, there is no chance of clash if we don't use goroutines
Filter requests sealing status:

  • Check cache
    • if expired or cache error is true
      • fetch new status (keep the caller waiting)
      • This would also work when Boost starts
      • Return the new status to caller and update cache
    • if cache is not expired
      • Return the cached status to caller (no waiting)
      • Don't trigger a refresh in case we have multiple deals processing at the same time
        • This would prevent the scenario where goroutine and sealingPipelineStatus() both try to update the cache
        • Or we can use locks to prevent this (more complexity)

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with the code as implemented is that we're repeatedly calling sealingpipeline.GetStatus, even if there are no deal proposals being made. We have seen that this can be a very expensive call (sometimes takes ~30s). So I would prefer to change the logic to only call sealingpipeline.GetStatus when it's needed. That's what I've proposed above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh! Sorry for the confusion in that case.
I have corrected the logic. Pushed new commit with changes.

Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Just one comment, please fix and then merge when ready

storagemarket/provider.go Outdated Show resolved Hide resolved
@LexLuthr LexLuthr merged commit 7c8f0da into main Feb 22, 2023
@LexLuthr LexLuthr deleted the fix/cache-slngpiplnstatus branch February 22, 2023 15:42
LexLuthr added a commit that referenced this pull request Feb 22, 2023
* cache sealing pipeline status

* fix test, surface config

* redesign logic, implement suggestions

* fix type conversion

* fix config override
LexLuthr added a commit that referenced this pull request Feb 22, 2023
…ejection (#1211)

* feat: cache sealing pipeline status (#1209)

* cache sealing pipeline status

* fix test, surface config

* redesign logic, implement suggestions

* fix type conversion

* fix config override

* fix: BasicDealFilter logic (#1210)

* add more data to dealfilterparam

* fix BasicDealFilter logic

* use IsOffline

* remove external filter params
LexLuthr added a commit that referenced this pull request Feb 24, 2023
* cache sealing pipeline status

* fix test, surface config

* redesign logic, implement suggestions

* fix type conversion

* fix config override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Very slow offline deal acceptance on v1.5.1
2 participants