mirror of https://github.com/tidwall/tile38.git
removed diag
This commit is contained in:
parent
b6884fce63
commit
e167e88e8f
|
@ -136,22 +136,10 @@ func (server *Server) flushAOF(sync bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type writeAOFDetails struct {
|
|
||||||
appendBufferElapsed time.Duration
|
|
||||||
notifyLiveElapsed time.Duration
|
|
||||||
geofencesElapsed time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
func (server *Server) writeAOF(args []string, d *commandDetails) error {
|
func (server *Server) writeAOF(args []string, d *commandDetails) error {
|
||||||
_, err := server.writeAOFDetails(args, d)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (server *Server) writeAOFDetails(args []string, d *commandDetails) (details writeAOFDetails, err error) {
|
|
||||||
|
|
||||||
if d != nil && !d.updated {
|
if d != nil && !d.updated {
|
||||||
// just ignore writes if the command did not update
|
// just ignore writes if the command did not update
|
||||||
return details, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.shrinking {
|
if server.shrinking {
|
||||||
|
@ -161,7 +149,6 @@ func (server *Server) writeAOFDetails(args []string, d *commandDetails) (details
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.aof != nil {
|
if server.aof != nil {
|
||||||
start := time.Now()
|
|
||||||
atomic.StoreInt32(&server.aofdirty, 1) // prewrite optimization flag
|
atomic.StoreInt32(&server.aofdirty, 1) // prewrite optimization flag
|
||||||
n := len(server.aofbuf)
|
n := len(server.aofbuf)
|
||||||
server.aofbuf = redcon.AppendArray(server.aofbuf, len(args))
|
server.aofbuf = redcon.AppendArray(server.aofbuf, len(args))
|
||||||
|
@ -169,21 +156,14 @@ func (server *Server) writeAOFDetails(args []string, d *commandDetails) (details
|
||||||
server.aofbuf = redcon.AppendBulkString(server.aofbuf, arg)
|
server.aofbuf = redcon.AppendBulkString(server.aofbuf, arg)
|
||||||
}
|
}
|
||||||
server.aofsz += len(server.aofbuf) - n
|
server.aofsz += len(server.aofbuf) - n
|
||||||
details.appendBufferElapsed = time.Since(start)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify aof live connections that we have new data
|
// notify aof live connections that we have new data
|
||||||
start := time.Now()
|
|
||||||
server.fcond.L.Lock()
|
server.fcond.L.Lock()
|
||||||
server.fcond.Broadcast()
|
server.fcond.Broadcast()
|
||||||
server.fcond.L.Unlock()
|
server.fcond.L.Unlock()
|
||||||
details.notifyLiveElapsed = time.Since(start)
|
|
||||||
|
|
||||||
// process geofences
|
// process geofences
|
||||||
start = time.Now()
|
|
||||||
defer func() {
|
|
||||||
details.geofencesElapsed = time.Since(start)
|
|
||||||
}()
|
|
||||||
if d != nil {
|
if d != nil {
|
||||||
// webhook geofences
|
// webhook geofences
|
||||||
if server.config.followHost() == "" {
|
if server.config.followHost() == "" {
|
||||||
|
@ -192,13 +172,13 @@ func (server *Server) writeAOFDetails(args []string, d *commandDetails) (details
|
||||||
// queue children
|
// queue children
|
||||||
for _, d := range d.children {
|
for _, d := range d.children {
|
||||||
if err := server.queueHooks(d); err != nil {
|
if err := server.queueHooks(d); err != nil {
|
||||||
return details, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// queue parent
|
// queue parent
|
||||||
if err := server.queueHooks(d); err != nil {
|
if err := server.queueHooks(d); err != nil {
|
||||||
return details, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +199,7 @@ func (server *Server) writeAOFDetails(args []string, d *commandDetails) (details
|
||||||
}
|
}
|
||||||
server.lcond.L.Unlock()
|
server.lcond.L.Unlock()
|
||||||
}
|
}
|
||||||
return details, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
func (server *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
||||||
|
|
|
@ -75,30 +75,18 @@ func (c *Server) cmdMassInsert(msg *Message) (res resp.Value, err error) {
|
||||||
return NOMessage, errInvalidArgument(snumPoints)
|
return NOMessage, errInvalidArgument(snumPoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
type docmdDetails struct {
|
docmd := func(args []string) error {
|
||||||
writeAOFDetails writeAOFDetails
|
|
||||||
cmdElapsed time.Duration
|
|
||||||
aofElapsed time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
docmd := func(args []string) (docmdDetails docmdDetails, err error) {
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
var nmsg Message
|
var nmsg Message
|
||||||
nmsg = *msg
|
nmsg = *msg
|
||||||
nmsg._command = ""
|
nmsg._command = ""
|
||||||
nmsg.Args = args
|
nmsg.Args = args
|
||||||
var d commandDetails
|
_, _, err := c.command(&nmsg, nil)
|
||||||
start := time.Now()
|
|
||||||
_, d, err = c.command(&nmsg, nil)
|
|
||||||
docmdDetails.cmdElapsed = time.Since(start)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return docmdDetails, err
|
return err
|
||||||
}
|
}
|
||||||
start = time.Now()
|
return err
|
||||||
docmdDetails.writeAOFDetails, err = c.writeAOFDetails(nmsg.Args, &d)
|
|
||||||
docmdDetails.aofElapsed = time.Since(start)
|
|
||||||
return docmdDetails, err
|
|
||||||
|
|
||||||
}
|
}
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
@ -141,27 +129,11 @@ func (c *Server) cmdMassInsert(msg *Message) (res resp.Value, err error) {
|
||||||
strconv.FormatFloat(lon, 'f', -1, 64),
|
strconv.FormatFloat(lon, 'f', -1, 64),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
start := time.Now()
|
err := docmd(values)
|
||||||
docmdDetails, err := docmd(values)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
elapsed := time.Since(start)
|
|
||||||
if elapsed > time.Millisecond*5 {
|
|
||||||
log.Infof("%d"+
|
|
||||||
", %6.1f cmd, %6.1f aof"+
|
|
||||||
", %6.1f buf, %6.1f not, %6.1f fence"+
|
|
||||||
", %6.1f tot",
|
|
||||||
len(values),
|
|
||||||
docmdDetails.cmdElapsed.Seconds()*1000,
|
|
||||||
docmdDetails.aofElapsed.Seconds()*1000,
|
|
||||||
docmdDetails.writeAOFDetails.appendBufferElapsed.Seconds()*1000,
|
|
||||||
docmdDetails.writeAOFDetails.notifyLiveElapsed.Seconds()*1000,
|
|
||||||
docmdDetails.writeAOFDetails.geofencesElapsed.Seconds()*1000,
|
|
||||||
elapsed.Seconds()*1000,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
atomic.AddUint64(&k, 1)
|
atomic.AddUint64(&k, 1)
|
||||||
if j%1000 == 1000-1 {
|
if j%1000 == 1000-1 {
|
||||||
log.Debugf("mass: %s %d/%d",
|
log.Debugf("mass: %s %d/%d",
|
||||||
|
|
Loading…
Reference in New Issue