Commit 544a80ef by Cody Northrop Committed by Commit Bot

Perf: Detect context used by trace

Capturing supports multiple contexts, which are hard coded into the function and file names. On desktop, they've typically been "1", but on Android we've seen context "2" or "3". This CL adds the ability to detect the context number used by the trace, and programmatically adds it to generated files. Test: angle_perftests --gtest_filter="*Trace*" Bug: b/152512564 Bug: angleproject:4036 Change-Id: I64616b93a704446b08cb614b2a74ab1932ef1f40 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2197283Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent 664376e2
{ {
"src/tests/perf_tests/restricted_traces/gen_restricted_traces.py": "src/tests/perf_tests/restricted_traces/gen_restricted_traces.py":
"8e2db2332d1969209081b05fe4e8da79", "ff51ca78ed52c33ddfcc4a7e795f217c",
"src/tests/perf_tests/restricted_traces/manhattan_10.tar.gz.sha1": "src/tests/perf_tests/restricted_traces/manhattan_10.tar.gz.sha1":
"b4d333cd5cf3977c339350be0a819928", "b4d333cd5cf3977c339350be0a819928",
"src/tests/perf_tests/restricted_traces/restricted_traces.json": "src/tests/perf_tests/restricted_traces/restricted_traces.json":
"b73081e6815268e7712599d83f4bfb7c", "ebdb00ee3c7c74832f586a83b4394486",
"src/tests/perf_tests/restricted_traces/restricted_traces_autogen.gni": "src/tests/perf_tests/restricted_traces/restricted_traces_autogen.gni":
"00afbfd7987ff25af045af104477a680", "54343c0c0a3a15f076516ad26f2ada5a",
"src/tests/perf_tests/restricted_traces/restricted_traces_autogen.h": "src/tests/perf_tests/restricted_traces/restricted_traces_autogen.h":
"d0b8cfda99009a6e042989ffa0ea3608", "d0b8cfda99009a6e042989ffa0ea3608",
"src/tests/perf_tests/restricted_traces/trex_200.tar.gz.sha1": "src/tests/perf_tests/restricted_traces/trex_200.tar.gz.sha1":
......
...@@ -303,9 +303,13 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) { ...@@ -303,9 +303,13 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) {
defines = [ "ANGLE_TRACE_DATA_DIR=\"${_trace_data_path}\"" ] defines = [ "ANGLE_TRACE_DATA_DIR=\"${_trace_data_path}\"" ]
data = [] data = []
foreach(_test, angle_restricted_traces) { foreach(_test_info, angle_restricted_traces) {
_test_and_ctx = []
_test_and_ctx = string_split(_test_info)
_test = _test_and_ctx[0]
_ctx = _test_and_ctx[1]
_test_dir = "perf_tests/restricted_traces/${_test}" _test_dir = "perf_tests/restricted_traces/${_test}"
_test_ctx = "${_test_dir}/${_test}_capture_context1" _test_ctx = "${_test_dir}/${_test}_capture_context${_ctx}"
# Similar to capture replay sample, use the file index for sources # Similar to capture replay sample, use the file index for sources
sources += sources +=
...@@ -319,7 +323,7 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) { ...@@ -319,7 +323,7 @@ if (is_win || is_linux || is_android || is_mac || is_fuchsia) {
defines += defines +=
[ "ANGLE_TRACE_DATA_DIR_${_test}=\"${_trace_data_path}/${_test}\"" ] [ "ANGLE_TRACE_DATA_DIR_${_test}=\"${_trace_data_path}/${_test}\"" ]
data += [ "${_test_dir}/${_test}_capture_context1.angledata.gz" ] data += [ "${_test_dir}/${_test}_capture_context${_ctx}.angledata.gz" ]
} }
deps = [ deps = [
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
# gen_restricted_traces.py: # gen_restricted_traces.py:
# Generates integration code for the restricted trace tests. # Generates integration code for the restricted trace tests.
import fnmatch
import json import json
import os
import sys import sys
gni_template = """# GENERATED FILE - DO NOT EDIT. gni_template = """# GENERATED FILE - DO NOT EDIT.
...@@ -17,7 +19,8 @@ gni_template = """# GENERATED FILE - DO NOT EDIT. ...@@ -17,7 +19,8 @@ gni_template = """# GENERATED FILE - DO NOT EDIT.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# #
# A list of all restricted trace tests. Can be consumed by tests/BUILD.gn. # A list of all restricted trace tests, paired with their context.
# Can be consumed by tests/BUILD.gn.
angle_restricted_traces = [ angle_restricted_traces = [
{test_list} {test_list}
...@@ -142,7 +145,8 @@ def reject_duplicate_keys(pairs): ...@@ -142,7 +145,8 @@ def reject_duplicate_keys(pairs):
def gen_gni(traces, gni_file, format_args): def gen_gni(traces, gni_file, format_args):
format_args["test_list"] = ",\n".join(['"%s"' % trace for trace in traces]) format_args["test_list"] = ",\n".join(
['"%s %s"' % (trace, get_context(trace)) for trace in traces])
gni_data = gni_template.format(**format_args) gni_data = gni_template.format(**format_args)
with open(gni_file, "w") as out_file: with open(gni_file, "w") as out_file:
out_file.write(gni_data) out_file.write(gni_data)
...@@ -154,6 +158,18 @@ def get_trace_info(trace): ...@@ -154,6 +158,18 @@ def get_trace_info(trace):
return ", ".join([element % trace for element in info]) return ", ".join([element % trace for element in info])
def get_context(trace):
"Returns the context number used by trace header file"
for file in os.listdir(trace):
# Load up the only header present for each trace
if fnmatch.fnmatch(file, '*.h'):
# Strip the extension to isolate the context
context = file[len(file) - 3]
assert context.isdigit() == True, "Failed to find trace context number"
assert file[len(file) - 4].isdigit() == False, "Context number is higher than 9"
return context
def get_cases(traces, function, args): def get_cases(traces, function, args):
funcs = [ funcs = [
"case RestrictedTraceID::%s: %s::%s(%s); break;" % (trace, trace, function, args) "case RestrictedTraceID::%s: %s::%s(%s); break;" % (trace, trace, function, args)
...@@ -163,13 +179,21 @@ def get_cases(traces, function, args): ...@@ -163,13 +179,21 @@ def get_cases(traces, function, args):
def get_header_name(trace): def get_header_name(trace):
return "%s/%s_capture_context1.h" % (trace, trace) return "%s/%s_capture_context%s.h" % (trace, trace, get_context(trace))
def get_sha1_name(trace): def get_sha1_name(trace):
return "%s.tar.gz.sha1" % trace return "%s.tar.gz.sha1" % trace
def get_cases_with_context(traces, function_start, function_end, args):
funcs = [
"case RestrictedTraceID::%s: %s::%s%s%s(%s); break;" %
(trace, trace, function_start, get_context(trace), function_end, args) for trace in traces
]
return "\n".join(funcs)
def gen_header(traces, header_file, format_args): def gen_header(traces, header_file, format_args):
includes = ["#include \"%s\"" % get_header_name(trace) for trace in traces] includes = ["#include \"%s\"" % get_header_name(trace) for trace in traces]
...@@ -180,8 +204,9 @@ def gen_header(traces, header_file, format_args): ...@@ -180,8 +204,9 @@ def gen_header(traces, header_file, format_args):
format_args["includes"] = "\n".join(includes) format_args["includes"] = "\n".join(includes)
format_args["trace_ids"] = ",\n".join(traces) format_args["trace_ids"] = ",\n".join(traces)
format_args["trace_infos"] = ",\n".join(trace_infos) format_args["trace_infos"] = ",\n".join(trace_infos)
format_args["replay_func_cases"] = get_cases(traces, "ReplayContext1Frame", "frameIndex") format_args["replay_func_cases"] = get_cases_with_context(traces, "ReplayContext", "Frame",
format_args["setup_func_cases"] = get_cases(traces, "SetupContext1Replay", "") "frameIndex")
format_args["setup_func_cases"] = get_cases_with_context(traces, "SetupContext", "Replay", "")
format_args["set_binary_data_dir_cases"] = get_cases(traces, "SetBinaryDataDir", "dataDir") format_args["set_binary_data_dir_cases"] = get_cases(traces, "SetBinaryDataDir", "dataDir")
format_args["decompress_callback_cases"] = get_cases(traces, "SetBinaryDataDecompressCallback", format_args["decompress_callback_cases"] = get_cases(traces, "SetBinaryDataDecompressCallback",
"callback") "callback")
......
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
"manhattan_10", "manhattan_10",
"trex_200" "trex_200"
] ]
} }
\ No newline at end of file
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# #
# A list of all restricted trace tests. Can be consumed by tests/BUILD.gn. # A list of all restricted trace tests, paired with their context.
# Can be consumed by tests/BUILD.gn.
angle_restricted_traces = [ angle_restricted_traces = [
"manhattan_10", "manhattan_10 1",
"trex_200", "trex_200 1",
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment