lindong28 commented on code in PR #66: URL: https://github.com/apache/flink-benchmarks/pull/66#discussion_r1131955641
########## regression_report_v2.py: ########## @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. +""" + +ENVIRONMENT = 2 + +""" +Returns a list of benchmark results +""" +def loadHistoryData(codespeedUrl, exe, benchmark, baselineSize): + url = codespeedUrl + 'timeline/json/?' + urllib.urlencode( + {'exe': exe, 'ben': benchmark, 'env': ENVIRONMENT, 'revs': baselineSize}) + f = urllib2.urlopen(url) + response = f.read() + f.close() + timelines = json.loads(response)['timelines'][0] + result = timelines['branches']['master'][exe] + lessIsbBetter = (timelines['lessisbetter'] == " (less is better)") + return result, lessIsbBetter + +def detectRegression(urlToBenchmark, stds, scores, baselineSize, minRegressionRatio, minInstabilityMultiplier, + direction): + sustainable_x = [min(scores[i - 3: i]) for i in range(3, baselineSize)] + baseline_throughput = max(sustainable_x) + current_throughput = max(scores[-3:]) + current_instability = stds[-1] / current_throughput + if direction * (1 - current_throughput / baseline_throughput) > max(minRegressionRatio, minInstabilityMultiplier * current_instability): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkBenchmark(args, exe, benchmark): + results, lessIsbBetter = loadHistoryData(args.codespeedUrl, exe, benchmark, args.baselineSize + 3) + results = list(reversed(results)) + scores = [score for (date, score, deviation, commit, branch) in results] + stds = [deviation for (date, score, deviation, commit, branch) in results] + + urlToBenchmark = args.codespeedUrl + 'timeline/#/?' + urllib.urlencode({ + 'ben': benchmark, + 'exe': exe, + 'env': ENVIRONMENT, + 'revs': args.displaySamples, + 'equid': 'off', + 'quarts': 'on', + 'extr': 'on'}) + + if len(results) < args.baselineSize: Review Comment: Does this mean that a new benchmark will only be included in the regression detection 30 days after this benchmark is added? I am wondering if it would be useful to include new benchmark in the detection faster. For example, we can start to detect regression after there are 5 samples for this benchmark. ########## regression_report_v2.py: ########## @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. +""" + +ENVIRONMENT = 2 + +""" +Returns a list of benchmark results +""" +def loadHistoryData(codespeedUrl, exe, benchmark, baselineSize): + url = codespeedUrl + 'timeline/json/?' + urllib.urlencode( + {'exe': exe, 'ben': benchmark, 'env': ENVIRONMENT, 'revs': baselineSize}) + f = urllib2.urlopen(url) + response = f.read() + f.close() + timelines = json.loads(response)['timelines'][0] + result = timelines['branches']['master'][exe] + lessIsbBetter = (timelines['lessisbetter'] == " (less is better)") + return result, lessIsbBetter + +def detectRegression(urlToBenchmark, stds, scores, baselineSize, minRegressionRatio, minInstabilityMultiplier, + direction): + sustainable_x = [min(scores[i - 3: i]) for i in range(3, baselineSize)] + baseline_throughput = max(sustainable_x) + current_throughput = max(scores[-3:]) + current_instability = stds[-1] / current_throughput + if direction * (1 - current_throughput / baseline_throughput) > max(minRegressionRatio, minInstabilityMultiplier * current_instability): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkBenchmark(args, exe, benchmark): + results, lessIsbBetter = loadHistoryData(args.codespeedUrl, exe, benchmark, args.baselineSize + 3) + results = list(reversed(results)) + scores = [score for (date, score, deviation, commit, branch) in results] + stds = [deviation for (date, score, deviation, commit, branch) in results] + + urlToBenchmark = args.codespeedUrl + 'timeline/#/?' + urllib.urlencode({ + 'ben': benchmark, + 'exe': exe, + 'env': ENVIRONMENT, + 'revs': args.displaySamples, + 'equid': 'off', + 'quarts': 'on', + 'extr': 'on'}) + + if len(results) < args.baselineSize: + return + + direction = 1 + if lessIsbBetter: + scores = [-1 * score for score in scores] + direction = -1 + detectRegression(urlToBenchmark, stds, scores, args.baselineSize, args.minRegressionRatio, + args.minInstabilityMultiplier, direction) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Regression report based on Max/Min value') + parser.add_argument('--baseline-size', dest='baselineSize', required=False, default=30, type=int, Review Comment: Since it refers to the number of samples, how about naming it `numBaselineSamples`? ########## regression_report_v2.py: ########## @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. +""" + +ENVIRONMENT = 2 + +""" +Returns a list of benchmark results +""" +def loadHistoryData(codespeedUrl, exe, benchmark, baselineSize): + url = codespeedUrl + 'timeline/json/?' + urllib.urlencode( + {'exe': exe, 'ben': benchmark, 'env': ENVIRONMENT, 'revs': baselineSize}) + f = urllib2.urlopen(url) + response = f.read() + f.close() + timelines = json.loads(response)['timelines'][0] + result = timelines['branches']['master'][exe] + lessIsbBetter = (timelines['lessisbetter'] == " (less is better)") + return result, lessIsbBetter + +def detectRegression(urlToBenchmark, stds, scores, baselineSize, minRegressionRatio, minInstabilityMultiplier, + direction): + sustainable_x = [min(scores[i - 3: i]) for i in range(3, baselineSize)] + baseline_throughput = max(sustainable_x) + current_throughput = max(scores[-3:]) + current_instability = stds[-1] / current_throughput + if direction * (1 - current_throughput / baseline_throughput) > max(minRegressionRatio, minInstabilityMultiplier * current_instability): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkBenchmark(args, exe, benchmark): + results, lessIsbBetter = loadHistoryData(args.codespeedUrl, exe, benchmark, args.baselineSize + 3) + results = list(reversed(results)) + scores = [score for (date, score, deviation, commit, branch) in results] + stds = [deviation for (date, score, deviation, commit, branch) in results] + + urlToBenchmark = args.codespeedUrl + 'timeline/#/?' + urllib.urlencode({ + 'ben': benchmark, + 'exe': exe, + 'env': ENVIRONMENT, + 'revs': args.displaySamples, + 'equid': 'off', + 'quarts': 'on', + 'extr': 'on'}) + + if len(results) < args.baselineSize: + return + + direction = 1 + if lessIsbBetter: + scores = [-1 * score for score in scores] + direction = -1 + detectRegression(urlToBenchmark, stds, scores, args.baselineSize, args.minRegressionRatio, + args.minInstabilityMultiplier, direction) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Regression report based on Max/Min value') + parser.add_argument('--baseline-size', dest='baselineSize', required=False, default=30, type=int, + help='Number of samples taken as the base line.') Review Comment: I am wondering if the following doc would be a bit more informative: The maximum number of recent samples across which the maximum achieved throughput would be used as the baseline for regression detection. ########## regression_report_v2.py: ########## @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. Review Comment: nits: could you help remove the word `edit` from this URL? It might be useful to briefly describe the algorithm so that users would not have to visit the Google doc. How about the following doc: ``` """ The regression detection algorithm calculates the regression ratio as the ratio of change between the current throughput and the maximum throughput observed in the most recent numBaselineSamples samples. A regression alert is triggered if the regression ratio exceeds max(minRegressionRatio, minInstabilityMultiplier * lastStandardDeviation) Please refer to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag for more detail. """ ``` ########## regression_report_v2.py: ########## @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. +""" + +ENVIRONMENT = 2 + +""" +Returns a list of benchmark results +""" +def loadHistoryData(codespeedUrl, exe, benchmark, baselineSize): + url = codespeedUrl + 'timeline/json/?' + urllib.urlencode( + {'exe': exe, 'ben': benchmark, 'env': ENVIRONMENT, 'revs': baselineSize}) + f = urllib2.urlopen(url) + response = f.read() + f.close() + timelines = json.loads(response)['timelines'][0] + result = timelines['branches']['master'][exe] + lessIsbBetter = (timelines['lessisbetter'] == " (less is better)") + return result, lessIsbBetter + +def detectRegression(urlToBenchmark, stds, scores, baselineSize, minRegressionRatio, minInstabilityMultiplier, + direction): + sustainable_x = [min(scores[i - 3: i]) for i in range(3, baselineSize)] + baseline_throughput = max(sustainable_x) + current_throughput = max(scores[-3:]) + current_instability = stds[-1] / current_throughput + if direction * (1 - current_throughput / baseline_throughput) > max(minRegressionRatio, minInstabilityMultiplier * current_instability): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkBenchmark(args, exe, benchmark): + results, lessIsbBetter = loadHistoryData(args.codespeedUrl, exe, benchmark, args.baselineSize + 3) + results = list(reversed(results)) + scores = [score for (date, score, deviation, commit, branch) in results] + stds = [deviation for (date, score, deviation, commit, branch) in results] + + urlToBenchmark = args.codespeedUrl + 'timeline/#/?' + urllib.urlencode({ + 'ben': benchmark, + 'exe': exe, + 'env': ENVIRONMENT, + 'revs': args.displaySamples, + 'equid': 'off', + 'quarts': 'on', + 'extr': 'on'}) + + if len(results) < args.baselineSize: + return + + direction = 1 + if lessIsbBetter: + scores = [-1 * score for score in scores] + direction = -1 + detectRegression(urlToBenchmark, stds, scores, args.baselineSize, args.minRegressionRatio, + args.minInstabilityMultiplier, direction) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Regression report based on Max/Min value') + parser.add_argument('--baseline-size', dest='baselineSize', required=False, default=30, type=int, + help='Number of samples taken as the base line.') + parser.add_argument('--display-samples', dest='displaySamples', required=False, default=200, Review Comment: Since it refers to the number of samples, how about `numDisplaySamples`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org