Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-base-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
--build-arg PHPSPY_BUILDER_UBUNTU=@sha256:cf31af331f38d1d7158470e095b132acd126a7180a54f263d386da88eb681d93
--build-arg AP_BUILDER_CENTOS=@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
--build-arg AP_BUILDER_ALPINE=@sha256:69704ef328d05a9f806b6b8502915e6a0a4faa4d72018dc42343f511490daf8a
--build-arg AP_CENTOS_MIN=:6
--build-arg AP_CENTOS_MIN=:7
--build-arg BURN_BUILDER_GOLANG=@sha256:f7d3519759ba6988a2b73b5874b17c5958ac7d0aa48a8b1d84d66ef25fa345f1
--build-arg GPROFILER_BUILDER=@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
--build-arg PYPERF_BUILDER_UBUNTU=@sha256:cf31af331f38d1d7158470e095b132acd126a7180a54f263d386da88eb681d93
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:
- ubuntu:20.04
- ubuntu:20.10
- ubuntu:22.04
- centos:6
- centos:7
- centos:8
- debian:8
Expand Down
8 changes: 2 additions & 6 deletions scripts/build_x86_64_executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ UBUNTU_VERSION_1804=@sha256:dca176c9663a7ba4c1f0e710986f5a25e672842963d95b960191
# phpspy & pyperf - ubuntu:20.04
UBUNTU_VERSION=@sha256:cf31af331f38d1d7158470e095b132acd126a7180a54f263d386da88eb681d93
# async-profiler glibc - centos:7
# requires CentOS 7 so the built DSO can be loaded into machines running with old glibc (tested up to centos:6),
# we do make some modifications to the selected versioned symbols so that we don't use anything from >2.12 (what centos:6
# has)
AP_BUILDER_CENTOS=@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
# async-profiler musl - alpine
AP_BUILDER_ALPINE=@sha256:69704ef328d05a9f806b6b8502915e6a0a4faa4d72018dc42343f511490daf8a
# dotnet builder - mcr.microsoft.com/dotnet/sdk:6.0.428-1-focal
DOTNET_BUILDER=@sha256:525ce79a6f545131df515ce34f7ee086eb18e4d707eff9676b2678f2f23b6d9e
# minimum CentOS version we intend to support with async-profiler (different between x86_64, where we require
# an older version)
AP_CENTOS_MIN=:6
# minimum CentOS version we intend to support with async-profiler
AP_CENTOS_MIN=:7
# burn - golang:1.16.3
BURN_BUILDER_GOLANG=@sha256:f7d3519759ba6988a2b73b5874b17c5958ac7d0aa48a8b1d84d66ef25fa345f1
# bcc & gprofiler - centos:7
Expand Down
4 changes: 3 additions & 1 deletion tests/containers/python/lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ def parser():
Thread(target=parser).start()
lister = Lister()
while True:
lister.lister()
# Call multiple times per iteration to increase chance of being sampled by profilers
for _ in range(10):
lister.lister()
4 changes: 0 additions & 4 deletions tests/test_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def test_executable(
pytest.xfail("Dotnet-trace doesn't work with alpine: https://github.com/intel/gprofiler/issues/795")

if exec_container_image is not None:
if "centos:6" in exec_container_image.tags and any("pyperf" in flag for flag in profiler_flags):
# don't run PyPerf on the centos:6 image, it fails. And in any case PyPerf can't run on centos:6.
pytest.skip("PyPerf test on centos:6")

gprofiler_inner_dir = Path("/app")
inner_output_dir = Path("/app/output")
cwd = Path(os.getenv("GITHUB_WORKSPACE", os.getcwd()))
Expand Down
21 changes: 17 additions & 4 deletions tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_python_select_by_libpython(
"3.7-musl-uwsgi",
],
)
@pytest.mark.flaky(reruns=3, reruns_delay=2)
@pytest.mark.parametrize("profiler_type", ["py-spy", "pyperf"])
def test_python_matrix(
application_pid: int,
Expand Down Expand Up @@ -119,9 +120,15 @@ def test_python_matrix(
):
pytest.xfail("This combination fails, see https://github.com/Granulate/gprofiler/issues/714")

with PythonProfiler(1000, 2, profiler_state, profiler_type, True, None, False, python_pyspy_process=[]) as profiler:
# Use longer duration for pyperf to ensure enough samples are collected for reliable assertions
duration = 5 if profiler_type == "pyperf" else 2
# Timeout should be longer than duration to allow profiling to complete
snapshot_timeout = duration + 5
with PythonProfiler(
1000, duration, profiler_state, profiler_type, True, None, False, python_pyspy_process=[]
) as profiler:
try:
profile = snapshot_pid_profile(profiler, application_pid)
profile = snapshot_pid_profile(profiler, application_pid, timeout=snapshot_timeout)
except TimeoutError:
if profiler._ebpf_profiler is not None and profiler._ebpf_profiler.process is not None:
PythonEbpfProfiler._check_output(profiler._ebpf_profiler.process, profiler._ebpf_profiler.output_path)
Expand Down Expand Up @@ -183,8 +190,14 @@ def test_dso_name_in_pyperf_profile(
if is_aarch64() and profiler_type == "pyperf":
pytest.skip("PyPerf doesn't support aarch64 architecture, see https://github.com/intel/gprofiler/issues/499")

with PythonProfiler(1000, 2, profiler_state, profiler_type, True, None, True, python_pyspy_process=[]) as profiler:
profile = snapshot_pid_profile(profiler, application_pid)
# Use longer duration for pyperf to ensure enough samples are collected
duration = 5 if profiler_type == "pyperf" else 2
# Timeout should be longer than duration to allow profiling to complete
snapshot_timeout = duration + 5
with PythonProfiler(
1000, duration, profiler_state, profiler_type, True, None, True, python_pyspy_process=[]
) as profiler:
profile = snapshot_pid_profile(profiler, application_pid, timeout=snapshot_timeout)
python_version, _, _ = application_image_tag.split("-")
interpreter_frame = "PyEval_EvalFrameEx" if python_version == "2.7" else "_PyEval_EvalFrameDefault"
collapsed = profile.stacks
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def assert_ldd_version_container(container: Container, version: str) -> None:
assert version_in_container == version, f"ldd version in container: {version_in_container}, expected {version}"


def snapshot_pid_profile(profiler: ProfilerInterface, pid: int) -> ProfileData:
def snapshot_pid_profile(profiler: ProfilerInterface, pid: int, timeout: int = 5) -> ProfileData:
last_snapshot = profiler.snapshot()

def has_profile() -> bool:
Expand All @@ -216,7 +216,7 @@ def has_profile() -> bool:
last_snapshot = profiler.snapshot()
return pid in last_snapshot

wait_event(timeout=5, stop_event=Event(), condition=has_profile, interval=2.0)
wait_event(timeout=timeout, stop_event=Event(), condition=has_profile, interval=2.0)
return last_snapshot[pid]


Expand Down
Loading