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

Cache execution traces (State Compute Cache) #10504

Closed
Stebalien opened this issue Mar 17, 2023 · 0 comments
Closed

Cache execution traces (State Compute Cache) #10504

Stebalien opened this issue Mar 17, 2023 · 0 comments
Assignees
Labels
kind/enhancement Kind: Enhancement

Comments

@Stebalien
Copy link
Member

Some node operators, especially exchanges and chain explorers, heavily rely on execution traces. Ideally said operators would call StateCompute once, but this isn't always the case.

We can optimize this by caching the result of:

func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (cid.Cid, []*api.InvocResult, error) {
var invocTrace []*api.InvocResult
st, err := sm.ExecutionTraceWithMonitor(ctx, ts, &InvocationTracer{trace: &invocTrace})
if err != nil {
return cid.Undef, nil, err
}
return st, invocTrace, nil
}

Specifically, we should introduce a simple ARC cache here. It can be small (16-32), but any amount of caching here will likely improve performance. Ideally we'd have a per-tipset lock to avoid duplicating work, but that can be done in a followup if it ends up being expensive.

@Stebalien Stebalien added the kind/enhancement Kind: Enhancement label Mar 17, 2023
@jennijuju jennijuju added this to the v1.23.0 milestone Mar 17, 2023
fridrik01 added a commit that referenced this issue Mar 20, 2023
This PR adds a small cache to calls to ExecutionTrace which helps
 improve performance for node operators like exchanges and block
explorers.

If items is in cache calls to this function will be 2-3x faster.

Fixes: #10504
@maciejwitowski maciejwitowski changed the title Cache execution traces Cache execution traces (State Compute Cache) Mar 22, 2023
maciejwitowski pushed a commit that referenced this issue Mar 29, 2023
This PR adds a small cache to calls to ExecutionTrace which helps
 improve performance for node operators like exchanges and block
explorers.

If items is in cache calls to this function will be 2-3x faster.

Fixes: #10504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Kind: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants