(desired_outcome=None)
| 913 | query.solo_runtime_profile_without_spilling = report.profile |
| 914 | |
| 915 | def get_report(desired_outcome=None): |
| 916 | reports_by_outcome = defaultdict(list) |
| 917 | leading_outcome = None |
| 918 | for remaining_samples in range(samples - 1, -1, -1): |
| 919 | report = runner.run_query(query, mem_limit, run_set_up=True, |
| 920 | timeout_secs=timeout_secs, retain_profile=True) |
| 921 | if report.timed_out: |
| 922 | report.write_query_profile( |
| 923 | os.path.join(results_dir, PROFILES_DIR), profile_error_prefix) |
| 924 | raise QueryTimeout( |
| 925 | "query {0} timed out during binary search".format(query.logical_query_id)) |
| 926 | if report.other_error: |
| 927 | report.write_query_profile( |
| 928 | os.path.join(results_dir, PROFILES_DIR), profile_error_prefix) |
| 929 | raise Exception( |
| 930 | "query {0} errored during binary search: {1}".format( |
| 931 | query.logical_query_id, str(report.other_error))) |
| 932 | LOG.debug("Spilled: %s" % report.mem_was_spilled) |
| 933 | if not report.has_query_error(): |
| 934 | if query.result_hash is None: |
| 935 | query.result_hash = report.result_hash |
| 936 | elif query.result_hash != report.result_hash: |
| 937 | report.write_query_profile( |
| 938 | os.path.join(results_dir, PROFILES_DIR), profile_error_prefix) |
| 939 | raise Exception( |
| 940 | "Result hash mismatch for query %s; expected %s, got %s" % |
| 941 | (query.logical_query_id, query.result_hash, report.result_hash)) |
| 942 | |
| 943 | if report.not_enough_memory: |
| 944 | outcome = "EXCEEDED" |
| 945 | elif report.mem_was_spilled: |
| 946 | outcome = "SPILLED" |
| 947 | else: |
| 948 | outcome = "NOT_SPILLED" |
| 949 | reports_by_outcome[outcome].append(report) |
| 950 | if not leading_outcome: |
| 951 | leading_outcome = outcome |
| 952 | continue |
| 953 | if len(reports_by_outcome[outcome]) > len(reports_by_outcome[leading_outcome]): |
| 954 | leading_outcome = outcome |
| 955 | if len(reports_by_outcome[leading_outcome]) + max_conflicting_samples == samples: |
| 956 | break |
| 957 | if ( |
| 958 | len(reports_by_outcome[leading_outcome]) + remaining_samples < |
| 959 | samples - max_conflicting_samples |
| 960 | ): |
| 961 | return |
| 962 | if desired_outcome \ |
| 963 | and len(reports_by_outcome[desired_outcome]) + remaining_samples \ |
| 964 | < samples - max_conflicting_samples: |
| 965 | return |
| 966 | reports = reports_by_outcome[leading_outcome] |
| 967 | reports.sort(key=lambda r: r.runtime_secs) |
| 968 | return reports[len(reports) // 2] |
| 969 | |
| 970 | if not any((old_required_mem_mb_with_spilling, old_required_mem_mb_without_spilling)): |
| 971 | mem_estimate = estimate_query_mem_mb_usage(query, runner.impalad_conn) |
no test coverage detected