mirror of
https://gitee.com/openeuler/A-Tune.git
synced 2025-12-06 16:09:25 +08:00
add generate command, which can generate the tuning project yaml depend on rules
This commit is contained in:
2
Makefile
2
Makefile
@@ -41,6 +41,7 @@ install:
|
||||
rm -rf $(DESTDIR)/var/lib/atuned/
|
||||
rm -rf $(DESTDIR)/var/run/atuned/
|
||||
mkdir -p $(DESTDIR)/etc/atuned/tuning
|
||||
mkdir -p $(DESTDIR)/etc/atuned/rules
|
||||
mkdir -p $(DESTDIR)/etc/atuned/training
|
||||
mkdir -p $(DESTDIR)/etc/atuned/classification
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/lib/atuned/modules
|
||||
@@ -57,6 +58,7 @@ install:
|
||||
install -m 750 pkg/atuned $(BINDIR)
|
||||
install -m 640 misc/atuned.service $(SYSTEMDDIR)
|
||||
install -m 640 misc/atuned.cnf $(DESTDIR)/etc/atuned/
|
||||
install -m 640 rules/tuning/tuning_rules.grl $(DESTDIR)/etc/atuned/rules
|
||||
install -m 640 misc/atune-engine.service $(SYSTEMDDIR)
|
||||
install -m 640 database/atuned.db $(DESTDIR)/var/lib/atuned/
|
||||
install -m 640 misc/atune-adm $(DESTDIR)$(PREFIX)/share/bash-completion/completions/
|
||||
|
||||
@@ -78,6 +78,10 @@ class Collector(Resource):
|
||||
float_data.append(type_name)
|
||||
data.append(float_data)
|
||||
|
||||
data_average = [sum(elem)/len(elem) for elem in zip(*data)]
|
||||
data_result = {}
|
||||
for index, _ in enumerate(data_average):
|
||||
data_result[field_name[index]] = data_average[index]
|
||||
if n_pipe is not None:
|
||||
n_pipe.close()
|
||||
|
||||
@@ -85,6 +89,7 @@ class Collector(Resource):
|
||||
save_file(path, data, field_name)
|
||||
result = {}
|
||||
result["path"] = path
|
||||
result["data"] = data_result
|
||||
return result, 200
|
||||
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
math "math"
|
||||
)
|
||||
|
||||
@@ -590,51 +588,52 @@ func init() {
|
||||
func init() { proto.RegisterFile("profile.proto", fileDescriptor_744bf7a47b381504) }
|
||||
|
||||
var fileDescriptor_744bf7a47b381504 = []byte{
|
||||
// 702 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5d, 0x4f, 0xdb, 0x3c,
|
||||
0x14, 0x26, 0x29, 0xb4, 0xe5, 0xb4, 0x50, 0x5e, 0x8b, 0x17, 0x45, 0x68, 0x9b, 0x50, 0xae, 0xb8,
|
||||
0x42, 0x68, 0x93, 0xf6, 0xa1, 0x0a, 0xa6, 0xac, 0x68, 0x52, 0x27, 0x60, 0xa8, 0x2d, 0x1a, 0xb7,
|
||||
0x26, 0x31, 0xa9, 0x15, 0x37, 0x8e, 0x1c, 0x97, 0x89, 0xfd, 0x93, 0xfd, 0x9b, 0xdd, 0xec, 0x7f,
|
||||
0x4d, 0x76, 0xec, 0x34, 0xad, 0xda, 0x69, 0xf4, 0x2e, 0xcf, 0xe3, 0xf3, 0x1c, 0x1f, 0x9f, 0xaf,
|
||||
0xc0, 0x4e, 0x26, 0xf8, 0x03, 0x65, 0xe4, 0x24, 0x13, 0x5c, 0x72, 0xd4, 0x30, 0xd0, 0x9f, 0x40,
|
||||
0xeb, 0x92, 0xe6, 0xf2, 0x8a, 0xe4, 0x39, 0x8e, 0x09, 0xf2, 0xa1, 0xfd, 0x8d, 0x8b, 0x84, 0x71,
|
||||
0x1c, 0x8d, 0x9e, 0x32, 0xe2, 0x39, 0x47, 0xce, 0xf1, 0xf6, 0x60, 0x8e, 0x53, 0x36, 0x37, 0x85,
|
||||
0xfa, 0x1a, 0x4f, 0x48, 0xee, 0xb9, 0x85, 0x4d, 0x95, 0x43, 0x07, 0x50, 0x0f, 0x42, 0x49, 0x1f,
|
||||
0x89, 0x57, 0xd3, 0xa7, 0x06, 0xf9, 0x5d, 0x68, 0x19, 0xbb, 0x7e, 0xfa, 0xc0, 0x11, 0x82, 0x4d,
|
||||
0x65, 0x6f, 0xae, 0xd1, 0xdf, 0xc8, 0x83, 0x46, 0x8f, 0xa7, 0x92, 0xa4, 0x52, 0x7b, 0x6e, 0x0f,
|
||||
0x2c, 0xf4, 0xbb, 0xd0, 0x09, 0x52, 0xcc, 0x9e, 0x72, 0x9a, 0xdb, 0x78, 0x97, 0x39, 0xd8, 0x87,
|
||||
0xad, 0x2b, 0x1e, 0x11, 0x66, 0x02, 0x2b, 0x80, 0xff, 0x12, 0x6a, 0x41, 0x98, 0xa8, 0xc0, 0x86,
|
||||
0x12, 0xcb, 0x69, 0x6e, 0x24, 0x06, 0xf9, 0x77, 0xd0, 0x0c, 0xc2, 0xa4, 0x37, 0x26, 0x61, 0xb2,
|
||||
0xd4, 0xe9, 0x4c, 0xe7, 0x56, 0x75, 0xe8, 0x08, 0x5a, 0x17, 0x24, 0x0f, 0x05, 0xcd, 0x24, 0xe5,
|
||||
0xa9, 0x79, 0x6d, 0x95, 0xf2, 0xef, 0x00, 0xcc, 0x93, 0x2f, 0x79, 0x8c, 0x76, 0xc1, 0xed, 0x47,
|
||||
0xda, 0x73, 0x6d, 0xe0, 0xf6, 0x23, 0xf4, 0x02, 0xb6, 0x6d, 0x42, 0x22, 0xe3, 0x7a, 0x46, 0xa8,
|
||||
0xd3, 0x11, 0x9d, 0x90, 0x5c, 0xe2, 0x49, 0x66, 0x7c, 0xcf, 0x08, 0xff, 0xb7, 0x03, 0xad, 0x1e,
|
||||
0x67, 0x8c, 0x84, 0xf2, 0x33, 0xc3, 0x31, 0x3a, 0x84, 0x66, 0x3f, 0x95, 0x44, 0x3c, 0x62, 0x66,
|
||||
0x6e, 0x28, 0xb1, 0x3a, 0xbb, 0x98, 0x0a, 0xac, 0x83, 0x74, 0x8b, 0x33, 0x8b, 0xd5, 0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b, 0xc4, 0xfe, 0x36, 0x8b, 0xf0, 0x3f, 0xdb, 0x77,
|
||||
0xa1, 0x69, 0x47, 0xbb, 0xd2, 0xfd, 0x0b, 0xd3, 0xbe, 0xe2, 0x39, 0xf7, 0x75, 0xfd, 0x4f, 0x7e,
|
||||
0xf3, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x88, 0xa1, 0x70, 0xa4, 0x07, 0x00, 0x00,
|
||||
// 711 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x5f, 0x4f, 0xdb, 0x30,
|
||||
0x10, 0x27, 0x29, 0xb4, 0xe5, 0x5a, 0x28, 0xb3, 0x18, 0x8a, 0xd0, 0x36, 0xa1, 0x3c, 0xf1, 0x84,
|
||||
0xd0, 0x26, 0xed, 0x8f, 0x2a, 0x98, 0xb2, 0xa2, 0x4d, 0x9d, 0x80, 0xa1, 0xb6, 0x68, 0xbc, 0x9a,
|
||||
0xc4, 0xa4, 0x56, 0xdc, 0x38, 0x72, 0x5c, 0x26, 0xf6, 0x4d, 0xf6, 0x81, 0xf6, 0xa1, 0xf6, 0x36,
|
||||
0xd9, 0xb1, 0xd3, 0xb4, 0x6a, 0xa7, 0xc1, 0x5b, 0x7e, 0x77, 0xf7, 0xbb, 0x3b, 0xdf, 0xbf, 0xc0,
|
||||
0x56, 0x26, 0xf8, 0x1d, 0x65, 0xe4, 0x28, 0x13, 0x5c, 0x72, 0xd4, 0x30, 0xd0, 0x9f, 0x40, 0xeb,
|
||||
0x9c, 0xe6, 0xf2, 0x82, 0xe4, 0x39, 0x8e, 0x09, 0xf2, 0xa1, 0xfd, 0x9d, 0x8b, 0x84, 0x71, 0x1c,
|
||||
0x8d, 0x1e, 0x32, 0xe2, 0x39, 0x07, 0xce, 0xe1, 0xe6, 0x60, 0x4e, 0xa6, 0x6c, 0xae, 0x0a, 0xf6,
|
||||
0x25, 0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|
||||
0x50, 0x62, 0xa5, 0x3b, 0x9b, 0x0a, 0xac, 0x93, 0x74, 0x0b, 0x9d, 0xc5, 0x4a, 0x67, 0x1b, 0x6c,
|
||||
0x82, 0x94, 0x18, 0xbd, 0x02, 0xf8, 0x36, 0x95, 0xd9, 0x54, 0x5e, 0x61, 0x39, 0xf6, 0xd6, 0xb5,
|
||||
0xb6, 0x22, 0x51, 0xc5, 0xfe, 0xc4, 0x78, 0x98, 0x78, 0x1b, 0x45, 0xb1, 0x35, 0x50, 0x3d, 0xbc,
|
||||
0x24, 0xf2, 0x07, 0x17, 0x89, 0x57, 0xd7, 0x72, 0x0b, 0x55, 0x6d, 0xf5, 0x60, 0x35, 0x8a, 0xda,
|
||||
0xaa, 0x6f, 0xff, 0x2b, 0xb4, 0x47, 0x02, 0xd3, 0xd4, 0x36, 0x55, 0xe5, 0x8a, 0x25, 0xd6, 0x11,
|
||||
0x8b, 0x1e, 0x94, 0x78, 0x21, 0x1f, 0x77, 0x31, 0x1f, 0xff, 0x97, 0x03, 0x5b, 0x67, 0xe4, 0x8e,
|
||||
0xa6, 0xc4, 0x7a, 0x3b, 0x80, 0xd6, 0x90, 0x88, 0x7b, 0x1a, 0x92, 0xca, 0x44, 0x57, 0x45, 0xe8,
|
||||
0x10, 0x3a, 0x41, 0x96, 0x31, 0x1a, 0xea, 0x72, 0xe8, 0xd6, 0x17, 0x8e, 0x17, 0xc5, 0x6a, 0xf4,
|
||||
0x87, 0x21, 0x49, 0xb1, 0xa0, 0x5c, 0x9b, 0x15, 0xd5, 0x9a, 0x93, 0x55, 0xe7, 0x77, 0x7d, 0x7e,
|
||||
0x7e, 0x87, 0xd0, 0x19, 0x86, 0x63, 0x12, 0x4d, 0x59, 0x99, 0xdc, 0x0e, 0xd4, 0x82, 0x2c, 0x33,
|
||||
0x49, 0xa9, 0xcf, 0xb2, 0x40, 0xee, 0xac, 0x40, 0xaa, 0x20, 0x43, 0x29, 0xb0, 0x24, 0xf1, 0x83,
|
||||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xf4, 0xd7, 0xd0,
|
||||
0x91, 0x62, 0x30, 0x22, 0x57, 0x55, 0x77, 0x89, 0xfd, 0x75, 0x16, 0xe1, 0xff, 0xb6, 0xef, 0x42,
|
||||
0xd3, 0xae, 0x76, 0x65, 0xfa, 0x17, 0xb6, 0x7d, 0xf5, 0xf4, 0x37, 0xbf, 0x90, 0x94, 0x88, 0xd5,
|
||||
0xe1, 0x96, 0x13, 0x6f, 0xeb, 0xfa, 0x67, 0xfe, 0xe6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0,
|
||||
0x92, 0xa6, 0x6c, 0xdd, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -665,6 +664,7 @@ type ProfileMgrClient interface {
|
||||
Delete(ctx context.Context, in *ProfileInfo, opts ...grpc.CallOption) (*Ack, error)
|
||||
Update(ctx context.Context, in *ProfileInfo, opts ...grpc.CallOption) (*Ack, error)
|
||||
Schedule(ctx context.Context, in *ScheduleMessage, opts ...grpc.CallOption) (ProfileMgr_ScheduleClient, error)
|
||||
Generate(ctx context.Context, in *ProfileInfo, opts ...grpc.CallOption) (ProfileMgr_GenerateClient, error)
|
||||
}
|
||||
|
||||
type profileMgrClient struct {
|
||||
@@ -1117,6 +1117,38 @@ func (x *profileMgrScheduleClient) Recv() (*AckCheck, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *profileMgrClient) Generate(ctx context.Context, in *ProfileInfo, opts ...grpc.CallOption) (ProfileMgr_GenerateClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &_ProfileMgr_serviceDesc.Streams[13], "/profile.ProfileMgr/Generate", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &profileMgrGenerateClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ProfileMgr_GenerateClient interface {
|
||||
Recv() (*AckCheck, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type profileMgrGenerateClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *profileMgrGenerateClient) Recv() (*AckCheck, error) {
|
||||
m := new(AckCheck)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ProfileMgrServer is the server API for ProfileMgr service.
|
||||
type ProfileMgrServer interface {
|
||||
Profile(*ProfileInfo, ProfileMgr_ProfileServer) error
|
||||
@@ -1135,59 +1167,7 @@ type ProfileMgrServer interface {
|
||||
Delete(context.Context, *ProfileInfo) (*Ack, error)
|
||||
Update(context.Context, *ProfileInfo) (*Ack, error)
|
||||
Schedule(*ScheduleMessage, ProfileMgr_ScheduleServer) error
|
||||
}
|
||||
|
||||
// UnimplementedProfileMgrServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedProfileMgrServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedProfileMgrServer) Profile(req *ProfileInfo, srv ProfileMgr_ProfileServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Profile not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) CheckInitProfile(req *ProfileInfo, srv ProfileMgr_CheckInitProfileServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method CheckInitProfile not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Analysis(req *AnalysisMessage, srv ProfileMgr_AnalysisServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Analysis not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Tuning(srv ProfileMgr_TuningServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Tuning not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) ListWorkload(req *ProfileInfo, srv ProfileMgr_ListWorkloadServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ListWorkload not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) UpgradeProfile(req *ProfileInfo, srv ProfileMgr_UpgradeProfileServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method UpgradeProfile not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) InfoProfile(req *ProfileInfo, srv ProfileMgr_InfoProfileServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method InfoProfile not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) CheckActiveProfile(req *ProfileInfo, srv ProfileMgr_CheckActiveProfileServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method CheckActiveProfile not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) ProfileRollback(req *ProfileInfo, srv ProfileMgr_ProfileRollbackServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ProfileRollback not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Charaterization(req *ProfileInfo, srv ProfileMgr_CharaterizationServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Charaterization not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Collection(req *CollectFlag, srv ProfileMgr_CollectionServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Collection not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Training(req *TrainMessage, srv ProfileMgr_TrainingServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Training not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Define(ctx context.Context, req *DefineMessage) (*Ack, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Define not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Delete(ctx context.Context, req *ProfileInfo) (*Ack, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Update(ctx context.Context, req *ProfileInfo) (*Ack, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
|
||||
}
|
||||
func (*UnimplementedProfileMgrServer) Schedule(req *ScheduleMessage, srv ProfileMgr_ScheduleServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Schedule not implemented")
|
||||
Generate(*ProfileInfo, ProfileMgr_GenerateServer) error
|
||||
}
|
||||
|
||||
func RegisterProfileMgrServer(s *grpc.Server, srv ProfileMgrServer) {
|
||||
@@ -1526,6 +1506,27 @@ func (x *profileMgrScheduleServer) Send(m *AckCheck) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _ProfileMgr_Generate_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(ProfileInfo)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(ProfileMgrServer).Generate(m, &profileMgrGenerateServer{stream})
|
||||
}
|
||||
|
||||
type ProfileMgr_GenerateServer interface {
|
||||
Send(*AckCheck) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type profileMgrGenerateServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *profileMgrGenerateServer) Send(m *AckCheck) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
var _ProfileMgr_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "profile.ProfileMgr",
|
||||
HandlerType: (*ProfileMgrServer)(nil),
|
||||
@@ -1610,6 +1611,11 @@ var _ProfileMgr_serviceDesc = grpc.ServiceDesc{
|
||||
Handler: _ProfileMgr_Schedule_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "Generate",
|
||||
Handler: _ProfileMgr_Generate_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "profile.proto",
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ service ProfileMgr {
|
||||
rpc Delete(ProfileInfo) returns (Ack) {}
|
||||
rpc Update(ProfileInfo) returns (Ack) {}
|
||||
rpc Schedule(ScheduleMessage) returns (stream AckCheck) {}
|
||||
rpc Generate(ProfileInfo) returns (stream AckCheck) {}
|
||||
}
|
||||
|
||||
message ListMessage {
|
||||
|
||||
@@ -44,6 +44,7 @@ const (
|
||||
DefaultProfilePath = DefaultPath + "profiles"
|
||||
DefaultConfPath = "/etc/atuned/"
|
||||
DefaultTuningPath = DefaultConfPath + "tuning/"
|
||||
DefaultRulePath = DefaultConfPath + "rules/"
|
||||
DefaultScriptPath = "/usr/libexec/atuned/scripts"
|
||||
DefaultCollectorPath = "/usr/libexec/atuned/collector"
|
||||
DefaultAnalysisPath = "/usr/libexec/atuned/analysis"
|
||||
@@ -90,6 +91,7 @@ const (
|
||||
//tuning config
|
||||
const (
|
||||
TuningFile string = DefaultTempPath + "/tuning.log"
|
||||
TuningRuleFile string = "tuning_rules.grl"
|
||||
TuningRestoreConfig string = "-tuning-restore.conf"
|
||||
DefaultTimeFormat string = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
package tuning
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitee.com/openeuler/A-Tune/common/config"
|
||||
"gitee.com/openeuler/A-Tune/common/http"
|
||||
"gitee.com/openeuler/A-Tune/common/log"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
|
||||
207
common/tuning/tuning_rules.go
Normal file
207
common/tuning/tuning_rules.go
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Huawei Technologies Co., Ltd.
|
||||
* A-Tune is licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
* Create: 2020-07-23
|
||||
*/
|
||||
|
||||
package tuning
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
PB "gitee.com/openeuler/A-Tune/api/profile"
|
||||
"gitee.com/openeuler/A-Tune/common/config"
|
||||
"gitee.com/openeuler/A-Tune/common/log"
|
||||
"gitee.com/openeuler/A-Tune/common/project"
|
||||
"gitee.com/openeuler/A-Tune/common/utils"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/newm4n/grool/builder"
|
||||
gContext "github.com/newm4n/grool/context"
|
||||
"github.com/newm4n/grool/engine"
|
||||
"github.com/newm4n/grool/model"
|
||||
"github.com/newm4n/grool/pkg"
|
||||
)
|
||||
|
||||
// TuningData : the struct which store the collection data
|
||||
type TuningData struct {
|
||||
CacheMissRatio float64 `mapstructure:"PERF.STAT.CACHE-MISS-RATIO"`
|
||||
DtlbLoadMissRatio float64 `mapstructure:"PERF.STAT.DTLB-LOAD-MISS-RATIO"`
|
||||
Ipc float64 `mapstructure:"PERF.STAT.IPC"`
|
||||
ItlbLoadMissRatio float64 `mapstructure:"PERF.STAT.ITLB-LOAD-MISS-RATIO"`
|
||||
Migrations float64 `mapstructure:"PERF.STAT.migrations"`
|
||||
MemoryBound float64 `mapstructure:"MEMORY-BOUND"`
|
||||
Mpki float64 `mapstructure:"PERF.STAT.MPKI"`
|
||||
Sbpc float64 `mapstructure:"PERF.STAT.SBPC"`
|
||||
Sbpi float64 `mapstructure:"PERF.STAT.SBPI"`
|
||||
StorageUtil float64 `mapstructure:"STORAGE.STAT.util"`
|
||||
TotalUtil float64 `mapstructure:"MEM.BANDWIDTH.Total_Util"`
|
||||
AquSz float64 `mapstructure:"STORAGE.STAT.aqu-sz"`
|
||||
Cswchs float64 `mapstructure:"SYS.TASKS.cswchs"`
|
||||
Cutil float64 `mapstructure:"CPU.STAT.cutil"`
|
||||
Errs float64 `mapstructure:"NET.STAT.errs"`
|
||||
Ifutil float64 `mapstructure:"NET.STAT.ifutil"`
|
||||
IoBi float64 `mapstructure:"MEM.VMSTAT.io.bi"`
|
||||
IoBo float64 `mapstructure:"MEM.VMSTAT.io.bo"`
|
||||
Iowait float64 `mapstructure:"CPU.STAT.iowait"`
|
||||
Irq float64 `mapstructure:"CPU.STAT.irq"`
|
||||
Ldavg1 float64 `mapstructure:"SYS.LDAVG.ldavg-1"`
|
||||
Ldavg5 float64 `mapstructure:"SYS.LDAVG.ldavg-5"`
|
||||
MemorySwpt float64 `mapstructure:"MEM.VMSTAT.memory.swpt"`
|
||||
Nice float64 `mapstructure:"CPU.STAT.nice"`
|
||||
PlistSz float64 `mapstructure:"SYS.LDAVG.plist-sz"`
|
||||
Procs float64 `mapstructure:"SYS.TASKS.procs"`
|
||||
ProcsB float64 `mapstructure:"MEM.VMSTAT.procs.b"`
|
||||
ProcsR float64 `mapstructure:"MEM.STAT.procs.r"`
|
||||
RMbs float64 `mapstructure:"STORAGE.STAT.rMBs"`
|
||||
WMbs float64 `mapstructure:"STORAGE.STAT.wMBs"`
|
||||
RAwait float64 `mapstructure:"STORAGE.STAT.r_await"`
|
||||
WAwait float64 `mapstructure:"STORAGE.STAT.w_await"`
|
||||
RareqSz float64 `mapstructure:"STORAGE.STAT.rareq-sz"`
|
||||
WareqSz float64 `mapstructure:"STORAGE.STAT.wareq-sz"`
|
||||
Rrqm float64 `mapstructure:"STORAGE.STAT.rrqm"`
|
||||
Wrqm float64 `mapstructure:"STORAGE.STAT.wrqm"`
|
||||
Rs float64 `mapstructure:"STORAGE.STAT.rs"`
|
||||
Ws float64 `mapstructure:"STORAGE.STAT.ws"`
|
||||
RunqSz float64 `mapstructure:"SYS.LDAVG.runq-sz"`
|
||||
RxKbs float64 `mapstructure:"NET.STAT.rxkBs"`
|
||||
RxPcks float64 `mapstructure:"NET.STAT.rxpcks"`
|
||||
TxKbs float64 `mapstructure:"NET.STAT.txkBs"`
|
||||
TxPcks float64 `mapstructure:"NET.STAT.txpcks"`
|
||||
Soft float64 `mapstructure:"CPU.STAT.soft"`
|
||||
Steal float64 `mapstructure:"CPU.STAT.steal"`
|
||||
Sys float64 `mapstructure:"CPU.STAT.sys"`
|
||||
SystemCs float64 `mapstructure:"MEM.VMSTAT.system.cs"`
|
||||
SystemIn float64 `mapstructure:"MEM.VMSTAT.system.in"`
|
||||
User float64 `mapstructure:"CPU.STAT.usr"`
|
||||
Util float64 `mapstructure:"CPU.STAT.util"`
|
||||
UtilCpu float64 `mapstructure:"MEM.VMSTAT.util.cpu"`
|
||||
UtilSwap float64 `mapstructure:"MEM.VMSTAT.util.swap"`
|
||||
}
|
||||
|
||||
// TuningFile used to store the object which match the tuning rule
|
||||
type TuningFile struct {
|
||||
prjs *[]project.YamlPrjSvr `yaml:"-"`
|
||||
PrjSrv *project.YamlPrjSvr
|
||||
ch chan *PB.AckCheck
|
||||
}
|
||||
|
||||
// NewTuningFile method create a TuningFile instance
|
||||
func NewTuningFile(workloadType string, ch chan *PB.AckCheck) *TuningFile {
|
||||
tuningFile := new(TuningFile)
|
||||
tuningFile.PrjSrv = new(project.YamlPrjSvr)
|
||||
tuningFile.PrjSrv.Project = workloadType
|
||||
tuningFile.PrjSrv.Maxiterations = 20
|
||||
|
||||
prjs := make([]project.YamlPrjSvr, 0)
|
||||
tuningFile.prjs = &prjs
|
||||
tuningFile.ch = ch
|
||||
return tuningFile
|
||||
}
|
||||
|
||||
// Load method load the yaml come with the atuned
|
||||
func (t TuningFile) Load() error {
|
||||
err := filepath.Walk(config.DefaultTuningPath, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() {
|
||||
prj := new(project.YamlPrjSvr)
|
||||
if err := utils.ParseFile(path, "yaml", &prj); err != nil {
|
||||
return fmt.Errorf("load %s faild, err: %v", path, err)
|
||||
}
|
||||
log.Infof("project:%s load %s success", prj.Project, path)
|
||||
*t.prjs = append(*t.prjs, *prj)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppendObject add the tuning object which match the rules
|
||||
func (t *TuningFile) AppendObject(object string) {
|
||||
log.Infof("append %s object to dest tuning file", object)
|
||||
var exist bool = false
|
||||
for _, prj := range *t.prjs {
|
||||
for _, obj := range prj.Object {
|
||||
if obj.Name != object {
|
||||
continue
|
||||
}
|
||||
exist = true
|
||||
t.PrjSrv.Object = append(t.PrjSrv.Object, obj)
|
||||
break
|
||||
}
|
||||
if exist {
|
||||
log.Infof("find object: %s", object)
|
||||
t.ch <- &PB.AckCheck{Name: fmt.Sprintf(" appending parameter: %s", object)}
|
||||
return
|
||||
}
|
||||
}
|
||||
t.ch <- &PB.AckCheck{Name: fmt.Sprintf(" appending parameter: %s, but not founded", object)}
|
||||
}
|
||||
|
||||
// Save method save the project to file
|
||||
func (t *TuningFile) Save(dstFile string) error {
|
||||
data, err := yaml.Marshal(t.PrjSrv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("data content: %s", string(data))
|
||||
err = utils.WriteFile(dstFile, string(data), utils.FilePerm,
|
||||
os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
type RuleEngine struct {
|
||||
DataContext *gContext.DataContext
|
||||
Grool *engine.Grool
|
||||
KnowledgeBase *model.KnowledgeBase
|
||||
}
|
||||
|
||||
func NewRuleEngine(srcFile string) *RuleEngine {
|
||||
ruleEngine := new(RuleEngine)
|
||||
|
||||
ruleEngine.KnowledgeBase = model.NewKnowledgeBase()
|
||||
ruleBuilder := builder.NewRuleBuilder(ruleEngine.KnowledgeBase)
|
||||
fileRes := pkg.NewFileResource(srcFile)
|
||||
err := ruleBuilder.BuildRuleFromResource(fileRes)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
ruleEngine.DataContext = gContext.NewDataContext()
|
||||
ruleEngine.Grool = engine.NewGroolEngine()
|
||||
|
||||
return ruleEngine
|
||||
}
|
||||
|
||||
func (r *RuleEngine) AddContext(key string, obj interface{}) error {
|
||||
err := r.DataContext.Add(key, obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RuleEngine) Execute() error {
|
||||
if r.Grool == nil {
|
||||
return fmt.Errorf("grool engine is nill")
|
||||
}
|
||||
|
||||
return r.Grool.Execute(r.DataContext, r.KnowledgeBase)
|
||||
}
|
||||
3
go.mod
3
go.mod
@@ -12,10 +12,11 @@ require (
|
||||
github.com/golang/protobuf v1.3.1
|
||||
github.com/mattn/go-sqlite3 v1.11.0
|
||||
github.com/mitchellh/mapstructure v1.1.2
|
||||
github.com/newm4n/grool v1.0.2
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
|
||||
github.com/urfave/cli v1.20.0
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
|
||||
google.golang.org/grpc v1.22.0
|
||||
gopkg.in/ini.v1 v1.48.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
|
||||
21
go.sum
21
go.sum
@@ -7,6 +7,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/antlr/antlr4 v0.0.0-20190623224521-a770ff26ccc4/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
|
||||
github.com/antlr/antlr4 v0.0.0-20190726171924-e4737db19f4f h1:GhBxi/Go5GISuLutOqoZ3RaWUpwiruwzlDPXLF0G40g=
|
||||
github.com/antlr/antlr4 v0.0.0-20190726171924-e4737db19f4f/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
@@ -42,6 +43,8 @@ github.com/go-xorm/xorm v0.7.4 h1:g/NgC590SzqV5VKmdRDNe/K3Holw3YJUCXX28r+rFGw=
|
||||
github.com/go-xorm/xorm v0.7.4/go.mod h1:vpza5fydeRgt+stvo9qgMhSNohYqmNt0I1/D6hkCekA=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
@@ -69,6 +72,8 @@ github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGk
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d h1:hJXjZMxj0SWlMoQkzeZDLi2cmeiWKa7y1B8Rg+qaoEc=
|
||||
github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
@@ -88,6 +93,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/newm4n/grool v1.0.2 h1:jdL8LAnWoGoNyeyHrzumljUM6RaFhVsSp0whEqUNLqU=
|
||||
github.com/newm4n/grool v1.0.2/go.mod h1:h0KB8fnrHYDz2uB2nNbVB9PvhZGf/sWMUHZM8ADoAMM=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
@@ -132,11 +139,13 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -145,8 +154,12 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -160,20 +173,28 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190813034749-528a2984e271/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
# Create: 2019-10-29
|
||||
|
||||
# atune-adm completion -*- shell-script -*-
|
||||
complete -W "upgrade profile analysis check info list rollback tuning collection define undefine update train help" atune-adm
|
||||
complete -W "upgrade profile analysis check info list rollback tuning collection define undefine update train generate help" atune-adm
|
||||
|
||||
# ex: filetype=sh
|
||||
|
||||
94
modules/client/profile/profile_generate.go
Normal file
94
modules/client/profile/profile_generate.go
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Huawei Technologies Co., Ltd.
|
||||
* A-Tune is licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
* Create: 2020-07-23
|
||||
*/
|
||||
|
||||
package profile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
PB "gitee.com/openeuler/A-Tune/api/profile"
|
||||
"gitee.com/openeuler/A-Tune/common/client"
|
||||
SVC "gitee.com/openeuler/A-Tune/common/service"
|
||||
"gitee.com/openeuler/A-Tune/common/utils"
|
||||
"io"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
CTX "golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var profileGenerateCommand = cli.Command{
|
||||
Name: "generate",
|
||||
Usage: "generate the tuning yaml profile based on the rules",
|
||||
UsageText: "atune-adm generate OPTIONS",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "project,p",
|
||||
Usage: "the filename and project name to be generated",
|
||||
Value: "default",
|
||||
},
|
||||
},
|
||||
Description: func() string {
|
||||
desc := "generate the tuning yaml profile depend on the rules"
|
||||
return desc
|
||||
}(),
|
||||
Action: profileGenerate,
|
||||
}
|
||||
|
||||
func init() {
|
||||
svc := SVC.ProfileService{
|
||||
Name: "opt.profile.generate",
|
||||
Desc: "opt profile generate",
|
||||
NewInst: newProfileGenerate,
|
||||
}
|
||||
if err := SVC.AddService(&svc); err != nil {
|
||||
fmt.Printf("Failed to load profile generate service : %s\n", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func newProfileGenerate(ctx *cli.Context, opts ...interface{}) (interface{}, error) {
|
||||
return profileGenerateCommand, nil
|
||||
}
|
||||
|
||||
func profileGenerate(ctx *cli.Context) error {
|
||||
if err := utils.CheckArgs(ctx, 0, utils.ConstExactArgs); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := client.NewClientFromContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
svc := PB.NewProfileMgrClient(c.Connection())
|
||||
stream, err := svc.Generate(CTX.Background(), &PB.ProfileInfo{Name: ctx.String("project")})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
for {
|
||||
reply, err := stream.Recv()
|
||||
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
utils.Print(reply)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/urfave/cli"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@@ -68,7 +69,8 @@ type CollectorPost struct {
|
||||
|
||||
// RespCollectorPost : the response of collection servie
|
||||
type RespCollectorPost struct {
|
||||
Path string `json:"path"`
|
||||
Path string `json:"path"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// ClassifyPostBody : the body send to classify service
|
||||
@@ -573,6 +575,7 @@ func (s *ProfileServer) Tuning(stream PB.ProfileMgr_TuningServer) error {
|
||||
}()
|
||||
|
||||
var optimizer = tuning.Optimizer{}
|
||||
|
||||
for {
|
||||
reply, err := stream.Recv()
|
||||
if err == io.EOF {
|
||||
@@ -606,7 +609,6 @@ func (s *ProfileServer) Tuning(stream PB.ProfileMgr_TuningServer) error {
|
||||
if err = tuning.CheckServerPrj(data, &optimizer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//content == nil means in restore config
|
||||
if content == nil {
|
||||
if err = optimizer.RestoreConfigTuned(ch); err != nil {
|
||||
@@ -1237,3 +1239,155 @@ func (s *ProfileServer) Schedule(message *PB.ScheduleMessage,
|
||||
_ = stream.Send(&PB.AckCheck{Name: "schedule finished"})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileServer) collection() (*RespCollectorPost, error) {
|
||||
//1. get the dimension structure of the system data to be collected
|
||||
collections, err := sqlstore.GetCollections()
|
||||
if err != nil {
|
||||
log.Errorf("inquery collection tables error: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 1.1 send the collect data command to the monitor service
|
||||
monitors := make([]Monitor, 0)
|
||||
for _, collection := range collections {
|
||||
re := regexp.MustCompile(`\{([^}]+)\}`)
|
||||
matches := re.FindAllStringSubmatch(collection.Metrics, -1)
|
||||
if len(matches) > 0 {
|
||||
for _, match := range matches {
|
||||
if len(match) < 2 {
|
||||
continue
|
||||
}
|
||||
var value string
|
||||
if s.Raw.Section("system").Haskey(match[1]) {
|
||||
value = s.Raw.Section("system").Key(match[1]).Value()
|
||||
} else if s.Raw.Section("server").Haskey(match[1]) {
|
||||
value = s.Raw.Section("server").Key(match[1]).Value()
|
||||
} else {
|
||||
return nil, fmt.Errorf("%s is not exist in the system or server section", match[1])
|
||||
}
|
||||
re = regexp.MustCompile(`\{(` + match[1] + `)\}`)
|
||||
collection.Metrics = re.ReplaceAllString(collection.Metrics, value)
|
||||
}
|
||||
}
|
||||
|
||||
monitor := Monitor{Module: collection.Module, Purpose: collection.Purpose, Field: collection.Metrics}
|
||||
monitors = append(monitors, monitor)
|
||||
}
|
||||
|
||||
sampleNum := s.Raw.Section("server").Key("sample_num").MustInt(20)
|
||||
collectorBody := new(CollectorPost)
|
||||
collectorBody.SampleNum = sampleNum
|
||||
collectorBody.Monitors = monitors
|
||||
collectorBody.File = "/run/atuned/test.csv"
|
||||
|
||||
log.Infof("tuning collector body is:", collectorBody)
|
||||
respCollectPost, err := collectorBody.Post()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return respCollectPost, nil
|
||||
}
|
||||
|
||||
func (s *ProfileServer) classify(dataPath string) (string, string, error) {
|
||||
//2. send the collected data to the model for completion type identification
|
||||
var resourceLimit string
|
||||
var workloadType string
|
||||
dataPath, err := Post("classification", "file", dataPath)
|
||||
if err != nil {
|
||||
log.Errorf("Failed transfer file to server: %v", err)
|
||||
return workloadType, resourceLimit, err
|
||||
}
|
||||
body := new(ClassifyPostBody)
|
||||
body.Data = dataPath
|
||||
body.ModelPath = path.Join(config.DefaultAnalysisPath, "models")
|
||||
|
||||
respPostIns, err := body.Post()
|
||||
if err != nil {
|
||||
return workloadType, resourceLimit, err
|
||||
}
|
||||
|
||||
log.Infof("workload %s, cluster result resource limit: %s",
|
||||
respPostIns.WorkloadType, respPostIns.ResourceLimit)
|
||||
resourceLimit = respPostIns.ResourceLimit
|
||||
workloadType = respPostIns.WorkloadType
|
||||
return workloadType, resourceLimit, nil
|
||||
}
|
||||
|
||||
func (s *ProfileServer) Getworkload() (string, error) {
|
||||
respCollectPost, err := s.collection()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
workload, _, err := s.classify(respCollectPost.Path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(workload) == 0 {
|
||||
return "", fmt.Errorf("workload is empty")
|
||||
}
|
||||
return workload, nil
|
||||
}
|
||||
|
||||
// Generate method generate the yaml file for tuning
|
||||
func (s *ProfileServer) Generate(message *PB.ProfileInfo, stream PB.ProfileMgr_GenerateServer) error {
|
||||
ch := make(chan *PB.AckCheck)
|
||||
defer close(ch)
|
||||
go func() {
|
||||
for value := range ch {
|
||||
_ = stream.Send(value)
|
||||
}
|
||||
}()
|
||||
|
||||
_ = stream.Send(&PB.AckCheck{Name: fmt.Sprintf("1.Start to analysis the system bottleneck")})
|
||||
respCollectPost, err := s.collection()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("collect data response body is: %+v", respCollectPost)
|
||||
collectData := respCollectPost.Data
|
||||
projectName := message.GetName()
|
||||
|
||||
_ = stream.Send(&PB.AckCheck{Name: fmt.Sprintf("2.Finding potential tuning parameters")})
|
||||
|
||||
var tuningData tuning.TuningData
|
||||
err = mapstructure.Decode(collectData, &tuningData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("decode to structure is: %+v", tuningData)
|
||||
|
||||
ruleFile := path.Join(config.DefaultRulePath, config.TuningRuleFile)
|
||||
engine := tuning.NewRuleEngine(ruleFile)
|
||||
if engine == nil {
|
||||
fmt.Errorf("create rules engine failed")
|
||||
}
|
||||
|
||||
tuningFile := tuning.NewTuningFile(projectName, ch)
|
||||
err = tuningFile.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
engine.AddContext("TuningData", &tuningData)
|
||||
engine.AddContext("TuningFile", tuningFile)
|
||||
err = engine.Execute()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(tuningFile.PrjSrv.Object) <= 0 {
|
||||
_ = stream.Send(&PB.AckCheck{Name: fmt.Sprintf(" No tuning parameters founed")})
|
||||
return nil
|
||||
}
|
||||
dstFile := path.Join(config.DefaultTuningPath, fmt.Sprintf("%s.yaml", projectName))
|
||||
log.Infof("generate tuning file: %s", dstFile)
|
||||
|
||||
err = tuningFile.Save(dstFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = stream.Send(&PB.AckCheck{Name: fmt.Sprintf("3. Generate tuning project: %s\n project name: %s", dstFile, projectName)})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
27
rules/tuning/tuning_rules.grl
Normal file
27
rules/tuning/tuning_rules.grl
Normal file
@@ -0,0 +1,27 @@
|
||||
rule MemUtil "When the Memory Total_Util is greater than 15 append the prefetcher object." salience 10 {
|
||||
when
|
||||
TuningData.TotalUtil > 10
|
||||
then
|
||||
TuningFile.AppendObject("prefetcher");
|
||||
}
|
||||
|
||||
rule CpuBind "When sys is greater than usr append the cpu.band object." {
|
||||
when
|
||||
TuningData.Sys / TuningData.User > 1
|
||||
then
|
||||
TuningFile.AppendObject("cpu.bind");
|
||||
}
|
||||
|
||||
rule CutilCpu "When cutil is greater than util.cpu append the kernel.numa_balancing object." {
|
||||
when
|
||||
TuningData.Cutil / TuningData.UtilCpu > 1.05
|
||||
then
|
||||
TuningFile.AppendObject("kernel.numa_balancing");
|
||||
}
|
||||
|
||||
rule Migrations "When perf stat migrations item is greater than 40000 append the kernel.sched_migration_cost_ns." {
|
||||
when
|
||||
TuningData.Migrations > 40000
|
||||
then
|
||||
TuningFile.AppendObject("kernel.sched_migration_cost_ns");
|
||||
}
|
||||
Reference in New Issue
Block a user