djanloo / quilt

A multiscale neural simulator
MIT License
0 stars 0 forks source link

Permature destruction of singleton/static objects #28

Closed djanloo closed 1 month ago

djanloo commented 1 month ago

PerfomanceRegistrar should be singleton and alive until the end of program. Most probably the management of the life times of objects due to the Cython environment is the cause. Here is the log:

[2024-07-08 13:24:57] - PID 138023139046528 - INFO: Created PerformanceRegistrar at index: 0x7d87d7899c50
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: PerformanceRegistrar: registered manager 1:oscillator network
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: Built HOMOGENEOUS OscillatorNetwork
[2024-07-08 13:24:57] - PID 138023139046528 - DEBUG: Registering a new Link: base -> base
[2024-07-08 13:24:57] - PID 138[2024-07-08 13:24:58] - PID 138023139046528 - INFO: Destroyed PerformanceRegistrar at index: 0x7d87d791b050
38023139046528 - INFO: Created PerformanceRegistrar at index: 0x7d87d7822af0
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: PerformanceRegistrar: registere[2024-07-08 13:24:58] - PID 138023139046528 - INFO: Destroyed PerformanceRegistrar at index: 0x7d87d7899c50
opulations and 76 oscillators
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: PerformanceRegistrar: registered manager 2:InhomPoissonSpikeSource
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: Transducer initialization rate is 500.000000
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: PerformanceRegistrar: registered manager 3:InhomPoissonSpikeSource
[2024-07-08 13:24:57] - PID 138023139046528 - INFO: Transducer initialization rate is 500.000000

Also the log seems to be buggy. This is clearly due to the static get_global_logger() method of Logger.

djanloo commented 1 month ago

There are too many of them around

[2024-07-08 13:34:54] - PID 130937661985920 - INFO: Destroyed PerformanceRegistrar at index: 0x77162029eaf0
[2024-07-08 13:34:54] - PID 130937661985920 - INFO: Destroyed PerformanceRegistrar at index: 0x771620315c50
[2024-07-08 13:34:54] - PID 130937661985920 - INFO: Destroyed PerformanceRegistrar at index: 0x771620397050

Check https://groups.google.com/g/cython-users/c/GAAPYb2X304

djanloo commented 1 month ago

It seems that the most intelligent way to solve this is to create a single shared library with all the static stuff. At this point it could be wise to remove the compilation of c++ files during the setup, by making a shared library before the setup() method is called, and then linking the extension to the library.

djanloo commented 1 month ago

Making a shared library without setuptools saved the day. Both the logfile and th ePerformanceRegistrar bug are solved.

djanloo commented 1 month ago

Solved with the only drawback that the library path is now an environment variable that has to be set. Thus for now the local installation costs:

export PYTHONPATH=/path/to/quilt
export LD_LIBRARY_PATH=/path/to/quilt/quilt/:$LD_LIBRARY_PATH