Giter Site home page Giter Site logo

Python vs. C++ backend about rtamt HOT 5 CLOSED

emxaz avatar emxaz commented on August 13, 2024
Python vs. C++ backend

from rtamt.

Comments (5)

nickovic avatar nickovic commented on August 13, 2024

The actual monitoring algorithms for temporal logic operators are implemented in both C++ (rtamt/cpplib/stl/rtamt_stl_library) and Python (rtamt/operation/stl). Both implementations provide the same functionality. Either one or the other is dynamically loaded based on the is_pure_python flag in STLSpecification object (the default value is true, i.e. the pure Python version). We use Boost.Python to create Python wrappers around C++ objects (see (rtamt/cpplib/stl/rtamt_stl_library_wrapper).

The PyPi package currently contains both the source distribution and the binary wheel, i.e. C++ library is pre-compiled on an Ubuntu 16.04 distribution. Our first tests show no visible performance gains in the C++ implementation compared to its Python counterpart, but we need to study it more closely. In principle, we plan to keep both implementation and to have a PyPi package that automatically builds the C++ binaries from the source.

I suggest using the Python-only implementation for now, as we do not have yet visible evidence about the advantage of using the Python/C++ version.

from rtamt.

nickovic avatar nickovic commented on August 13, 2024

I hope it answers your questions, do not hesitate to ask for further clarifications.

from rtamt.

emxaz avatar emxaz commented on August 13, 2024

Thanks, that about covers it for now. I'm interested to hear more regarding the performance tests you ran -- were the specifications simple enough that the overhead of Python didn't make a measurable difference?

from rtamt.

nickovic avatar nickovic commented on August 13, 2024

I reran the performance tests, and now I am indeed able to measure the difference between the pure Python and the Python/C++ implementation - I must have done something wrong in my first evaluation.

There are one major source of complexity in STL monitors - the size of the temporal operator intervals (defining the number of samples that you need to process). I used the time library and recorded the time before and after making an update with time.time()). I used a simple STL formula (always[0:K] (a+b <= 2)) and varied K, and indeed there is a considerable difference between the pure Python and the Python/C++.

The difference starts getting noticeable for K >= 5000

K Python Python/C++
5k 0.009 0.0014
50k 0.2 0.008
500k 40 0.07
etc.

from rtamt.

nickovic avatar nickovic commented on August 13, 2024

I reran the performance tests, and now I am indeed able to measure the difference between the pure Python and the Python/C++ implementation - I must have done something wrong in my first evaluation.

There are one major source of complexity in STL monitors - the size of the temporal operator intervals (defining the number of samples that you need to process). I used the time library and recorded the time before and after making an update with time.time()). I used a simple STL formula (always[0:K] (a+b <= 2)) and varied K, and indeed there is a considerable difference between the pure Python and the Python/C++.

The difference starts getting noticeable for K >= 5000

K Python Python/C++
5k 0.009 0.0014
50k 0.2 0.008
500k 40 0.07
etc.

from rtamt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.