The JIT-compiled code time savings don't pay back the compilation time in Python 3.9+, so drop the library dependency. See #1400 and #1413, which improved the payback in some cases but not enough to matter to runSim.
Remove numba from requirements.txt but I'll leave it in the wcEcoli3 pyenv on Sherlock until next time we need to rebuild it.
Update the --jit / --no-jit CLI arg docstrings, but leave in these args so no shell scripts will break.
Don't change the build_ode.build_functions() API or its callers, so it'd be easy to reenable the JIT compiler someday.
Sidetrack
Cumulative string concatenation (see _matrix_to_array()) takes O(n^2) time, so standard practice is to accumulate a list then join it. In some programs n remains small enough to not matter although situations change and code gets reused. I'm either into standard practice, having fun with optimization, or thinking about Google code reviews where one would have to justify an n^2 algorithm.
Timing EQUILIBRIUM_RATES_JACOBIAN with ≈350 non-zero elements:
cumulative concatenation: 0.11 ms
join a list: 0.09 ms
Those are shockingly close, and both are too small to matter to runSim.
Python guru Alex Martelli explains https://stackoverflow.com/a/1350289/1682419 that the CPython compiler optimizes a loop containing s += something if it detects the common case it can handle. The rationale is many Python programmers won't know to use join(), which makes sense. But the fragile optimization could be a trap. Alex recommends using join().
Still, I left _matrix_to_array() as is, but it does rely on a CPython-specific optimization.
The JIT-compiled code time savings don't pay back the compilation time in Python 3.9+, so drop the library dependency. See #1400 and #1413, which improved the payback in some cases but not enough to matter to runSim.
See https://github.com/1fish2/numba-test and https://github.com/1fish2/numba-test/blob/main/observations.md for measurements of 4 matrices captured from a cell sim. Those matrices get evaluated about this many times in a typical cell generation:
Changes
numba
fromrequirements.txt
but I'll leave it in thewcEcoli3
pyenv on Sherlock until next time we need to rebuild it.build_ode.build_functions()
API or its callers, so it'd be easy to reenable the JIT compiler someday.Sidetrack
Cumulative string concatenation (see
_matrix_to_array()
) takes O(n^2) time, so standard practice is to accumulate a list then join it. In some programs n remains small enough to not matter although situations change and code gets reused. I'm either into standard practice, having fun with optimization, or thinking about Google code reviews where one would have to justify an n^2 algorithm.Timing EQUILIBRIUM_RATES_JACOBIAN with ≈350 non-zero elements:
Those are shockingly close, and both are too small to matter to runSim.
Python guru Alex Martelli explains https://stackoverflow.com/a/1350289/1682419 that the CPython compiler optimizes a loop containing
s += something
if it detects the common case it can handle. The rationale is many Python programmers won't know to use join(), which makes sense. But the fragile optimization could be a trap. Alex recommends using join().Still, I left
_matrix_to_array()
as is, but it does rely on a CPython-specific optimization.