Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"runtime"
"strings"
"syscall"
"time"
Expand All @@ -24,6 +25,12 @@ func IO(req *pbm.BinRequest, maxReplySize int) (*pbm.BinReply, error) {
start := time.Now()
res := pbm.BinReply{Id: req.Id, Module: req.Module, Exitcode: 0}

// measure mem alloc
var m runtime.MemStats
runtime.GC()
runtime.ReadMemStats(&m)
startAlloc := m.Alloc

l := log.WithFields(log.Fields{"rid": FmtRid(req.Id)})

done := make(chan bool, 1)
Expand Down Expand Up @@ -64,6 +71,7 @@ func IO(req *pbm.BinRequest, maxReplySize int) (*pbm.BinReply, error) {
l.WithError(err).Error("cmd.StdinPipe")
}
stdout, err := cmd.StdoutPipe()
defer stdout.Close()
if err != nil {
l.WithError(err).Error("cmd.StdoutPipe")
}
Expand Down Expand Up @@ -192,6 +200,14 @@ func IO(req *pbm.BinRequest, maxReplySize int) (*pbm.BinReply, error) {
case <-time.After(CommandTimeout + 15*time.Second):
l.Fatal("Something went terribly wrong")
}

res.Stdout = []byte{}

runtime.GC()
runtime.ReadMemStats(&m)
allocDiff := m.Alloc - startAlloc
log.WithFields(log.Fields{"# goroutines": runtime.NumGoroutine(), "alloc total": m.Alloc, "alloc diff": allocDiff}).Warn("Stats..")

return &res, nil
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
Version = "0.7.6"
Version = "0.7.7"
clientID = "babl-server"

MaxKafkaMessageSize = 1024 * 100 // 100kb
Expand Down