mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
ethdb/pebble: expose stall counter of pebble
This commit is contained in:
parent
485ff4bbff
commit
122e795f93
1 changed files with 24 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -57,6 +58,7 @@ const (
|
||||||
type Database struct {
|
type Database struct {
|
||||||
fn string // filename for reporting
|
fn string // filename for reporting
|
||||||
db *pebble.DB // Underlying pebble storage engine
|
db *pebble.DB // Underlying pebble storage engine
|
||||||
|
namespace string // Namespace for metrics
|
||||||
|
|
||||||
compTimeMeter *metrics.Meter // Meter for measuring the total time spent in database compaction
|
compTimeMeter *metrics.Meter // Meter for measuring the total time spent in database compaction
|
||||||
compReadMeter *metrics.Meter // Meter for measuring the data read during compaction
|
compReadMeter *metrics.Meter // Meter for measuring the data read during compaction
|
||||||
|
|
@ -120,6 +122,10 @@ func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
|
||||||
d.writeDelayStartTime = time.Now()
|
d.writeDelayStartTime = time.Now()
|
||||||
d.writeDelayCount.Add(1)
|
d.writeDelayCount.Add(1)
|
||||||
d.writeStalled.Store(true)
|
d.writeStalled.Store(true)
|
||||||
|
|
||||||
|
stall := "stall/" + toCamelCase(b.Reason)
|
||||||
|
gauge := metrics.GetOrRegisterGauge(d.namespace+stall, nil)
|
||||||
|
gauge.Inc(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) onWriteStallEnd() {
|
func (d *Database) onWriteStallEnd() {
|
||||||
|
|
@ -669,3 +675,19 @@ func (iter *pebbleIterator) Release() {
|
||||||
iter.released = true
|
iter.released = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// toCamelCase converts string to camel case.
|
||||||
|
func toCamelCase(s string) string {
|
||||||
|
words := strings.FieldsFunc(s, func(r rune) bool {
|
||||||
|
return r == ' ' || r == '_' || r == '-' // split by space, underscore, or dash
|
||||||
|
})
|
||||||
|
for i := range words {
|
||||||
|
if i == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(words[i]) > 0 {
|
||||||
|
words[i] = strings.ToUpper(words[i][:1]) + strings.ToLower(words[i][1:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings.Join(words, "")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue