Release notes for sbmlsim 0.71.0
A simulation and a scan of the same model now cost a fraction of what they did. Nothing of the API changed and every number is the number of 0.70.0, bitwise; what went away is the work python did again for every call.
A simulator keeps the compiled plan of a simulation per model, keyed by its content, so a loop which simulates the same simulation compiles it once instead of once per call. A run of a scan keeps the text of its request the same way, so a run which differs from the one before it in nothing writes and encodes no request again. A ScanResult builds its xarray.Dataset when something asks for ds and not before: units, dims, variables, ragged, q and the new array(key), which hands out the array of the engine as it is, read the arrays of the result directly, so a reader which only wants numbers never pays for 190 xarray.Variable objects. The times of a simulation of an array of doubles are read once instead of number by number.
A run of a scan runs on the batch executor the model keeps (SBMLModel.batch_executor, sbmlsim_core.scan.run(executor=) of sbmlsim-core 0.71.0, the new floor). The workers of a fresh executor build their instance of the engine at its first batch, which a run made again every time, and for a short run that was most of its cost. A scan of a dimension of models runs on an executor of every one of its models, as before.
Measured on the HCTZ model of 191 selections, one process, against 0.70.0 with the same script:
| 0.70.0 | 0.71.0 | ||
|---|---|---|---|
simulate, 51 rows
| 0.380 ms | 0.157 ms | 2.4x |
simulate, 1001 rows
| 1.354 ms | 0.486 ms | 2.8x |
run to a ScanResult, 51 rows
| 1.976 ms | 0.661 ms | 3.0x |
run to a ScanResult, 1001 rows
| 3.725 ms | 1.480 ms | 2.5x |
res.q[name]
| 0.0227 ms | 0.0039 ms | 5.8x |
res.array(name)
| 0.0001 ms |
A column of a result is now read faster than from libroadrunner, which takes 0.018 ms for one on the same machine.
The JavaScript host of sbmlsim-core reads the values of a result without a copy as well (simulate(request, { borrow: true }) for a view into the memory of the engine, { into: target } for an array of the caller), which a page of the browser runtime of a web app can use.