Same probe repeated probing performance

Hi,
When I ran the time_poisson_interactive [1] example, I noticed that probing took a lot of time. Speciffically, when I:
- used pb.get_tss_functions(state0, save_results=False) to turn off saving to disk,
- commented out any matplotlib plotting part, and
- turned on options.probe
- ran 201 time steps
... the problem was solved in 46.9 seconds (the tss() call at the bottom), but probing itself (only the entire for loop for the two probes from "for ii, probe in enumerate(probes):" to "append(results)") took 27.1 seconds in total (0.135 sec each step on average).
Further profiling reveals that everytime when Field.evalute_at() is called during probing, the get_ref_coors() function and its subsequent downstream functions are called to (what I understand) find the evalutaion points in the mesh, taking up 26.4 seconds in total.
This is rather inefficient. Is there a way to reuse the previously calculated probing cells, since the probes and mesh are constant throughout the problem?
[1] http://sfepy.org/doc-devel/examples/diffusion/time_poisson_interactive.html
Regards,
Bill

Hi Bill,
On 05/15/2018 04:17 AM, Bill Sze wrote:
Hi,
When I ran the time_poisson_interactive [1] example, I noticed that probing took a lot of time. Speciffically, when I:
- used pb.get_tss_functions(state0, save_results=False) to turn off saving to disk,
- commented out any matplotlib plotting part, and
- turned on options.probe
- ran 201 time steps
... the problem was solved in 46.9 seconds (the tss() call at the bottom), but probing itself (only the entire for loop for the two probes from "for ii, probe in enumerate(probes):" to "append(results)") took 27.1 seconds in total (0.135 sec each step on average).
Further profiling reveals that everytime when Field.evalute_at() is called during probing, the get_ref_coors() function and its subsequent downstream functions are called to (what I understand) find the evalutaion points in the mesh, taking up 26.4 seconds in total.
This is rather inefficient. Is there a way to reuse the previously calculated probing cells, since the probes and mesh are constant throughout the problem?
Good observation, thanks!
It is possible to cache the reference coordinates, but it is up to the caller, and the probes have not used that feature.
I have just updated the probes (work in progress) to reuse the reference coordinates, if possible - could you check the updated code in [2] and report back here if the update improves your results?
r.
[2] https://github.com/rc/sfepy/tree/cache-refcoors-in-probes
[1] http://sfepy.org/doc-devel/examples/diffusion/time_poisson_interactive.html

Hi Robert,
Thanks for the fast response! The new version is quite amazing for me since in my own model I am probing the result on each time step.
Anyways, here are my rough benchmarks using the same script as I described before (no disk writes, no plotting, 201 time steps)
- Before: total time: 36.0 sec, in which probe time: 20.8 sec
- After: total time: 16.6 sec, in which probe time: 0.73 sec, the first probe took 90 ms and the rest were 3.2+/-0.6 ms (min 2.6 ms, max 5.6 ms).
Thank you for the patch!
Regards,
Bill

On 05/15/2018 04:08 PM, Bill Sze wrote:
Hi Robert,
Thanks for the fast response! The new version is quite amazing for me since in my own model I am probing the result on each time step.
Anyways, here are my rough benchmarks using the same script as I described before (no disk writes, no plotting, 201 time steps)
- Before: total time: 36.0 sec, in which probe time: 20.8 sec
- After: total time: 16.6 sec, in which probe time: 0.73 sec, the first probe took 90 ms and the rest were 3.2+/-0.6 ms (min 2.6 ms, max 5.6 ms).
OK!
I might clean it up a bit more and then merge the branch.
r.
participants (2)
-
Bill Sze
-
Robert Cimrman