read conmon output and convert to json in two steps

when reading the output from conmon using the JSON methods, it appears that
JSON marshalling is higher in pprof than it really is because the pipe is
"waiting" for a response. this gives us a clearer look at the real CPU/time
consumers.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude 2018-10-23 13:19:42 -05:00
parent d043ac4de5
commit 318e33ce2c
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package libpod
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
@ -418,7 +419,12 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res
ch := make(chan syncStruct)
go func() {
var si *syncInfo
if err = json.NewDecoder(parentPipe).Decode(&si); err != nil {
rdr := bufio.NewReader(parentPipe)
b, err := rdr.ReadBytes('\n')
if err != nil {
ch <- syncStruct{err: err}
}
if err := json.Unmarshal(b, &si); err != nil {
ch <- syncStruct{err: err}
return
}