Skip to content

Commit

Permalink
[SYSINFRA-1673] reduce reflow cpu usage in scheduler.run (grailbio/gr…
Browse files Browse the repository at this point in the history
…ail!902)

reduce reflow cpu/mem usage

Various changes to reduce reflow cpu/mem usage:
- Use a higher (`50`) than default (`2`) number of idle conns per reflowlet.
- Make sure to close `http` calls to release connections
- Don't update status in `repository/manager` for non-console
  use-cases (eg: `pi-evaluator`), and don't set a default status.

Co-authored-by:
Approved-by: Approved-by: Jim Clune <jclune@grailbio.com>

GitLab URL: https://gitlab.com/grailbio/grail/-/merge_requests/902

fbshipit-source-id: 4af52c5
  • Loading branch information
swami-m authored and jclune committed Jun 7, 2022
1 parent 8c9c2b1 commit 0080661
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pool/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ func (o *clientExec) RemoteLogs(ctx context.Context, stdout bool) (reflow.Remote
which = "stdoutloc"
}
call, code, err := o.makeLogsCall(ctx, which, false)
defer func() { _ = call.Close() }()
if err != nil {
return reflow.RemoteLogs{}, errors.E("logslocation", o.URI(), which, err)
}
defer func() { _ = call.Close() }()
if code != http.StatusOK {
return reflow.RemoteLogs{}, call.Error()
}
Expand Down
4 changes: 2 additions & 2 deletions pool/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ func (n execNode) logNode(loc, stdout, stderr bool, follow string) rest.Node {
call.Error(err)
return
}
defer func() { _ = rc.Close() }()
_, err = io.Copy(&rest.StreamingCall{Call: call}, rc)
if err != nil {
call.Error(err)
return
}
rc.Close()
call.Write(http.StatusOK, bytes.NewReader(nil))
_ = call.Write(http.StatusOK, bytes.NewReader(nil))
})
}

Expand Down
4 changes: 4 additions & 0 deletions repository/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ func (m *Manager) transfer(ctx context.Context, dst, src reflow.Repository, file
}

func (m *Manager) updateStats(src, dst reflow.Repository, status transferStatus, stat stat) {
// If there's no status object to report to, then don't bother with updating stats.
if m.Status == nil {
return
}
k := key(src) + key(dst)
m.mu.Lock()
t := m.tasks[k]
Expand Down
3 changes: 1 addition & 2 deletions runtime/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strings"

"github.com/grailbio/base/status"
"github.com/grailbio/infra"
"github.com/grailbio/reflow"
"github.com/grailbio/reflow/errors"
Expand Down Expand Up @@ -46,7 +45,7 @@ func newScheduler(config infra.Config, logger *log.Logger) (*sched.Scheduler, er
return nil, err
}
transferer := &repository.Manager{
Status: new(status.Status).Group("transfers"),
Status: nil,
PendingTransfers: repository.NewLimits(limit),
Stat: repository.NewLimits(statLimit),
Log: logger,
Expand Down

0 comments on commit 0080661

Please sign in to comment.