jdtuck / ElasticFDA.jl

Functional Data Analysis using Square-Root Slope Framework
Other
10 stars 5 forks source link

Julia code 6x slower than respective Python #8

Open ll-portes opened 2 years ago

ll-portes commented 2 years ago

Hi,

I was using the Python version of the fdasrsf pkg. However, I tried to use the Julia version to see if I could speed up (or to get better memory management). I don't know if my example (attached) is correct, but to align the same data it took 6s-7s in Julia and 1s in Python. So, maybe there is something within the Julia code preventing it to be fast.

Remark: f.shape is just (100, 15) in the example.

julia-vs-python

jdtuck commented 2 years ago

So I have not updated the Julia package in a long time. Additionally, the c interface is to an older Dynamic Programming which is slower than the one currently in use for Python.

wadehenning commented 2 years ago

@jdtuck I see that he is calculating the Karcher mean. Does the Python version use parallel processing by default (I know the Julia version does not)? @ll-portes , just to double check, are you timing the second run of the Julia implementation so that you are not timing the compile time included in the first run?

jdtuck commented 2 years ago

It does not perform parallel processing by default as his number of sample points is <100. If his sample points >100 then it would kick of parallel processing. Also depending on the numpy version, there will also be openmp usage of the BLAS operations.

ll-portes commented 2 years ago

Thank you for your reply!

Compilation + execution is 12.5 s. When a run for the second time, it gives me 6.4 s. In Python, the omethod is 'DP2'. I tried the other methods to see if maybe DP (Python) would have the same 6s as found with the Julia version, and the results are:

I've uploaded some notebooks (Julia and Python) here ll-portes/ElasticRegistration_studies with the data and timing tests (studing-fdasrvf-Python-2021-11-28.ipynb for Python and studing-fdasrvf-JULIA-2021-11-28.ipynb for Julia).

Remark - I'm glad to know that the Python version has the newer Dynamic Programming because I'm very comfortable in coding with Python (but not in Julia)! There is another issue linked with memory resulting in Python kernel crashing that I'll post at the fdasrvf Python channel.