Skip to content
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

Add support for scripts that spin up processes #40

Merged
merged 3 commits into from Aug 2, 2016

Conversation

kyleknap
Copy link
Member

@kyleknap kyleknap commented Aug 1, 2016

Before was not able to accurately track aws cli streaming operations relative to memory usage and cpu usage because the streaming tasks spin off processes in piping inputs and outputs. Now with this PR it is possible to track these numbers.

cc @jamesls @JordonPhillips

Before was not able to accurately track aws cli streaming operations. Now
this is possible.
@jamesls
Copy link
Member

jamesls commented Aug 1, 2016

Which streaming tasks spin off processes? I wouldn't expect that to be the case. Could you add more info?

I'd prefer to just somehow track the actual process we care about rather than aggregate all child processes recursively.

@kyleknap
Copy link
Member Author

kyleknap commented Aug 1, 2016

So I was doing something like this:

./s3transfer/scripts/performance/benchmark "cat 16KB | aws s3 cp - s3://mybucketfoo" --output-file temp.csv --data-interval 0.1

And that was getting me values like 2.3 MB memory usage and 0% CPU usage which is not correct at all.

Is there a better way to measure this than looking at all of the child processes? I am not sure if it is easy to determine what process that we actually care about when the script is relatively general.

@jamesls
Copy link
Member

jamesls commented Aug 1, 2016

Cat's unnecessary. You can use < and > to pipe from/to stdin/stdout, respectively.

Does that work for you?

@kyleknap
Copy link
Member Author

kyleknap commented Aug 1, 2016

No unfortunately. I switched it to:

./s3transfer/scripts/performance/benchmark "aws s3 cp - s3://mybucketfoo < 16KB" --output-file temp.csv --data-interval 0.1

and I was getting no readings for memory usage or disk usage. Only, the changes in this PR allow me to get the values.

@jamesls
Copy link
Member

jamesls commented Aug 1, 2016

I think that's just because of the shell=True. This should actually affect even non streaming transfers. It's actually running /bin/sh and passing the aws ... command as an argument. The process tree looks like:

 |       \-+= 72362 jamesls python scripts/performance/benchmark aws s3 cp - s3://bucket/ < /tmp/largefile --output-file temp.csv --data-interval 1.0
 |         \-+- 72363 jamesls /bin/sh -c aws s3 cp - s3://bucket < /tmp/largefile
 |           \--- 72364 jamesls /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /usr/local/bin/aws s3 cp - s3://bucket

I'd suggest:

  • If the first child process is /bin/sh (the default from subprocess.Popen with shell=True), then look at the grandchild process, and pick the first entry.

@kyleknap
Copy link
Member Author

kyleknap commented Aug 1, 2016

I can do that then.

@kyleknap
Copy link
Member Author

kyleknap commented Aug 2, 2016

@jamesls

I updated it to look to see if there is any child processes and use the first python labeled process found. If there is no child processes, then it uses the original process passed in. The streaming and nonstreaming case work with this.

# We want to always be measuring the python process.
children = process.children(recursive=True)
for child_process in children:
if 'python' in child_process.name():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a case insensitive search. If you look at my process tree in my original comment I have:

 72364 jamesls /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /usr/local/bin/aws s3 cp - s3://bucket

@kyleknap
Copy link
Member Author

kyleknap commented Aug 2, 2016

Alright. I updated to normalize to lowercase. Let me know what you think.

@jamesls
Copy link
Member

jamesls commented Aug 2, 2016

:shipit: Thanks.

@kyleknap kyleknap merged commit a380e4c into boto:develop Aug 2, 2016
@kyleknap kyleknap deleted the include-children branch August 2, 2016 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants