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

[R4R]validator rpc api consume mutch time #61

Merged
merged 6 commits into from
Apr 10, 2019
Merged

Conversation

unclezoro
Copy link
Collaborator

@unclezoro unclezoro commented Mar 15, 2019

Description

fix /validators rpc response time grow with time.

Rationale

This pr do not fully resolve the issue.

There still one problem:
** for recent 1048576 block, it will get exactly result. But the block before that height,
the ProposerPriority is not accurate. **

My concern is that it takes too much cost to get ProposerPriority(we have to get each block round and replay it ).

put the pr in tendermint, community want to rewrite IncrementProposerPriority, but since it is a hard fork, it will not be that quick, so this pr is a hot fix, I will keep trace it
tendermint/tendermint#3438
Now community submit this pr:
tendermint/tendermint#3537

Example

After fix this, no matter what hight we use, it takes 0.01s.

Changes

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

@unclezoro unclezoro changed the title [WIP]fix validator rpc api consume mutch time [R4R]fix validator rpc api consume mutch time Mar 15, 2019
@unclezoro unclezoro requested review from ackratos, darren-liu, rickyyangz and yutianwu and removed request for ackratos March 15, 2019 12:44
@unclezoro unclezoro self-assigned this Mar 15, 2019
@unclezoro unclezoro changed the title [R4R]fix validator rpc api consume mutch time [WIP]fix validator rpc api consume mutch time Mar 17, 2019
@unclezoro unclezoro changed the title [WIP]fix validator rpc api consume mutch time [R4R]fix validator rpc api consume mutch time Mar 17, 2019
@unclezoro unclezoro changed the title [R4R]fix validator rpc api consume mutch time [R4R]hot fix: validator rpc api consume mutch time Mar 28, 2019
state/store.go Outdated
@@ -202,7 +201,14 @@ func (valInfo *ValidatorsInfo) Bytes() []byte {

// LoadValidators loads the ValidatorSet for a given height.
// Returns ErrNoValSetForHeight if the validator set can't be found for this height.
func LoadValidators(db dbm.DB, height int64) (*types.ValidatorSet, error) {
// Notice: for recent 1048576 block, it will get exactly result. But the block before that height,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we change comment magic number into latestStateToKeep?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

state/store.go Outdated
proposalAddr := meta.Header.ProposerAddress
_, proposer := valInfo.ValidatorSet.GetByAddress(proposalAddr.Bytes())
if proposer == nil {
panic(
Copy link
Contributor

@ackratos ackratos Mar 28, 2019

Choose a reason for hiding this comment

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

doesn't look like it need panic here, can we just log an error? Or the panic would be captured on entrance of query?

Copy link
Collaborator Author

@unclezoro unclezoro Mar 28, 2019

Choose a reason for hiding this comment

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

I think panic is ok(the previous code before I modified is also panic). When can't find proposer from ValidatorSet or can't load valInfo2 from store, our data store is broken, which is a disaster, just fail fast. This service weight accurate more than availability.

@abelliumnt
Copy link
Contributor

tendermint/tendermint#3044 (comment)

valInfo2.ValidatorSet.IncrementProposerPriority(int(height - valInfo.LastHeightChanged)) // mutate

According to the above comment, I think there is no accuracy issue about ProposerPriority calculation. Do you agree with me?

if height - valInfo.LastHeightChanged is huge, IncrementProposerPriority will cost too much time. Is this the root reason of consuming too much time?

)
}
valInfo2.ValidatorSet.IncrementProposerPriority(int(height - valInfo.LastHeightChanged)) // mutate
Copy link
Contributor

Choose a reason for hiding this comment

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

Without IncrementProposerPriority, the priority information of getted valInfo may be inaccurate. Why not to save validator info at every height.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without IncrementProposerPriority, the priority information of getted valInfo may be inaccurate. Why not to save validator info at every height.

It takes too much storage, almost reduntant. @ackratos have save it in 100000000 recent blocks, but before that just rewrite the storage

Copy link
Contributor

Choose a reason for hiding this comment

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

How about save validator info at every 1000 or 10000 height no matter validator change or not? Thus IncrementProposerPriority would not cost too much time and disk storage will be much less.

@unclezoro unclezoro changed the title [R4R]hot fix: validator rpc api consume mutch time [WIP]hot fix: validator rpc api consume mutch time Apr 1, 2019
@unclezoro
Copy link
Collaborator Author

tendermint/tendermint#3044 (comment)

valInfo2.ValidatorSet.IncrementProposerPriority(int(height - valInfo.LastHeightChanged)) // mutate

According to the above comment, I think there is no accuracy issue about ProposerPriority calculation. Do you agree with me?

if height - valInfo.LastHeightChanged is huge, IncrementProposerPriority will cost too much time. Is this the root reason of consuming too much time?

Yes, IncrementProposerPriority will cost too much time. I do not notice the comment previous, try to dive it. Change state R4R to WIP

@unclezoro unclezoro changed the base branch from master to develop April 10, 2019 05:38
@unclezoro unclezoro changed the title [WIP]hot fix: validator rpc api consume mutch time [R4R]validator rpc api consume mutch time Apr 10, 2019
@unclezoro unclezoro merged commit be7c020 into develop Apr 10, 2019
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.

None yet

4 participants