Skip to content

Commit

Permalink
Revert "Add system module for observing various information of mo" (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
sukki37 authored Sep 5, 2023
1 parent 935f677 commit 44086eb
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 301 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ require (
github.com/lni/dragonboat/v4 v4.0.0-20220815145555-6f622e8bcbef
github.com/lni/goutils v1.3.1-0.20220604063047-388d67b4dbc4
github.com/lni/vfs v0.2.1-0.20220616104132-8852fd867376
github.com/mackerelio/go-osstat v0.2.4
github.com/matrixorigin/simdcsv v0.0.0-20230210060146-09b8e45209dd
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/panjf2000/ants/v2 v2.7.4
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1423,8 +1423,6 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
Expand Down
90 changes: 0 additions & 90 deletions pkg/common/system/system.go

This file was deleted.

35 changes: 0 additions & 35 deletions pkg/common/system/system_test.go

This file was deleted.

23 changes: 0 additions & 23 deletions pkg/common/system/types.go

This file was deleted.

72 changes: 2 additions & 70 deletions pkg/sql/plan/function/func_unary.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ import (
"context"
"encoding/hex"
"fmt"
"github.com/matrixorigin/matrixone/pkg/vectorize/moarray"
"github.com/matrixorigin/matrixone/pkg/vectorize/momath"
"io"
"math"
"runtime"
"strconv"
"strings"
"time"

"github.com/matrixorigin/matrixone/pkg/common/system"
"github.com/matrixorigin/matrixone/pkg/vectorize/moarray"
"github.com/matrixorigin/matrixone/pkg/vectorize/momath"

"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/mpool"
"github.com/matrixorigin/matrixone/pkg/container/types"
Expand Down Expand Up @@ -441,71 +438,6 @@ func MoDisableMemUsageDetail(ivecs []*vector.Vector, result vector.FunctionResul
return moMemUsageCmd("disable_detail", ivecs, result, proc, length)
}

func MoMemory(ivecs []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
if len(ivecs) != 1 {
return moerr.NewInvalidInput(proc.Ctx, "no memory command name")
}
if !ivecs[0].IsConst() {
return moerr.NewInvalidInput(proc.Ctx, "mo memory can only take scalar input")
}
return opUnaryStrToFixedWithErrorCheck(ivecs, result, proc, length, func(v string) (int64, error) {
switch v {
case "go":
return int64(system.GolangMemory()), nil
case "total":
return int64(system.TotalMemory()), nil
case "available":
return int64(system.AvailableMemory()), nil
default:
return -1, moerr.NewInvalidInput(proc.Ctx, "no memory command name")
}
})
}

func MoCPU(ivecs []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
if len(ivecs) != 1 {
return moerr.NewInvalidInput(proc.Ctx, "no cpu command name")
}
if !ivecs[0].IsConst() {
return moerr.NewInvalidInput(proc.Ctx, "mo cpu can only take scalar input")
}
return opUnaryStrToFixedWithErrorCheck(ivecs, result, proc, length, func(v string) (int64, error) {
switch v {
case "goroutine":
return int64(system.GoRoutines()), nil
case "total":
return int64(system.NumCPU()), nil
case "available":
return int64(system.AvailableCPU()), nil
default:
return -1, moerr.NewInvalidInput(proc.Ctx, "no cpu command name")
}
})
}

const (
DefaultStackSize = 10 << 20 // 10MB
)

func MoCPUDump(ivecs []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int) error {
if len(ivecs) != 1 {
return moerr.NewInvalidInput(proc.Ctx, "no cpu dump command name")
}
if !ivecs[0].IsConst() {
return moerr.NewInvalidInput(proc.Ctx, "mo cpu dump can only take scalar input")
}
return opUnaryStrToBytesWithErrorCheck(ivecs, result, proc, length, func(v string) ([]byte, error) {
switch v {
case "goroutine":
buf := make([]byte, DefaultStackSize)
n := runtime.Stack(buf, true)
return buf[:n], nil
default:
return nil, moerr.NewInvalidInput(proc.Ctx, "no cpu dump command name")
}
})
}

const (
MaxAllowedValue = 8000
)
Expand Down
9 changes: 0 additions & 9 deletions pkg/sql/plan/function/function_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,6 @@ const (
COSINE_SIMILARITY
VECTOR_DIMS //VECTOR DIMENSIONS

// observation function
MO_CPU
MO_MEMORY
MO_CPU_DUMP

// FUNCTION_END_NUMBER is not a function, just a flag to record the max number of function.
// TODO: every one should put the new function id in front of this one if you want to make a new function.
FUNCTION_END_NUMBER
Expand Down Expand Up @@ -596,8 +591,4 @@ var functionIdRegister = map[string]int32{
"inner_product": INNER_PRODUCT,
"cosine_similarity": COSINE_SIMILARITY,
"vector_dims": VECTOR_DIMS,

"mo_cpu": MO_CPU,
"mo_memory": MO_MEMORY,
"mo_cpu_dump": MO_CPU_DUMP,
}
63 changes: 0 additions & 63 deletions pkg/sql/plan/function/list_builtIn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4708,69 +4708,6 @@ var supportedOthersBuiltIns = []FuncNew{
},
},
},
// function `mo_memory`
{
functionId: MO_MEMORY,
class: plan.Function_INTERNAL,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{
overloadId: 0,
volatile: true,
realTimeRelated: true,
args: []types.T{types.T_varchar},
retType: func(parameters []types.Type) types.Type {
return types.T_int64.ToType()
},
newOp: func() executeLogicOfOverload {
return MoMemory
},
},
},
},
// function `mo_cpu`
{
functionId: MO_CPU,
class: plan.Function_INTERNAL,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{
overloadId: 0,
volatile: true,
realTimeRelated: true,
args: []types.T{types.T_varchar},
retType: func(parameters []types.Type) types.Type {
return types.T_int64.ToType()
},
newOp: func() executeLogicOfOverload {
return MoCPU
},
},
},
},
// function `mo_cpu_dump`
{
functionId: MO_CPU_DUMP,
class: plan.Function_INTERNAL,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{
overloadId: 0,
volatile: true,
realTimeRelated: true,
args: []types.T{types.T_varchar},
retType: func(parameters []types.Type) types.Type {
return types.T_varchar.ToType()
},
newOp: func() executeLogicOfOverload {
return MoCPUDump
},
},
},
},

// function `mo_show_visible_bin`
{
Expand Down
6 changes: 0 additions & 6 deletions test/distributed/cases/system/system.result

This file was deleted.

2 changes: 0 additions & 2 deletions test/distributed/cases/system/system.sql

This file was deleted.

0 comments on commit 44086eb

Please sign in to comment.