Skip to content

Commit 066514c

Browse files
authored
gProfiler 1.2.7 (#216)
And other small fixes.
1 parent 18cabcc commit 066514c

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
mkdir -p output
8686
./scripts/build_x86_64_executable.sh
8787
mv build/x86_64/gprofiler output/gprofiler_x86_64
88+
cp output/gprofiler_x86_64 output/gprofiler # for backwards compatibility
8889
8990
- name: Upload the executables as job artifacts
9091
uses: actions/upload-artifact@v2

gprofiler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright (c) Granulate. All rights reserved.
33
# Licensed under the AGPL3 License. See LICENSE.md in the project root for license information.
44
#
5-
__version__ = "1.2.6"
5+
__version__ = "1.2.7"

gprofiler/profilers/java.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def __init__(self, version: Version, build: int, name: str):
377377
self.name = name
378378

379379
def __repr__(self):
380-
return f"JvmVersion({self.version}, {self.build}, {self.name})"
380+
return f"JvmVersion({self.version}, {self.build!r}, {self.name!r})"
381381

382382

383383
# Parse java version information from "java -version" output
@@ -514,12 +514,14 @@ def __init__(
514514
self._interval = int((1 / frequency) * 1000_000_000)
515515
self._buildids = java_async_profiler_buildids
516516
self._version_check = java_version_check
517-
if not java_version_check:
517+
if not self._version_check:
518518
logger.warning("Java version checks are disabled")
519519
self._mode = java_async_profiler_mode
520520
self._safemode = java_async_profiler_safemode
521521
self._saved_mlock: Optional[int] = None
522522
self._java_safemode = java_safemode
523+
if self._java_safemode:
524+
logger.debug("Java safemode enabled")
523525

524526
def _is_jvm_type_supported(self, java_version_cmd_output: str) -> bool:
525527
return all(exclusion not in java_version_cmd_output for exclusion in self.JDK_EXCLUSIONS)
@@ -587,37 +589,49 @@ def _run_java_version() -> None:
587589
# Version is printed to stderr
588590
return java_version_cmd_output.stderr.decode()
589591

590-
def _profile_process(self, process: Process) -> Optional[StackToSampleCount]:
591-
logger.info(f"Profiling process {process.pid} with async-profiler")
592+
def _check_jvm_type_supported(self, process: Process, java_version_output: str) -> bool:
593+
if not self._is_jvm_type_supported(java_version_output):
594+
logger.error(f"Process {process.pid} running unsupported JVM ({java_version_output!r}), skipping...")
595+
return False
596+
597+
return True
598+
599+
def _is_profiling_supported(self, process: Process) -> bool:
592600
process_basename = os.path.basename(process.exe())
593601
if self._java_safemode:
594602
# TODO we can get the "java" binary by extracting the java home from the libjvm path,
595603
# then check with that instead (if exe isn't java)
596604
if process_basename != "java":
597605
logger.error(
598-
f"Non-java basenamed process {process.pid} ({process.exe()}), skipping..."
606+
f"Non-java basenamed process {process.pid} ({process.exe()!r}), skipping..."
599607
" (disable --java-safemode to profile it anyway)"
600608
)
601-
return None
609+
return False
602610

603611
java_version_output = self._get_java_version(process)
604612

605-
if not self._is_jvm_type_supported(java_version_output):
606-
logger.error(f"Process {process.pid} running unsupported JVM, skipping...")
607-
return None
613+
if not self._check_jvm_type_supported(process, java_version_output):
614+
return False
608615

609616
if not self._is_jvm_version_supported(java_version_output):
610617
logger.error(
611-
f"Process {process.pid} running unsupported Java version, skipping..."
618+
f"Process {process.pid} running unsupported Java version ({java_version_output!r}), skipping..."
612619
" (disable --java-safemode to profile it anyway)"
613620
)
614-
return None
621+
return False
615622
else:
616623
if self._version_check and process_basename == "java":
617-
if not self._is_jvm_type_supported(self._get_java_version(process)):
618-
logger.error(f"Process {process.pid} running unsupported JVM, skipping...")
619-
return None
624+
java_version_output = self._get_java_version(process)
625+
if not self._check_jvm_type_supported(process, java_version_output):
626+
return False
627+
628+
return True
620629

630+
def _profile_process(self, process: Process) -> Optional[StackToSampleCount]:
631+
if not self._is_profiling_supported(process):
632+
return None
633+
634+
logger.info(f"Profiling process {process.pid} with async-profiler")
621635
with AsyncProfiledProcess(process, self._storage_dir, self._buildids, self._mode, self._safemode) as ap_proc:
622636
return self._profile_ap_process(ap_proc)
623637

0 commit comments

Comments
 (0)