Granulate / gprofiler

gProfiler is a system-wide profiler, combining multiple sampling profilers to produce unified visualization of what your CPU is spending time on.
https://profiler.granulate.io
Apache License 2.0
754 stars 54 forks source link

tests: perf various combinations of test_perf_fp_dwarf_smart collapsed differ on aarch64 #746

Open pfilipko1 opened 1 year ago

pfilipko1 commented 1 year ago

Failing tests:

FAILED tests/test_perf.py::test_perf_fp_dwarf_smart[True-fp-native_fp] - AssertionError: assert (True ^ True)
FAILED tests/test_perf.py::test_perf_fp_dwarf_smart[True-dwarf-native_fp] - AssertionError: function ';recursive;recursive;recursive;recursive;' missing in collapsed data!
FAILED tests/test_perf.py::test_perf_fp_dwarf_smart[True-dwarf-native_dwarf] - AssertionError: assert (False ^ False)
FAILED tests/test_perf.py::test_perf_fp_dwarf_smart[True-smart-native_dwarf] - AssertionError: assert (False ^ False)

Exemplary output:

system_profiler = <gprofiler.profilers.perf.SystemProfiler object at 0xffffa4cb4ee0>, application_pid = 1478804, runtime = 'native_dwarf', perf_mode = 'smart', application_docker_container = <Container: 51caf27de4>

    @pytest.mark.parametrize("runtime", ["native_fp", "native_dwarf"])
    @pytest.mark.parametrize("perf_mode", ["fp", "dwarf", "smart"])
    @pytest.mark.parametrize("in_container", [True])  # native app is built only for container
    def test_perf_fp_dwarf_smart(
        system_profiler: SystemProfiler,
        application_pid: int,
        runtime: str,
        perf_mode: str,
        application_docker_container: Container,
    ) -> None:
        with system_profiler as profiler:
            process_profile = snapshot_pid_profile(profiler, application_pid)
            process_collapsed = process_profile.stacks
            with open("perf.txt","a") as f:
                f.write(str(process_collapsed))
                f.write("")
            if runtime == "native_dwarf":
                # app is built with DWARF info and without FP, so we expect to see a callstack only in DWARF or smart modes.
>               assert is_function_in_collapsed(";recursive;recursive;recursive;recursive;", process_collapsed) ^ bool(
                    perf_mode not in ("dwarf", "smart")
                )
E               AssertionError: assert (False ^ False)
E                +  where False = is_function_in_collapsed(';recursive;recursive;recursive;recursive;', Counter({'native;_start;recursive': 90}))
E                +  and   False = bool('smart' not in ('dwarf', 'smart'))

tests/test_perf.py:66: AssertionError
Jongy commented 1 year ago

I think these failures are all due to https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm64/kernel/perf_callchain.c?id=33c222aeda14596ca5b9a1a3002858c6c3565ddd. This causes unwinding to show only one level in certain cases, so this test (which checks for multiple levels recursive;recursive;recursive;... fails.