-
Notifications
You must be signed in to change notification settings - Fork 11
G-UTILS-GPROFILER REWORK (2): Rework complex files #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
c092236
to
40b789f
Compare
@@ -247,6 +244,7 @@ def _kill_and_reap_process(process: Popen, kill_signal: signal.Signals) -> Tuple | |||
|
|||
def run_process( | |||
cmd: Union[str, List[str]], | |||
logger: Union[logging.LoggerAdapter, logging.Logger], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we don’t want to enforce this as keyword argument?
I'm changing the source branch to |
return wrapper | ||
|
||
|
||
def start_process( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start_process
, run_process
et al are very coupled to gProfiler at several points:
- the logging of command + output
- staticx
- removal of LD_LIBRARY_PATH
and add some optional features that we want for gProfiler but not for other callers: - pdeathsig
Let's keep it in gProfiler, alongside all relevant logic:
get_staticx_dir
start_process
run_process
set_child_termination_on_parent_death
prctl
- (and any other function not used in this PR after the removal of that function).
os.unlink(f) | ||
|
||
|
||
def wait_for_file_by_prefix( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused? Move back to gProfiler.
return Path(output_files[0]) | ||
|
||
|
||
def reap_process(process: Popen) -> Tuple[int, bytes, bytes]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be moved back.
return result | ||
|
||
|
||
def pgrep_maps(match: str, logger: Union[logging.LoggerAdapter, logging.Logger]) -> List[Process]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be moved back.
_INSTALLED_PROGRAMS_CACHE: List[str] = [] | ||
|
||
|
||
def assert_program_installed(program: str) -> None: | ||
if program in _INSTALLED_PROGRAMS_CACHE: | ||
return | ||
|
||
if shutil.which(program) is not None: | ||
_INSTALLED_PROGRAMS_CACHE.append(program) | ||
else: | ||
raise ProgramMissingException(program) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move back
) | ||
|
||
|
||
class JattachJcmdRunner: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert this to accept a run_process
callable, gProfiler will use its run_process
function and other components will pass their own wrappers.
The type of the callable should be defined in granulate-utils.
self._libap_path_glibc = libap_path_glibc | ||
self._libap_path_musl = libap_path_musl | ||
|
||
# assert mode in ("cpu", "itimer", "alloc"), f"unexpected mode: {mode}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to bring this assert back (potentially with other event types you wish to support)
def _run_async_profiler(self, cmd: List[str]) -> str: | ||
try: | ||
# kill jattach with SIGTERM if it hangs. it will go down | ||
run_process( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented for JattachJcmdRunner
, please have a parameter for this class to control the callable to run processes with. When instantiating JattachJcmdRunner
, you'll pass the same value from this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be moved back to gProfiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these can be moved back to gProfiler
Part of the G-UTILS-GPROFILER REWORK saga - which aims to move away shared code from gprofiler to the g-utils project:
#263 #261 intel/gprofiler#925 intel/gprofiler#926 intel/gprofiler#926
This ultimate PR (for this repo) is responsible for logical changes and "trimming" of complex files to be untied from the gprofiler platform