OpenCue icon indicating copy to clipboard operation
OpenCue copied to clipboard

unnecessary psutil instance

Open donalm opened this issue 3 years ago • 1 comments

Instead of: https://github.com/AcademySoftwareFoundation/OpenCue/blob/e7c38c6bf5a39eec650a1f7a3851dabcc10d6f48/rqd/rqd/rqmachine.py#L268-L270

Consider:

                    with open("/proc/{}/cmdline".format(pid)) as fh:
                        pids[pid]["cmd_line"] = fh.read().strip('\x00').split('\x00')

I'd like the code in this loop to be efficient, so that we minimize occurrences of /prod/PID directories being cleaned up before we have a chance to read their contents.

(See #1189)

The proposed enhancement runs considerably faster than instancing psutil.Process

donalm avatar Sep 14 '22 12:09 donalm

That suggestion looks good to me.

Unfortunate that psutil is so inefficient -- ideally we would be using it more instead of less to make more of the RQD code cross-platform.

But in this case, the code is already accessing the /proc part of the filesystem anyway, so it's already Windows-unfriendly, and we don't lose anything here by ditching psutil.

bcipriano avatar Sep 14 '22 18:09 bcipriano