-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
perf: Return the execution tipset in GetMsgInfo #10632
Conversation
141656a
to
a11752f
Compare
a11752f
to
61ca075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fridrik01 This LGTM, but do we know how much faster it is? I'm a bit disinclined to merge it if it isn't a significant improvement. My guess is that it won't be much faster, because if we have a match in this index, then we've likely already walked up to the execution tipset's height, which means the ChainStore's index is likely already warmed up to this height, in which case the perf gain might be negligible.
I don't have any good reason NOT to merge this, though, so feel free to say "just merge it" :P
chain/stmgr/searchwait.go
Outdated
if err != nil { | ||
return nil, nil, cid.Undef, xerrors.Errorf("error looking up execution tipset: %w", err) | ||
var xts *types.TipSet = nil | ||
if xtsCid != cid.Undef { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if xtsCid != cid.Undef { | |
if xtsCid.Defined() { |
chain/stmgr/searchwait.go
Outdated
xts, err := sm.cs.GetTipsetByHeight(ctx, minfo.Epoch+1, curTs, false) | ||
if err != nil { | ||
return nil, nil, cid.Undef, xerrors.Errorf("error looking up execution tipset: %w", err) | ||
var xts *types.TipSet = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var xts *types.TipSet = nil | |
var xts *types.TipSet |
chain/index/interface.go
Outdated
// The lookup is done using the onchain message Cid; that is the signed message Cid | ||
// for SECP messages and unsigned message Cid for BLS messages. | ||
GetMsgInfo(ctx context.Context, m cid.Cid) (MsgInfo, error) | ||
GetMsgInfo(ctx context.Context, mCid cid.Cid) (MsgInfo, cid.Cid, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, the MsgInfo
isn't actually serialized and stored anywhere, which means we can break the shape of the struct without any migration or other problems. In that case, consider just adding the xTsCid to MsgInfo
, instead of making it a separate returned value?
This commit updates the GetMsgInfo to include the execution tipset of the message (if it exists). This allows us to call GetTipSetByCid instead of GetTipsetByHeight which should be considerably faster and help speed up both StateSearcMessage and StateWaitForMessage calls.
61ca075
to
11ef044
Compare
11ef044
to
7b8c285
Compare
@arajasek Probably with the recent improvement in As I understand the skiplist implementation the worst case cost of Let me know if you agree to that and I'll close this PR |
@fridrik01 I think I agree with you -- let's close this PR for now, we can come back to it if necessary! |
Related Issues
#10589
Proposed Changes
This PR updates the
GetMsgInfo
to include the execution tipset of the message (if it exists). This allows us to callGetTipSetByCid
instead ofGetTipsetByHeight
which should be considerably faster and help speed up bothStateSearcMessage
andStateWaitForMessage
calls.Additional Info
GetMsgInfo
have this feature disable behind a context option?Test plan
Test functionality
Start lotus node using calibration net
Printed out some messages in sqlite/messageindx.db
Picked
bafy2bzaceaxefz7474lvmgnsr26fr3g27knqda6dnbdospx7jxekdhyqn5kms
since it has a entry with epoch+1 and called the RPC endpoint:Observed (using debug logs not part of this PR) that we found the execution tipset in the message index and called
GetTipSetByCid
instead ofGetTipsetByHeight
insidesearchForIndexedMsg
.test we are using sqlite index on epoch column
Also confirmed that sqlite uses the newly created index when executing the
dbqGetTipsetInfo
prepared statement:Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps