mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-21 17:01:35 +00:00
rpc: unsafe_write_heap_profile
This commit is contained in:
@ -36,7 +36,7 @@ func UnsafeSetConfig(typ, key, value string) (*ctypes.ResultUnsafeSetConfig, err
|
|||||||
|
|
||||||
var profFile *os.File
|
var profFile *os.File
|
||||||
|
|
||||||
func UnsafeStartCPUProfiler(filename string) (*ctypes.ResultUnsafeCPUProfiler, error) {
|
func UnsafeStartCPUProfiler(filename string) (*ctypes.ResultUnsafeProfile, error) {
|
||||||
var err error
|
var err error
|
||||||
profFile, err = os.Create(filename)
|
profFile, err = os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -46,11 +46,22 @@ func UnsafeStartCPUProfiler(filename string) (*ctypes.ResultUnsafeCPUProfiler, e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ctypes.ResultUnsafeCPUProfiler{}, nil
|
return &ctypes.ResultUnsafeProfile{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnsafeStopCPUProfiler() (*ctypes.ResultUnsafeCPUProfiler, error) {
|
func UnsafeStopCPUProfiler() (*ctypes.ResultUnsafeProfile, error) {
|
||||||
pprof.StopCPUProfile()
|
pprof.StopCPUProfile()
|
||||||
profFile.Close()
|
profFile.Close()
|
||||||
return &ctypes.ResultUnsafeCPUProfiler{}, nil
|
return &ctypes.ResultUnsafeProfile{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func UnsafeWriteHeapProfile(filename string) (*ctypes.ResultUnsafeProfile, error) {
|
||||||
|
memProfFile, err := os.Create(filename)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pprof.WriteHeapProfile(memProfFile)
|
||||||
|
memProfFile.Close()
|
||||||
|
|
||||||
|
return &ctypes.ResultUnsafeProfile{}, nil
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ var Routes = map[string]*rpc.RPCFunc{
|
|||||||
"unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"),
|
"unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"),
|
||||||
"unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfilerResult, "filename"),
|
"unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfilerResult, "filename"),
|
||||||
"unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfilerResult, ""),
|
"unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfilerResult, ""),
|
||||||
|
"unsafe_write_heap_profile": rpc.NewRPCFunc(UnsafeWriteHeapProfileResult, "filename"),
|
||||||
}
|
}
|
||||||
|
|
||||||
func SubscribeResult(wsCtx rpctypes.WSRPCContext, event string) (ctypes.TMResult, error) {
|
func SubscribeResult(wsCtx rpctypes.WSRPCContext, event string) (ctypes.TMResult, error) {
|
||||||
@ -164,3 +165,11 @@ func UnsafeStopCPUProfilerResult() (ctypes.TMResult, error) {
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UnsafeWriteHeapProfileResult(filename string) (ctypes.TMResult, error) {
|
||||||
|
if r, err := UnsafeWriteHeapProfile(filename); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -70,7 +70,7 @@ type ResultUnconfirmedTxs struct {
|
|||||||
|
|
||||||
type ResultUnsafeSetConfig struct{}
|
type ResultUnsafeSetConfig struct{}
|
||||||
|
|
||||||
type ResultUnsafeCPUProfiler struct{}
|
type ResultUnsafeProfile struct{}
|
||||||
|
|
||||||
type ResultSubscribe struct {
|
type ResultSubscribe struct {
|
||||||
}
|
}
|
||||||
@ -114,6 +114,7 @@ const (
|
|||||||
ResultTypeUnsafeSetConfig = byte(0xa0)
|
ResultTypeUnsafeSetConfig = byte(0xa0)
|
||||||
ResultTypeUnsafeStartCPUProfiler = byte(0xa1)
|
ResultTypeUnsafeStartCPUProfiler = byte(0xa1)
|
||||||
ResultTypeUnsafeStopCPUProfiler = byte(0xa2)
|
ResultTypeUnsafeStopCPUProfiler = byte(0xa2)
|
||||||
|
ResultTypeUnsafeWriteHeapProfile = byte(0xa3)
|
||||||
)
|
)
|
||||||
|
|
||||||
type TMResult interface {
|
type TMResult interface {
|
||||||
@ -137,6 +138,7 @@ var _ = wire.RegisterInterface(
|
|||||||
wire.ConcreteType{&ResultUnsubscribe{}, ResultTypeUnsubscribe},
|
wire.ConcreteType{&ResultUnsubscribe{}, ResultTypeUnsubscribe},
|
||||||
wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
|
wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
|
||||||
wire.ConcreteType{&ResultUnsafeSetConfig{}, ResultTypeUnsafeSetConfig},
|
wire.ConcreteType{&ResultUnsafeSetConfig{}, ResultTypeUnsafeSetConfig},
|
||||||
wire.ConcreteType{&ResultUnsafeCPUProfiler{}, ResultTypeUnsafeStartCPUProfiler},
|
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeStartCPUProfiler},
|
||||||
wire.ConcreteType{&ResultUnsafeCPUProfiler{}, ResultTypeUnsafeStopCPUProfiler},
|
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeStopCPUProfiler},
|
||||||
|
wire.ConcreteType{&ResultUnsafeProfile{}, ResultTypeUnsafeWriteHeapProfile},
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user