From fe03b0b22ca71e422b299d92dabceebc69c6e3db Mon Sep 17 00:00:00 2001 From: Xiaoguang Li Date: Tue, 18 Aug 2020 12:19:18 +0800 Subject: [PATCH] atune: add noise and sel_feature configs --- analysis/engine/optimizer.py | 4 +++- analysis/engine/parser.py | 4 ++++ common/config/config.go | 10 ++++++++++ common/models/optimizer.go | 2 ++ common/tuning/optimizer.go | 5 +++++ misc/atuned.cnf | 6 ++++++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/analysis/engine/optimizer.py b/analysis/engine/optimizer.py index 02f71e4..46dedb8 100644 --- a/analysis/engine/optimizer.py +++ b/analysis/engine/optimizer.py @@ -64,7 +64,9 @@ class Optimizer(Resource): engine = optimizer.Optimizer(task_id, args["knobs"], child_conn, engine=args.get("engine"), max_eval=args.get("max_eval"), n_random_starts=args.get("random_starts"), - x0=x_ref, y0=y_ref, split_count=args.get("split_count")) + x0=x_ref, y0=y_ref, split_count=args.get("split_count"), + noise=args.get("noise"), + sel_feature=args.get("feature_filter") or args.get("sel_feature")) engine.start() value = {} diff --git a/analysis/engine/parser.py b/analysis/engine/parser.py index aad41f1..6a21748 100644 --- a/analysis/engine/parser.py +++ b/analysis/engine/parser.py @@ -36,6 +36,10 @@ OPTIMIZER_POST_PARSER.add_argument('feature_filter', type=bool, location='json', help="the feature_filter enabled") OPTIMIZER_POST_PARSER.add_argument('split_count', type=int, location='json', help="split_count cannot be null") +OPTIMIZER_POST_PARSER.add_argument('sel_feature', type=bool, location='json', + help="enable the feature selection or not") +OPTIMIZER_POST_PARSER.add_argument('noise', type=float, location='json', + help="the noise can not be null") OPTIMIZER_PUT_PARSER = reqparse.RequestParser() OPTIMIZER_PUT_PARSER.add_argument('iterations', type=int, required=True, diff --git a/common/config/config.go b/common/config/config.go index dcc3a40..a65c6a7 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -114,6 +114,12 @@ var ( TLSHTTPCACertFile string ) +// the tuning configs +var ( + Noise float64 + SelFeature bool +) + // the system config in atuned.cnf var ( Network string @@ -188,6 +194,10 @@ func (c *Cfg) Load() error { Network = net } + section = cfg.Section("tuning") + Noise = section.Key("noise").MustFloat64(0.000000001) + SelFeature = section.Key("sel_feature").MustBool(false) + if err := initLogging(cfg); err != nil { return err } diff --git a/common/models/optimizer.go b/common/models/optimizer.go index 418fd00..abc2270 100644 --- a/common/models/optimizer.go +++ b/common/models/optimizer.go @@ -31,6 +31,8 @@ type OptimizerPostBody struct { Yref []string `json:"y_ref,omitempty"` FeatureFilter bool `json:"feature_filter"` SplitCount int32 `json:"split_count"` + Noise float64 `json:"noise"` + SelFeature bool `json:"sel_feature"` } // Knob body store the tuning properties diff --git a/common/tuning/optimizer.go b/common/tuning/optimizer.go index adc8916..782d52b 100644 --- a/common/tuning/optimizer.go +++ b/common/tuning/optimizer.go @@ -131,7 +131,9 @@ func (o *Optimizer) createOptimizerTask(ch chan *PB.TuningMessage, iters int32, optimizerBody.Engine = engine optimizerBody.RandomStarts = o.RandomStarts optimizerBody.FeatureFilter = o.FeatureFilter + optimizerBody.SelFeature = config.SelFeature optimizerBody.SplitCount = o.SplitCount + optimizerBody.Noise = config.Noise optimizerBody.Knobs = make([]models.Knob, 0) for _, item := range o.Prj.Object { if item.Info.Skip { @@ -361,6 +363,9 @@ func (o *Optimizer) matchRelations(optStr string) bool { func (o *Optimizer) filterParams() (string, error) { log.Infof("params importance weight is: %s", o.RespPutIns.Rank) + if strings.TrimSpace(o.RespPutIns.Rank) == "" { + return "", nil + } sortedParams := make(utils.SortedPair, 0) paramList := strings.Split(o.RespPutIns.Rank, ",") diff --git a/misc/atuned.cnf b/misc/atuned.cnf index 7875f09..51f0eb0 100755 --- a/misc/atuned.cnf +++ b/misc/atuned.cnf @@ -79,3 +79,9 @@ disk = sda network = enp189s0f0 user = root + +#################################### tuning ############################### +# tuning configs +[tuning] +noise = 0.000000001 +sel_feature = false -- GitLab