-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve process spawn speed and remove trailing lines. #50
base: master
Are you sure you want to change the base?
Conversation
Problem: # FIXME: popen is slow Solution: use subprocess.run
15407e0
to
6f30ca9
Compare
Should I file more issues for all the formatting and linting issues ruff shows or what is the policy? With
and running
You might want to run this yourself to have less stuff to review. |
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.
The whitespace cleanup (c8d6482) looks good to me, thanks.
The subprocess substitution isn't likely speeding up it as expected.
There is no coding style policy. Would unified style help you before further modifications or what is it helpful for (it's non-functional change, right)?
# --> use /proc/<pid>/status -> Cpus_allowed | ||
# int(line.replace(',',''), 16) | ||
# note: delete leading zeros to compare to allcpumask | ||
line = os.popen('/usr/bin/taskset -p ' + str(proc) +' 2>/dev/null', 'r').readline() | ||
taskset_res = subprocess.run(['/usr/bin/taskset -p', str(proc)], capture_output=True) | ||
line = taskset_res.stdout.readline() |
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.
Are you sure this is really faster?
I think the comment suggests reading info from procfs directly instead of spawning a helper 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.
Would unified style help you before further modifications or what is it helpful for (it's non-functional change, right)?
Unfortunately ruff as linter shows on linting both formatting and non-formatting problems. From my experience linting catches mostly unhandled cases and type confusion.
Personally I disagree very often with what Python decided in their formatting pep(s), but configuring it feels too painful/annoying.
The subprocess substitution isn't likely speeding up it as expected.
My bad, will read from procfs directly.
No description provided.