feat(executor): debug log protobuf sizes only
All checks were successful
submodules sync / sync (push) Successful in 43s
build / build (push) Successful in 1m21s
build / trigger-build-image (push) Successful in 8s

This commit is contained in:
张泊明518370910136 2024-11-06 04:38:22 -05:00
parent 8bc1b8284d
commit ce794f1315
GPG Key ID: D47306D7062CDA9D
2 changed files with 20 additions and 2 deletions

2
go.mod
View File

@ -11,6 +11,7 @@ require (
github.com/mcuadros/go-defaults v1.2.0
github.com/mitchellh/mapstructure v1.5.0
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
)
require (
@ -41,7 +42,6 @@ require (
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

View File

@ -7,6 +7,7 @@ import (
"github.com/criyle/go-judge/pb"
"github.com/joint-online-judge/JOJ3/internal/stage"
"google.golang.org/protobuf/proto"
)
type Sandbox struct {
@ -37,7 +38,24 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
}
}
pbCmds := convertPBCmd(cmds)
slog.Debug("sandbox execute", "protobuf cmds", pbCmds)
for i, pbCmd := range pbCmds {
slog.Debug(
"sandbox execute",
"index", i,
"protobuf cmd size", proto.Size(pbCmd),
"protobuf cmd stdin size", proto.Size(pbCmd.Files[0]),
"protobuf cmd stdout size", proto.Size(pbCmd.Files[1]),
"protobuf cmd stderr size", proto.Size(pbCmd.Files[2]),
)
for k, v := range pbCmd.CopyIn {
slog.Debug(
"sandbox execute",
"index", i,
"CopyIn filename", k,
"protobuf file size", proto.Size(v),
)
}
}
pbReq := &pb.Request{Cmd: pbCmds}
pbRet, err := e.execClient.Exec(context.TODO(), pbReq)
if err != nil {