# Performance issue with LoadPlugin() (TTK module)

**URL:** https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126
**Category:** ParaView Support
**Tags:** python
**Created:** [June 27, 2019, 7:36am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126 "2019-06-27T07:36:09Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![julien-tierny](https://discourse.paraview.org/user_avatar/discourse.paraview.org/julien-tierny/32/3916_2.png) [@julien-tierny](https://discourse.paraview.org/u/julien-tierny)
#### Post date: [June 27, 2019, 7:36am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/1 "2019-06-27T07:36:09Z")

</div>

hi there,

I am the lead developer of ttk ([https://topology-tool-kit.github.io/](https://topology-tool-kit.github.io/)), an open-source library for topological data analysis, which massively relies on the vtk/paraview ecosystem.

ttk ships with a plugin for paraview.  
we use this plugin to provide python support to our users.

currently, we recommend users to use pvpython, as described in this example:

> **[topology-tool-kit/ttk](https://github.com/topology-tool-kit/ttk/tree/master/examples/python)**
>
> TTK - Topological Data Analysis and Visualization - Source Code - topology-tool-kit/ttk

  
on my system, this example takes 2 seconds to execute.

however, several users expressed the need to use a vanilla python interpreter instead of pvpython (in particular, to integrate ttk into an existing python project).

to run with a default python interpreter (as described there: [https://kitware.github.io/paraview-docs/latest/python/quick-start.html](https://kitware.github.io/paraview-docs/latest/python/quick-start.html)), I setup the PYTHONPATH and LD\_LIBRARY\_PATH as follows:  
$ export PYTHONPATH="/usr/local/lib/python3.6/site-packages/"  
$ export LD\_LIBRARY\_PATH="/usr/local/lib/:/usr/local/lib/plugins"  
(paraview is installed in /usr/local and the ttk plugin in /usr/local/lib/plugins, I use python 3.6)

next, in my python code ([https://github.com/topology-tool-kit/ttk/blob/master/examples/python/ttkExample-python.py](https://github.com/topology-tool-kit/ttk/blob/master/examples/python/ttkExample-python.py)), I add, line 34, the following instruction:  
LoadPlugin(“libTopologyToolKit.so”, ns=globals())

the corresponding diff is shown here:

> <https://github.com/topology-tool-kit/ttk/commit/fb929789d0040a004b1b7378b1e62492b4b14a72#diff-e144caa62c199cb05295f9b57a95cb9d>

and the rest of the script executes properly, … but it takes 40 seconds! ☹  
38 of these are spent in the call LoadPlugin()

so here are my questions:

- is there anything that I did wrong here?
- is there a serious performance issue with this function?

my understanding of the situation is that pvpython ([https://github.com/Kitware/ParaView/blob/master/CommandLineExecutables/pvpython.h](https://github.com/Kitware/ParaView/blob/master/CommandLineExecutables/pvpython.h)) is loading the plugin natively in C++ while LoadPlugin() does some additional parsing in python.  
could that be it?

thanks a lot for your help!  
cheers,

---

<div class="post-metadata">

### Author: ![lhofmann](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@lhofmann](https://discourse.paraview.org/u/lhofmann)
#### Post date: [June 27, 2019, 2:19pm UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/2 "2019-06-27T14:19:03Z")

</div>

I also noticed this issue some time ago, and work around this by loading plugins from the `PV_PLUGIN_PATH` or `PV_PLUGIN_CONFIG_FILE` environment variables, which is much faster than `LoadPlugin()`.

Does `export PV_PLUGIN_PATH=/path/to/ttk/plugins` work for you?  
On my system, all plugins in the specified directory are loaded by `from paraview.simple import *`.

---

<div class="post-metadata">

### Author: ![julien-tierny](https://discourse.paraview.org/user_avatar/discourse.paraview.org/julien-tierny/32/3916_2.png) [@julien-tierny](https://discourse.paraview.org/u/julien-tierny)
#### Post date: [June 27, 2019, 2:43pm UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/3 "2019-06-27T14:43:50Z")

</div>

awesome lutz!  
moving /path/to/ttk/plugins from LD\_LIBRARY\_PATH to PV\_PLUGIN\_PATH actually made the trick! it’s running in 2 seconds again now 🙂

I realize we discussed that at some point a few days ago but I thought the LD\_LIBRARY\_PATH was the official way to go instead (see [https://kitware.github.io/paraview-docs/latest/python/quick-start.html](https://kitware.github.io/paraview-docs/latest/python/quick-start.html))

thanks a lot for your help!!!  
cheers,

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [June 28, 2019, 7:01am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/4 "2019-06-28T07:01:27Z")

</div>

@utkarsh.ayachit Utkarsh, should the documentation be updated to suggest (and perhaps prefer) this other method?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 28, 2019, 9:41am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/5 "2019-06-28T09:41:14Z")

</div>

An issue should also be logged imo, these timings are not normal.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [June 28, 2019, 1:20pm UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/6 "2019-06-28T13:20:47Z")

</div>

Agreed. And if for some reason we cannot improve the plugin loading speed, documentation changes are in order.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 13, 2020, 7:10am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/7 "2020-02-13T07:10:53Z")

</div>

I’m able to reproduce this issue, albeit not as drastically.  
With a build master and LagrangianParticleTracker plugin.

PV\_PLUGIN\_PATH : 1.8s  
LoadPlugin : 3s

I’ve opened an issue here :  
[https://gitlab.kitware.com/paraview/paraview/issues/19681](https://gitlab.kitware.com/paraview/paraview/issues/19681)

@Kenneth_Moreland : I think this should be fixed instead.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 25, 2020, 2:04am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/8 "2020-05-25T02:04:12Z")

</div>

@julien-tierny : A fix has been merged, please use LoadPlugins instead. See here for more info :  
[https://gitlab.kitware.com/paraview/paraview/-/merge\_requests/4092](https://gitlab.kitware.com/paraview/paraview/-/merge_requests/4092)

If you could test, that would be great ?

Also, do you have a gitlab account, I tried to tag you there but couldn’t find you.

---

<div class="post-metadata">

### Author: ![julien-tierny](https://discourse.paraview.org/user_avatar/discourse.paraview.org/julien-tierny/32/3916_2.png) [@julien-tierny](https://discourse.paraview.org/u/julien-tierny)
#### Post date: [May 28, 2020, 9:31am UTC](https://discourse.paraview.org/t/performance-issue-with-loadplugin-ttk-module/2126/9 "2020-05-28T09:31:36Z")

</div>

hi mathieu,  
thanks for your message. I’ll try to have a look at that (I need to dig to find these scripts). cheers,
