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

investigate performance of memory pool for coverage tracer #479

Open
0xalpharush opened this issue Sep 11, 2024 · 0 comments
Open

investigate performance of memory pool for coverage tracer #479

0xalpharush opened this issue Sep 11, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@0xalpharush
Copy link
Contributor

0xalpharush commented Sep 11, 2024

The coverage tracer currently deallocates and reallocates memory very frequently and potentially it is upwards of 24kb (the PC coverage tracker is the length of the code and EVM codesize checks are often disabled) per contract that is touched during a tx's execution. This design, in part, contributes to Medusa spending a lot of time in the GC runtime. Eliminating this overhead may increase the throughput of the fuzzer

We could explore each worker having a sync.Pool of bytes.Buffer's that are cleared and re-used, only allocating when the pool's fully used. I'm not sure if this approach would allow workers to be long-lived and not frequently restarted when the worker reset limit is reached.

func (t *CoverageTracer) OnTxStart(vm *tracing.VMContext, tx *coretypes.Transaction, from common.Address) {
// Reset our call frame states
t.callDepth = 0
t.coverageMaps = NewCoverageMaps()
t.callFrameStates = make([]*coverageTracerCallFrameState, 0)
t.evmContext = vm
}

As an aside, using edges instead of PC's may make this performance optimization necessary. That said, it may make it feasible for us to track the hit count and generate line-based reports for the full campaign even if we're only using edges to decide whether a sequence should be inserted into the corpus (see #326 (comment))

@0xalpharush 0xalpharush added the help wanted Extra attention is needed label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant