-
Notifications
You must be signed in to change notification settings - Fork 93
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 /v2/blocks high memory usage #1395
Comments
Benchmark results
|
WIP PR for the benchmarks used to generate the above #1396 |
Over the last 2 days, our memory usage has continued to increase even though the level of traffic has stayed consistent. This makes it feel like there is a memory leak. It would be useful to have a local pprof HTTP endpoint to be able to grab a dump of the heap. |
You can use the Are you saying you'd also like to be able to get a heap profile, https://pkg.go.dev/runtime/[email protected]#WriteHeapProfile at any given time via an http endpoint? Also, do you have more info on the memory usage problems you're seeing? The issues we've been investigating are related to queries using large amounts of memory when deserializing blocks from pgsql which have large numbers of inner txns. We're not currently aware of any places this would leak objects, so if you have any info on that we'd be interested to take a look. |
Yes, we are currently tracking the memory due to the /v2/blocks/ issue. Adding a runtime way to get a heap dump would allow us to see if there is any unknown issues over time. This is what the code could like to add an pprof endpoint addr := os.Getenv("DEBUG_PPROF_ADDR") //127.0.0.1:7777
if addr != "" {
go func() {
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
server := &http.Server{
Addr: addr,
Handler: mux,
}
err := server.ListenAndServe()
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Error("running pprof server failed")
}
}()
} The heap could then be retrieved with a command like this:
|
@Eric-Warehime was this fixed by the PR's above or is there still some concern in this area? |
This has been resolved by the PRs mentioned above. |
Using the
/v2/blocks
endpoint (with Indexer v2.15.0) will currently return an error when the total number of transactions in the returned block is greater than theMaxTransactionsLimit
. See here for the implementation.This becomes a problem when there are a large number of inner transactions since the returned data recursively reconstructs transactions. By that I mean that a root txn will have inner txns nested inside of it, and an inner txn will have a copy of the root txn which also has inner txns.
The result is that not only does the memory usage scale with the number of transactions in a block, but also with the number of inner transactions.
Based on benchmarking, a
MaxTransactionsLimit
of 1000 will consume ~3GB of memory if the transactions in the block each have 200 inner transactions.Desired Result:
Identify and implement a solution to limit memory consumption on blocks containing large numbers of inner transactions.
The text was updated successfully, but these errors were encountered: