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

[Execution] Add ingestion throttle #5337

Merged
merged 8 commits into from
Apr 17, 2024
Merged

Conversation

zhangchiqing
Copy link
Member

@zhangchiqing zhangchiqing commented Feb 1, 2024

Working towards #5298

This PR adds a throttle module that allows execution ingestion engine to load up to the first 500 blocks and start fetching data and executing them even if it's falling far behind.

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 136 lines in your changes are missing coverage. Please review.

Project coverage is 56.15%. Comparing base (f5d8ff9) to head (669e087).

Files Patch % Lines
engine/execution/ingestion/throttle.go 0.00% 136 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5337      +/-   ##
==========================================
+ Coverage   55.63%   56.15%   +0.52%     
==========================================
  Files        1037      824     -213     
  Lines      101339    81121   -20218     
==========================================
- Hits        56376    45555   -10821     
+ Misses      40624    31988    -8636     
+ Partials     4339     3578     -761     
Flag Coverage Δ
unittests 56.15% <0.00%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhangchiqing zhangchiqing force-pushed the leo/ingestion-throttle branch from dd61789 to b118353 Compare March 4, 2024 16:52
@zhangchiqing zhangchiqing force-pushed the leo/ingestion-throttle branch from b118353 to b9d994a Compare March 27, 2024 00:08
@zhangchiqing zhangchiqing marked this pull request as ready for review March 27, 2024 00:08
@zhangchiqing zhangchiqing requested a review from ramtinms as a code owner March 27, 2024 00:08
engine/execution/ingestion/throttle.go Show resolved Hide resolved
return err
}
} else {
unexecuted, err = findFinalized(c.state, c.headers, c.executed, c.executed+500)
Copy link
Contributor

Choose a reason for hiding this comment

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

c.executed+500

is 500 supposed to be b.threshold or just a different constant value we use for the range? If the latter, please make it a const with some comments about how it's used

engine/execution/ingestion/throttle.go Show resolved Hide resolved
}, nil
}

func (c *BlockThrottle) Init(processables chan<- flow.Identifier) error {

This comment was marked as resolved.

Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

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

IMO if the block throttle is not inited, or executed > finalized I would just make the block throttle behave as if it isn't there instead of producing errors.

What do you think?

// CatchUpThreshold is the number of blocks that if the execution is far behind
// the finalization then we will only lazy load the next unexecuted finalized
// blocks until the execution has caught up
const CatchUpThreshold = 500
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the default value?

Suggested change
const CatchUpThreshold = 500
const DefaultCatchUpThreshold = 500

engine/execution/ingestion/throttle.go Show resolved Hide resolved
defer c.mu.Unlock()

if !c.inited {
return fmt.Errorf("throttle not inited")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really an error scenario? Wont the BlockThrottle just get inited later in which case we can continue?

Copy link
Member Author

@zhangchiqing zhangchiqing Apr 12, 2024

Choose a reason for hiding this comment

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

This is to make sure c.processables is not nil, which is supposed to be updated already by the Init function. If we continue, it will panic with nil error.

But I will refactor to turn inited into a function and just check if c.processables == nil.

@zhangchiqing zhangchiqing added this pull request to the merge queue Apr 16, 2024
Merged via the queue into master with commit b772212 Apr 17, 2024
55 checks passed
@zhangchiqing zhangchiqing deleted the leo/ingestion-throttle branch April 17, 2024 00:40
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.

4 participants