aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2018-03-03 07:52:21 +0800
committerGitHub <noreply@github.com>2018-03-03 07:52:21 +0800
commit12f4d284114a719e9a0779933e8770c352ed1767 (patch)
treec49924faee63349c5a5abda0b7bdc79408d39447 /internal
parent49bcb5fbd55e3e15c534fac13d2d65829319298a (diff)
downloaddexon-12f4d284114a719e9a0779933e8770c352ed1767.tar
dexon-12f4d284114a719e9a0779933e8770c352ed1767.tar.gz
dexon-12f4d284114a719e9a0779933e8770c352ed1767.tar.bz2
dexon-12f4d284114a719e9a0779933e8770c352ed1767.tar.lz
dexon-12f4d284114a719e9a0779933e8770c352ed1767.tar.xz
dexon-12f4d284114a719e9a0779933e8770c352ed1767.tar.zst
dexon-12f4d284114a719e9a0779933e8770c352ed1767.zip
internal/debug: add support for mutex profiles (#16230)
Diffstat (limited to 'internal')
-rw-r--r--internal/debug/api.go27
-rw-r--r--internal/web3ext/web3ext.go15
2 files changed, 38 insertions, 4 deletions
diff --git a/internal/debug/api.go b/internal/debug/api.go
index 3547b0564..048b7d763 100644
--- a/internal/debug/api.go
+++ b/internal/debug/api.go
@@ -140,10 +140,9 @@ func (h *HandlerT) GoTrace(file string, nsec uint) error {
return nil
}
-// BlockProfile turns on CPU profiling for nsec seconds and writes
-// profile data to file. It uses a profile rate of 1 for most accurate
-// information. If a different rate is desired, set the rate
-// and write the profile manually.
+// BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to
+// file. It uses a profile rate of 1 for most accurate information. If a different rate is
+// desired, set the rate and write the profile manually.
func (*HandlerT) BlockProfile(file string, nsec uint) error {
runtime.SetBlockProfileRate(1)
time.Sleep(time.Duration(nsec) * time.Second)
@@ -162,6 +161,26 @@ func (*HandlerT) WriteBlockProfile(file string) error {
return writeProfile("block", file)
}
+// MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file.
+// It uses a profile rate of 1 for most accurate information. If a different rate is
+// desired, set the rate and write the profile manually.
+func (*HandlerT) MutexProfile(file string, nsec uint) error {
+ runtime.SetMutexProfileFraction(1)
+ time.Sleep(time.Duration(nsec) * time.Second)
+ defer runtime.SetMutexProfileFraction(0)
+ return writeProfile("mutex", file)
+}
+
+// SetMutexProfileFraction sets the rate of mutex profiling.
+func (*HandlerT) SetMutexProfileFraction(rate int) {
+ runtime.SetMutexProfileFraction(rate)
+}
+
+// WriteMutexProfile writes a goroutine blocking profile to the given file.
+func (*HandlerT) WriteMutexProfile(file string) error {
+ return writeProfile("mutex", file)
+}
+
// WriteMemProfile writes an allocation profile to the given file.
// Note that the profiling rate cannot be set through the API,
// it must be set on the command line.
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index a6b81b4c2..9d6ce8c6c 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -308,6 +308,21 @@ web3._extend({
params: 1
}),
new web3._extend.Method({
+ name: 'mutexProfile',
+ call: 'debug_mutexProfile',
+ params: 2
+ }),
+ new web3._extend.Method({
+ name: 'setMutexProfileRate',
+ call: 'debug_setMutexProfileRate',
+ params: 1
+ }),
+ new web3._extend.Method({
+ name: 'writeMutexProfile',
+ call: 'debug_writeMutexProfile',
+ params: 1
+ }),
+ new web3._extend.Method({
name: 'writeMemProfile',
call: 'debug_writeMemProfile',
params: 1