Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

gprof2dot : pip install gprof2dot 

How to run?

  1.  prepare Prepare a standard launch 
  2. Copy python directory from /gss_efgw_work/work/g2fjc/jintrac/v220922/python to some location on pfs for example: /pfs/work/g2pbloch/python 
  3. Change JINTRAC_PYTHON_DIR  in rjettov (430 line) to python directory on pfs from step 2
  4. Change run_python_driver (line 49) in /pfs/work/g2pbloch/python :
  5. 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 
  6. line-profiler : mpirun --allow-run-as-root -np $NPROC python -u  -m kernprof -l /pfs/work/g2pbloch/jetto_profiler/jintrac_imas_driver.py  mpi 
  7. When we use line-profiler we must add wrapper to profiling function. In this case we should add @profile  upper jintrac_imas_driver function in jintrac_imas_driver.py  : 

    Code Block
    languagepy
    titlefunction wrapper
    @profile
    def jintrac_imas_driver(params, components, mpi='no'):
    
        """JINTRAC-IMAS generic workflow driver."""


  8. Run ./rjettov -S -I -p -x64 test v220922 g2fjc 

...

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
titleline-profiler result
Timer unit: 1e-06 s

Total time: 232.892 s
File: /pfs/work/g2pbloch/python/jintrac_imas_driver.py
Function: jintrac_imas_driver at line 721

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   721                                           @profile
   722                                           def jintrac_imas_driver(params, components, mpi='no'):
   723                                           
   724                                               """JINTRAC-IMAS generic workflow driver."""
   725                                           
   726                                               # Workflow configuration parameters
   727                                           
   728         1          5.9      5.9      0.0      user_in = wf.string(params, "Input IDS user")
   729         1          2.3      2.3      0.0      machine_in = wf.string(params, "Input IDS machine")
   730         1          4.7      4.7      0.0      shot_in = wf.integer(params, "Input IDS shot")
   731         1          2.1      2.1      0.0      run_in = wf.integer(params, "Input IDS run")
   732         1          2.9      2.9      0.0      user_out = wf.string(params, "Output IDS user")
   733         1          2.6      2.6      0.0      machine_out = wf.string(params, "Output IDS machine")
   734         1          2.6      2.6      0.0      shot_out = wf.integer(params, "Output IDS shot")
   735         1          2.6      2.6      0.0      run_out = wf.integer(params, "Output IDS run")
   736         1         13.3     13.3      0.0      user_tmp = os.environ['HOME']+'/public/tempdb'

...

Candidates for bottlenecks

From cProfile we result  can see, 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. 

...