test: add performance testing harness#23
Merged
Conversation
0177427 to
739f9c8
Compare
739f9c8 to
4f72c9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
INFINI_RT_BUILD_PERFORMANCE_TESTINGCMake path undertests/performance.TensorViewperformance tests that emit JSON lines withunit,mean, andmedian.scripts/run_performance_tests.pyandscripts/compare_performance_results.pyfor local result collection and baseline/candidate comparison.docs/build.md.Motivation
InfiniRT currently has functional coverage but no repeatable local mechanism for measuring runtime overhead and catching performance regressions. This PR introduces the first local performance-testing harness without mixing it into the default functional
INFINI_RT_BUILD_TESTINGflow.Closes N/A
Type of Change
feat- new feature / new operator / new platformfix- bug fixperf- performance improvement (no behavioral change)refactor- code restructuring without behavior changetest- adding or fixing tests onlydocs- documentation onlybuild/ci- build system or CI configurationchore- tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Test Results on Supported Platforms
ssh nvidia; directperf_runtime_dispatchandperf_tensor_viewruns passed.perf_memoryis too slow with current default CUDA allocator iterations and exceeded a 90s direct-run timeout after one result.Remote CPU CTest output
Benchmark / Performance Impact
This PR adds opt-in performance tests only. It does not change runtime behavior unless
INFINI_RT_BUILD_PERFORMANCE_TESTING=ONis explicitly configured.Remote validation was run on
ssh nvidiain/tmp/infinirt-perf-nb3EjJ/InfiniRTat commit4f72c9bc87de289400b108ba3bec2ce33b8d6f9a.Environment:
Commands used for CPU validation:
cmake -S . -B build-perf-cpu \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_CPU=ON \ -DINFINI_RT_BUILD_PERFORMANCE_TESTING=ON cmake --build build-perf-cpu -j ctest --test-dir build-perf-cpu -L performance --output-on-failure python3 scripts/run_performance_tests.py \ --build-dir build-perf-cpu \ --backend cpu \ --output perf-current-cpu.jsonCommands used for NVIDIA validation:
CPU result summary from
perf-current-cpu.json:Raw NVIDIA perf_runtime_dispatch output
{"backend":"nvidia","benchmark":"perf_runtime_dispatch.runtime_device_type","params":{},"iterations":1000000,"unit":"ns","mean":5.724313,"median":5.82811} {"backend":"nvidia","benchmark":"perf_runtime_dispatch.set_runtime_device_type","params":{},"iterations":1000000,"unit":"ns","mean":5.83061171429,"median":5.813068} {"backend":"nvidia","benchmark":"perf_runtime_dispatch.dispatch_GetDevice","params":{},"iterations":200000,"unit":"ns","mean":65.0808092857,"median":48.231315} {"backend":"nvidia","benchmark":"perf_runtime_dispatch.direct_GetDevice","params":{},"iterations":200000,"unit":"ns","mean":42.586075,"median":42.065435} {"backend":"nvidia","benchmark":"perf_runtime_dispatch.dispatch_DeviceSynchronize","params":{},"iterations":200000,"unit":"ns","mean":2015.20736643,"median":1785.503775} {"backend":"nvidia","benchmark":"perf_runtime_dispatch.direct_DeviceSynchronize","params":{},"iterations":200000,"unit":"ns","mean":1824.255975,"median":1889.21806}Raw NVIDIA perf_tensor_view output
{"backend":"nvidia","benchmark":"perf_tensor_view.construct_contiguous","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":35.2714471429,"median":35.26721} {"backend":"nvidia","benchmark":"perf_tensor_view.operator_index","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":70.49953,"median":70.459035} {"backend":"nvidia","benchmark":"perf_tensor_view.numel","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":3.09144928571,"median":3.00024} {"backend":"nvidia","benchmark":"perf_tensor_view.is_contiguous_true","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":28.1229221429,"median":28.096425} {"backend":"nvidia","benchmark":"perf_tensor_view.is_contiguous_false","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":20.7970757143,"median":20.842875} {"backend":"nvidia","benchmark":"perf_tensor_view.hash","params":{"ndim":2},"iterations":200000,"unit":"ns","mean":11.0330228571,"median":11.017515}Raw NVIDIA perf_memory partial output
The direct run used
timeout 90s ./perf_memory. It printed one result before the timeout ended the process:{"backend":"nvidia","benchmark":"perf_memory.MallocFree","params":{"size_bytes":4096},"iterations":2000,"unit":"us","mean":1244.18359121,"median":1091.6453825}This suggests the current CUDA allocator benchmark iteration count is too high for practical review-time validation. The harness works, but CUDA memory benchmarks should likely get backend-specific iteration tuning before they are used as a gating signal.
Attached output file: perf-current-cpu.json
[ { "backend": "cpu", "benchmark": "perf_runtime_dispatch.runtime_device_type", "params": {}, "iterations": 1000000, "unit": "ns", "mean": 4.04114271429, "median": 4.042901, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_runtime_dispatch.set_runtime_device_type", "params": {}, "iterations": 1000000, "unit": "ns", "mean": 4.04959485714, "median": 4.049852, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_runtime_dispatch.dispatch_GetDevice", "params": {}, "iterations": 200000, "unit": "ns", "mean": 5.71934857143, "median": 5.67667, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_runtime_dispatch.direct_GetDevice", "params": {}, "iterations": 200000, "unit": "ns", "mean": 0.33768, "median": 0.333525, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_runtime_dispatch.dispatch_DeviceSynchronize", "params": {}, "iterations": 200000, "unit": "ns", "mean": 5.41648142857, "median": 5.45549, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_runtime_dispatch.direct_DeviceSynchronize", "params": {}, "iterations": 200000, "unit": "ns", "mean": 0.333523571429, "median": 0.333535, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocFree", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.0336127857143, "median": 0.033011, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocHostFreeHost", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.0321147142857, "median": 0.0320175, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyHostToDevice", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.058539, "median": 0.058533, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToHost", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.0422036428571, "median": 0.0421755, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToDevice", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.0591995, "median": 0.0592265, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.Memset", "params": { "size_bytes": 4096 }, "iterations": 2000, "unit": "us", "mean": 0.0326498571429, "median": 0.0326875, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocFree", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 0.035048, "median": 0.035026, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocHostFreeHost", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 0.036511, "median": 0.035368, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyHostToDevice", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 1.76186985714, "median": 1.707405, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToHost", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 1.67260242857, "median": 1.668868, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToDevice", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 1.69421542857, "median": 1.691289, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.Memset", "params": { "size_bytes": 65536 }, "iterations": 1000, "unit": "us", "mean": 1.14093642857, "median": 1.139347, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocFree", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 0.0341842857143, "median": 0.03412, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocHostFreeHost", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 0.0340828571429, "median": 0.03383, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyHostToDevice", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 69.968505, "median": 69.737025, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToHost", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 68.9639157143, "median": 68.89886, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToDevice", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 69.8550871429, "median": 71.085695, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.Memset", "params": { "size_bytes": 1048576 }, "iterations": 200, "unit": "us", "mean": 20.0378564286, "median": 20.46497, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocFree", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 0.0365928571429, "median": 0.0356, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MallocHostFreeHost", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 0.0364714285714, "median": 0.0352, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyHostToDevice", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 1005.07313571, "median": 1005.7637, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToHost", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 1050.11529286, "median": 1062.5111, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.MemcpyDeviceToDevice", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 1075.48677143, "median": 1077.0393, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_memory.Memset", "params": { "size_bytes": 16777216 }, "iterations": 20, "unit": "us", "mean": 745.283185714, "median": 735.2114, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.construct_contiguous", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 35.52444, "median": 35.484405, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.operator_index", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 71.1723085714, "median": 70.905275, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.numel", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 3.00286, "median": 3.0001, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.is_contiguous_true", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 27.9748014286, "median": 27.978335, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.is_contiguous_false", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 21.211595, "median": 21.310235, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" }, { "backend": "cpu", "benchmark": "perf_tensor_view.hash", "params": { "ndim": 2 }, "iterations": 200000, "unit": "ns", "mean": 11.0501507143, "median": 11.01058, "commit": "4f72c9bc87de289400b108ba3bec2ce33b8d6f9a", "compiler": "/usr/bin/c++", "build_type": "Release", "system": "Linux-5.15.0-179-generic-x86_64-with-glibc2.35" } ]No baseline-vs-new comparison is included because this PR introduces the harness and does not claim a runtime performance improvement. The default memory sweep covers up to 16 MiB;
INFINI_RT_PERF_ENABLE_LARGE=1enables the 256 MiB case.Notes for Reviewers
tests/performanceand scripts underscriptsfor this first stage.unit,mean, andmedian.perf-current-cpu.jsonso reviewers can inspect the exact JSON emitted by the new harness.perf_memoryis too slow with the current allocator benchmark iteration count; this is a useful follow-up before using NVIDIA memory benchmarks as a presubmit gate.