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

profiling my plan #165

Open
francoisverbeek opened this issue May 8, 2019 · 5 comments
Open

profiling my plan #165

francoisverbeek opened this issue May 8, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@francoisverbeek
Copy link

Hi guys, thanks again for open-sourcing testplan.
Having written a testplan that starts a few processes and use the TCP server etc, I notice some of my tests are slow. I tried to use the builtin profiler in intellij or cProfile to find out about where and what and I notice that the testplan is actually executed as a separate thread, which escapes the default profilers. For profiling purposes, I'd like to be able to escape that and have a mode where I can run single-threaded. I couldn't find anything in the doc in that respect. Do you have a canonical way to do that? Would you be interested by a pull request?

@francoisverbeek francoisverbeek changed the title profiling testplan profiling my plan May 8, 2019
@francoisverbeek
Copy link
Author

This seems to work for me, will try on a bigger test plan and confirm.

@ryan-collingham
Copy link
Contributor

ryan-collingham commented May 9, 2019

Hi Francois,

Thanks for raising. Yes I agree that it would be useful to be able to profile a testplan. As you note, currently the execution is always run in a separate thread - this is done so that the main thread can quickly jump in and handle any signal interrupts, there are a number of cases where the python runtime will not immediately handle a signal (e.g. while join()-ing another thread). But there are downsides as you note for profiling (also I think many common debuggers do not handle threads well).

Fundamentally though, Testplan is (now) a multithreaded application so I think the most ideal solution would be to find a profiler that can cope with threads, rather than providing a special single-threaded mode for profiling.

Do you think it would be useful to add profiling options at the MultiTest scope, or would a testplan-wide profile be more useful?

@francoisverbeek
Copy link
Author

Hi Ryan,

I've briefly looked at threading-aware profilers and was not overly impressed by what I saw, to be fair. cProfile also has the advantage of being always available, and to be well known and well tooled.
My aim would be more to profile user test code than testplan itself, although I think including things like drivers start and stop would definitely be useful. Experimenting briefly in my fork, wrapping Runnable._run in a simple context manager yields promising results, but I haven't had occasion to test my approach properly yet. Also interesting to consider is to which extend the profile stats could be considered as part of the test report.

To push the idea further, a more generic way to include profilers for the application under test and integrate their results in the reports could also be extremely valuable, for instance valgrind, callgrind, strace, dtrace etc.

that might end up being a lot of work though!

@ryan-collingham
Copy link
Contributor

Sounds like it would be useful to add a profile option at the MultiTest scope then, to be able to profile user testsuites (or possibly even indivudal testcases). We could then include the profile output in the report.

I'll discuss with the team, and if they agree we can add to the list. It won't be a priority right now since we need to add some other key features (e.g. DB uploading) first, but maybe after that is done.

@francoisverbeek
Copy link
Author

Sounds great 👍
Thank you!

@ryan-collingham ryan-collingham added the enhancement New feature or request label May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants