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
cli: optimize reana-client #359
Conversation
@@ -77,6 +76,7 @@ def get_files(ctx, workflow, _filter, | |||
Examples: \n | |||
\t $ reana-client ls --workflow myanalysis.42 | |||
""" | |||
import tablib |
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.
BTW another improvement like importing tablib
is related to parsing yaml
, which is very slow. Do we need to use FullLoader
? Cannot we use CLoader
? It would be much faster:
In [19]: %timeit with open('./reana_client/schemas/reana_analysis_schema.json', 'r') as afile: res_f = yaml.load(afile, Loader=yaml.FullLoader)
24 ms ± 376 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [20]: %timeit with open('./reana_client/schemas/reana_analysis_schema.json', 'r') as afile: res_c = yaml.load(afile, Loader=yaml.CLoader)
1.87 ms ± 91.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
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.
I tested it and didn't notice significant differences in performance. Perhaps reana.yaml
should be bigger to notice them? Any example to better test it?
f9fe724
to
4fe0805
Compare
Nice improvements! And we have a room for more, e.g. compare $ python -m cProfile -o rc.prof ~/.virtualenvs/reana/bin/reana-client version
$ echo -e 'sort cumtime\nstats' | python -m pstats rc.prof | less
453917 function calls (443016 primitive calls) in 1.018 seconds
...
1 0.000 0.000 0.506 0.506 /home/simko/private/project/reana/src/reana-client/reana_client/utils.py:8(<module>)
1 0.000 0.000 0.500 0.500 /home/simko/.virtualenvs/reana/lib/python3.8/site-packages/yadageschemas/__init__.py:1(<module>)
1 0.000 0.000 0.270 0.270 /home/simko/.virtualenvs/reana/lib/python3.8/site-packages/pkg_resources/__init__.py:2(<module>)
1 0.000 0.000 0.236 0.236 /home/simko/.virtualenvs/reana/lib/python3.8/site-packages/jsonschema/__init__.py:1(<module>)
2151 0.008 0.000 0.235 0.000 /home/simko/.virtualenvs/reana/lib/python3.8/re.py:287(_compile)
172 0.000 0.000 0.226 0.001 /home/simko/.virtualenvs/reana/lib/python3.8/re.py:248(compile) with ~0.5 seconds spent in yadage schemas and ~0.3 seconds with the regular expression business handling (2K compilations!), while $ python -m cProfile -o rc.prof ~/.virtualenvs/reana/bin/reana-dev version
$ echo -e 'sort cumtime\nstats' | python -m pstats rc.prof | less
28090 function calls (27441 primitive calls) in 0.098 seconds We can think of these further improvements later. |
All commands tested, everything working except |
4fe0805
to
ed0acab
Compare
ed0acab
to
593d75b
Compare
* Client operations are expensive, moving the client imports inside the functions that use them reduces loading time as it only performs the import when it's really needed
593d75b
to
0b425c0
Compare
closes #354
Optimizations:
ping
: ~2.2s → ~0.8s--help
: ~0.6s → ~0.3sversion
: ~0.6s → ~0.3screate
: ~2s → ~1.2sstart
: ~2.4s → ~1.5sstatus
: ~1.6s → ~1.2srun
: ~7s → ~3.9s (reana-demo-worldpopulation)list
: ~1.6s → ~1.2sdiff
: ~1.6s → ~1slogs
: ~1.6s → ~1sstop
: ~1s → ~0.4supload
: ~2.3s → ~1.2sdownload
: ~1.8s → ~1.1sdu
: ~1.5s → ~0.9sls
: ~2s → ~1.6smv
: ~2.9s → ~2.3srm
: ~1.6s → ~1s