...
line-profiler - https://pypi.org/project/line-profiler/
...
Requirements
python 3.10: module load itm-python/3.10
...
gprof2dot:
4. pip install gprof2dot
How to run?
- prepare a standard launch
- Copy
python
folder from/gss_efgw_work/work/g2fjc/jintrac/v220922/python
to some location onpfs
for example:/pfs/work/g2pbloch/python
- Change
JINTRAC_PYTHON_DIR
in rjettov (430 line) to python folder on pfs from step 2 - Change
run_python_driver (line 49)
in/pfs/work/g2pbloch/python
: - cProfile :
mpirun --allow-run-as-root -np $NPROC python -u -m cProfile -o jintrac.prof /pfs/work/g2pbloch/jetto_profiler/jintrac_imas_driver.py mpi
- line-profiler :
mpirun --allow-run-as-root -np $NPROC python -u -m kernprof -l /pfs/work/g2pbloch/jetto_profiler/jintrac_imas_driver.py mpi
When we use line-profiler we must add wrapper to profiling function. In this case we should add
@profile
upperjintrac_imas_driver
function injintrac_imas_driver.py
:Code Block language py title function wrapper @profile def jintrac_imas_driver(params, components, mpi='no'): """JINTRAC-IMAS generic workflow driver."""
- Run
./rjettov -S -I -p -x64 test v220922 g2fjc
...
cProfile analysis
To read data from test.prof we need python script. We can use e.g.
...
6. View file name output.svg height 250
Line-profiler analysis
To read data from jintrac_imas_driver.py.lprof
run: python -m line_profiler jintrac_imas_driver.py.lprof
. These are the first few lines of the results :
...
Code Block |
---|
Line # Hits Time Per Hit % Time Line Contents 895 1 62545203.7 62545203.7 26.9 alenv = ALEnv(user_temp=user_tmp) 917 22 49496025.7 2249819.4 21.3 ids_bundle_input[ids_struct] = eval('DBentry.idsin.get("'+ids_struct+'")') 922 1 83745046.9 83745046.9 36.0 tmpdict = bundle_copy(ids_bundle_input) 956 2 4665617.1 2332808.6 2.0 ids_bundle_input[elem] = DBentry.idsin.get_slice(elem, tstart, 3) 966 1 6353190.5 6353190.5 2.7 ids_bundle_work = bundle_copy(ids_bundle_input) 967 1 7884627.8 7884627.8 3.4 ids_bundle_updated = bundle_copy(ids_bundle_input) 1022 3 14539266.0 4846422.0 6.2 ids_bundle_prev[item] = bundle_copy(ids_bundle_work,imas_control.get_ids_sublist_updates(item)) |
...
Candidates for bottlenecks
From cProfile we can see, that 85% execution time jintrac_imas_driver.py spend on imas functions. Function ual_open_pulse
was called only 3 times. It execution time is 27s. Functions
ual_read_data_array
and ual_read_data_scalar
was called more than 2 milions times.
...