Using the Tracer Class#
If you need more control over the tracing process, you can use the Tracer
class directly. As mentioned throughout these examples, the Tracer class
enforces a singleton pattern to manage issues that arise from the underlying mapflpy_fortran object
not being thread-safe. As a result, it is recommended to use the Tracer class
in single-threaded contexts only viz. instantiating one instance of the class at a time.
The benefit of using the Tracer class directly is that it provides direct
access to the mapflpy_fortran object – allowing for faster and more flexible tracing operations.
Alternatively, the TracerMP (while thread-safe) branches new instances of the
mapflpy_fortran object into discrete processes and communicates with these instances through
python’s Pipe() protocol. Although this approach is more robust in multi-threaded
contexts, it incurs a performance penalty due to the overhead of inter-process communication.